Submission #245196

#TimeUsernameProblemLanguageResultExecution timeMemory
245196urd05여왕벌 (KOI15_queen)C++14
10 / 100
5087 ms67576 KiB
#include <bits/stdc++.h>
using namespace std;

int arr[700][700][3][3][3]; //i,j,l,lu,u
int zero[1000000];
int one[1000000];
int two[1000000];
int grow[700][700];
int val[700][700];
long long save[1400][700][11];

typedef pair<int,int> P;

P next(P pt) {
    if (pt.first==0) {
        return P(pt.first,pt.second+1);
    }
    return P(pt.first-1,pt.second);
}

int main(void) {
    int m,n;
    scanf("%d %d\n",&m,&n);
    for(int i=0;i<m;i++) {
        for(int j=0;j<m;j++) {
            val[i][j]=1;
        }
    }
    for(int i=1;i<m;i++) {
        for(int j=1;j<m;j++) {
            for(int l=0;l<3;l++) {
                for(int lu=0;lu<3;lu++) {
                    for(int u=0;u<3;u++) {
                        char x;
                        scanf("%c",&x);
                        if (x=='L') {
                            arr[i][j][l][lu][u]=l;
                        }
                        if (x=='D') {
                            arr[i][j][l][lu][u]=lu;
                        }
                        if (x=='U') {
                            arr[i][j][l][lu][u]=u;
                        }
                    }
                }
            }
            scanf("\n");
        }
    }
    int cnt[1400];
    memset(cnt,0,sizeof(cnt));
    for(int i=0;i<n;i++) {
        scanf("%d %d %d",&zero[i],&one[i],&two[i]);
        cnt[zero[i]]++;
    }
    bool flag=true;
    for(int i=0;i<n;i++) {
        if (two[i]!=0) {
            flag=false;
        }
    }
    if (!flag) {
        for(int ind=0;ind<n;ind++) {
            P pos=P(m-1,0);
            for(int j=0;j<zero[ind];j++) {
                grow[pos.first][pos.second]=0;
                pos=next(pos);
            }
            for(int j=0;j<one[ind];j++) {
                grow[pos.first][pos.second]=1;
                pos=next(pos);
            }
            for(int j=0;j<two[ind];j++) {
                grow[pos.first][pos.second]=2;
                pos=next(pos);
            }
            for(int i=1;i<m;i++) {
                grow[i][i]=arr[i][i][grow[i][i-1]][grow[i-1][i-1]][grow[i-1][i]];
                for(int j=i+1;j<m;j++) {
                    grow[i][j]=arr[i][j][grow[i][j-1]][grow[i-1][j-1]][grow[i-1][j]];
                }
                for(int j=i+1;j<m;j++) {
                    grow[j][i]=arr[j][i][grow[j][i-1]][grow[j-1][i-1]][grow[j-1][i]];
                }
            }
            for(int i=0;i<m;i++) {
                for(int j=0;j<m;j++) {
                    val[i][j]+=grow[i][j];
                }
            }
        }
        for(int i=0;i<m;i++) {
            for(int j=0;j<m;j++) {
                printf("%d ",val[i][j]);
            }
            printf("\n");
        }
        return 0;
    }
    for(int ind=0;ind<2*m;ind++) {
        zero[ind]=ind;
        one[ind]=2*m-1-ind;
        P pos=P(m-1,0);
        for(int j=0;j<zero[ind];j++) {
            grow[pos.first][pos.second]=0;
            pos=next(pos);
        }
        for(int j=0;j<one[ind];j++) {
            grow[pos.first][pos.second]=1;
            pos=next(pos);
        }
        for(int i=1;i<m;i++) {
            grow[i][i]=arr[i][i][grow[i][i-1]][grow[i-1][i-1]][grow[i-1][i]];
            for(int j=i+1;j<m;j++) {
                grow[i][j]=arr[i][j][grow[i][j-1]][grow[i-1][j-1]][grow[i-1][j]];
            }
            for(int j=i+1;j<m;j++) {
                grow[j][i]=arr[j][i][grow[j][i-1]][grow[j-1][i-1]][grow[j-1][i]];
            }
        }
        for(int i=0;i<m;i++) {
            for(int j=0;j<m;j++) {
                save[ind][i][j/64]|=(grow[i][j]<<(j%64));
            }
        }
    }
    for(int i=0;i<m;i++) {
        for(int j=0;j<m;j++) {
            int val=1;
            for(int k=0;k<2*m;k++) {
                val+=cnt[k]*((save[k][i][j/64]>>(j%64))&1);
            }
            printf("%d ",val);
        }
        printf("\n");
    }
}

Compilation message (stderr)

queen.cpp: In function 'int main()':
queen.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d\n",&m,&n);
     ~~~~~^~~~~~~~~~~~~~~~~
queen.cpp:35:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                         scanf("%c",&x);
                         ~~~~~^~~~~~~~~
queen.cpp:48:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("\n");
             ~~~~~^~~~~~
queen.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d",&zero[i],&one[i],&two[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...