夢追い人

"It takes a dreamer to make a dream come true."―Vincent Willem van Gogh

昨日解いたやつ

頭は全然使ってない。というか使うのやるほど時間はないw

1657

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, pair<int, pair<int, int> > > P;
int t;
string s, e;
int dx[8] = {-1,0,1,-1,1,-1,0,1};
int dy[8] = {-1,-1,-1,0,0,1,1,1};
int main() {
    scanf("%d",&t);
    for (int i=0; i<t; i++) {
        cin>>s>>e;
        int sx=7-(s[0]-'a'), sy=s[1]-'1';
        int ex=7-(e[0]-'a'), ey=e[1]-'1';
        if (sx<ex) swap(sx,ex);
        if (sy<ey) swap(sy,ey);
        if (sx==ex&&sy==ey) printf("0 0 0 0\n");
        else {
            printf("%d ",max(sx-ex,sy-ey));
            if (sx==ex||sy==ey||sx+sy==ex+ey||sx-ex==sy-ey) printf("1 ");
            else printf("2 ");
            if (sx==ex||sy==ey) printf("1 ");
            else printf("2 ");
            if (sx+sy==ex+ey||sx-ex==sy-ey) printf("1\n");
            else if ((sx+sy-ex-ey)&1) printf("Inf\n");
            else printf("2\n");
        }
    }
}

2013

#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int n, scnt;
string name[20];
int main() {
    scnt = 1;
    while (scanf("%d",&n)) {
        if (!n) break;
        printf("SET %d\n",scnt++);
        for (int i=0; i<n; i++) cin>>name[i];
        vector<string> res;
        for (int i=0; i<n; i+=2) {
            res.push_back(name[i]);
        }
        for (int i=n-1; i>=0; i--) {
            if (i%2) res.push_back(name[i]);
        }
        for (int i=0; i<n; i++) cout<<res[i]<<endl;
    }
}

3435

#include <cstdio>
#include <cstring>
int n, grid[100][100];
int main() {
    scanf("%d",&n);
    for (int i=0; i<n*n; i++) for (int j=0; j<n*n; j++)
        scanf("%d",&grid[i][j]);
    bool cor = true;
    // group check
    int isuse[100];
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            memset(isuse, 0, sizeof(isuse));
            for (int k=i*n; k<(i+1)*n; k++) for (int l=j*n; l<(j+1)*n; l++) {
                if (grid[k][l] == 0) continue;
                if (isuse[grid[k][l]-1]==1) cor = false;
                else isuse[grid[k][l]-1] = 1;
            }
        }
    }
    // row & column check
    for (int i=0; i<n*n; i++) {
        // row
        memset(isuse, 0, sizeof(isuse));
        for (int j=0; j<n*n; j++) {
            if (grid[i][j] == 0) continue;
            if (isuse[grid[i][j]-1]==1) cor = false;
            else isuse[grid[i][j]-1] = 1;
        }
        // column
        memset(isuse, 0, sizeof(isuse));
        for (int j=0; j<n*n; j++) {
            if (grid[j][i] == 0) continue;
            if (isuse[grid[j][i]-1]==1) cor = false;
            else isuse[grid[j][i]-1] = 1;
        }
    }
    if (cor) puts("CORRECT");
    else puts("INCORRECT");
}

3117

#include <cstdio>
#include <iostream>
using namespace std;
int t, n, po;
string str;
int main() {
    while (scanf("%d%d",&t,&n)) {
        if (!t&&!n) break;
        int sum = 0;
        for (int i=0; i<t; i++) {
            cin>>str>>po;
            sum += po;
        }
        printf("%d\n",3*n-sum);
    }
}
広告を非表示にする