SDUT 2021 Winter Team Contest - 5(Kattis)

Kattis

A - Alchemy 101

题目链接

答案

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
const int M = 111;
using namespace std;

void solve(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n%4==0){
            cout<<n<<endl;
            rep(i,1,n){
                if(i==n) cout<<i<<endl;
                else cout<<i<<" ";
            }
        }
        else if(n%4==1){
            if(n==1){
                puts("1");
                puts("1");
            }
            else{
                cout<<n-1<<endl;
                rep(i,1,n-2) cout<<i<<" ";
                cout<<n<<endl;
            }
        }
        else if(n%4==2){
            cout<<n-1<<endl;
            rep(i,2,n-1) cout<<i<<" ";
            cout<<n<<endl;
        }
        else if(n%4==3){
            cout<<n-1<<endl;
            rep(i,1,n-1){
                if(i==n-1) cout<<i<<endl;
                else cout<<i<<" ";
            }
            //cout<<n<<endl;
        }
    }
}

int main() {
    solve();
	return 0;
}

C - Can Tho Expressway

题目链接

答案

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
const int M = 111;
using namespace std;

int a[N];
int dx[M];
int dy[M];

void solve(){
    int t;
    cin>>t;
    while(t--){
        int x1,y1;
        int x2,y2;
        cin>>x1>>y1>>x2>>y2;
        if(x2<y2) swap(x2,y2);
        int m;
        cin>>m;
        rep(i,1,m){
            cin>>dx[i]>>dy[i];
        }
        int l=0;
        int r=0;
        rep(i,1,m){
            int tep=dx[i]*x1+dy[i]*y1;
            if(tep>=x2) l++;
            else r++;
        }
        if(l==m){
            puts("NO");
            continue;
        }
        l=r=0;
        rep(i,1,m){
            int tep=dx[i]*x1+dy[i]*y1;
            if(tep<=y2) r++;
            else l++;
        }
        if(r==m){
            puts("NO");
            continue;
        }
        puts("YES");
    }
}

int main() {
    solve();
	return 0;
}

F - Final Exam

题目链接

答案

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const int M = 1111;
using namespace std;

char s[M];

void solve(){
     int n;
     cin>>n;
     int cnt=0;
     rep(i,0,n-1){
        cin>>s[i];
        if(i){
            if(s[i]==s[i-1]) cnt++;
        }
     }
     cout<<cnt<<endl;
}

int main() {
    solve();
	return 0;
}

上一篇:AtCoder Beginner Contest 188 F- +1-1x2 记忆化搜索


下一篇:【Samara Farewell Contest 2020 H】Video Reviews - 2 题解