2017CCPC秦皇岛(C、E、L、M)

C - Crusaders Quest

#include
using namespace std;
#define clr(a) memset(a, 0, sizeof(a))
#define line cout<<"-------------"<> T;
    while(T--){
        clr(s);
        scanf("%s", s);
        bool flag = false;
        char str;
        for(int i=0; i<7; i++){
            if(s[i] == s[i+1] && s[i] == s[i+2]){
                flag = true;
                str = s[i];
                break;
            }
        }
        if(flag){
            char a[11];
            int pos = 0;
            for(int i=0; i<9; i++){
                if(s[i] != str){
                    a[pos ++] = s[i];
                }
            }
            int ans = 2;
            for(int i=0; i<6; i++){
                if(a[i] == a[i+1] && a[i] == a[i+2]){
                    ans = 3;
                    break;
                }
            }
            cout << ans << endl;
        }
        else {
            int ans = 1;
            char a[11];
            int pos = 0;
            for(int i=0; i<9; i++){
                if(s[i] != 'a') a[pos++] = s[i];
            }
            for(int i=0; i<6; i++){
                if(a[i] == a[i+1] && a[i] == a[i+2]){
                    ans = 2;
                    break;
                }
            }
            clr(a); pos = 0;
            for(int i=0; i<9; i++){
                if(s[i] != 'o') a[pos++] = s[i];
            }
            for(int i=0; i<6; i++){
                if(a[i] == a[i+1] && a[i] == a[i+2]){
                    ans = 2;
                    break;
                }
            }
            clr(a); pos = 0;
            for(int i=0; i<9; i++){
                if(s[i] != 'g') a[pos++] = s[i];
            }
            for(int i=0; i<6; i++){
                if(a[i] == a[i+1] && a[i] == a[i+2]){
                    ans = 2;
                    break;
                }
            }
            cout << ans << endl;
        }
    }

    return 0;
}

E - String of CCPC

#include
using namespace std;
#define clr(a) memset(a,0,sizeof(a))

const int maxn = 2e5+10;
const int MAXN = 1e6+10;
const int INF = 0x3f3f3f3f;
const int N = 1010;

char s[maxn];
int n, cnt;

int main(){
    int T;
    scanf("%d", &T);
    while(T--){
        clr(s);
        cnt = 0;
        scanf("%d %s", &n, s);
        bool flag = false;
        for(int i=0; i

L - One-Dimensional Maze

#include
using namespace std;
#define clr(a) memset(a, 0, sizeof(a))
#define line cout<<"-------------"<> T;
    while(T--){
        clr(s);
        scanf("%d%d",&n, &m);
        scanf("%s", s+1);
        int ans = 0;
        int num1 = 0, num2 = 1;
        if(s[m] == 'L'){
            for(int i=2; i<=m-1; i++){
                if(s[i] == 'R') num1 ++;
            }
            for(int i=m+1; i<=n-1; i++){
                if(s[i] == 'L') num2 ++;
            }
            ans = min(num1, num2);
        }
        else{
            for(int i=m+1; i<=n-1; i++){
                if(s[i] == 'L') num1 ++;
            }
            for(int i=2; i<=m-1; i++){
                if(s[i] == 'R') num2 ++;
            }
            ans = min(num1, num2);
        }
        cout << ans <

M - Safest Buildings

#include
using namespace std;
#define clr(a) memset(a, 0, sizeof(a))
#define line cout<<"-------------"<= dis)
        return acos(-1.0) * b.r * b.r;
    if(b.r - a.r >= dis)
        return acos(-1.0) * a.r * a.r;
    else{
        double A1 = acos((a.r * a.r + dis * dis - b.r * b.r) / (2 * dis * a.r));
        double A2 = acos((b.r * b.r + dis * dis - a.r * a.r) / (2 * dis * b.r));
        return a.r * a.r * A1 + b.r * b.r * A2 - sin(A1) * a.r * dis;
    }
}
bool cmp(node a, node b){
    return a.s > b.s;
}

int main(){
    int T;
    cin >> T;
    while(T--){
        clr(p);
        scanf("%d%lf%lf", &n, &R, &r);
        pre.r = R-r; pre.x = pre.y = 0.0; pre.s = R*R;
        for(int i=1; i<=n; i++){
            scanf("%lf%lf", &p[i].x, &p[i].y);
            p[i].id = i; p[i].r = r;
            p[i].s = solve(p[i], pre);
        }
        double maxx = -1.0;
        int f[N];
        int num = 1;
        sort(p+1, p+n+1, cmp);
        f[1] = p[1].id;
        for(int i=2; i<=n; i++){
            if(fabs(p[i].s - p[1].s) > eps) break;
            f[++num] = p[i].id;
        }
        sort(f+1, f+num+1);
        printf("%d\n", num);
        for(int i=1; i<=num; i++){
            if(i == num) printf("%d\n", f[i]);
            else printf("%d ", f[i]);
        }
    }
    return 0;
}
/*
2
3 10 5
3 4
3 5
3 6
3 10 4
-7 -6
4 5
5 4
*/

 

你可能感兴趣的:(2018暑假多校补题,套题记录)