# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
245201 | 2020-07-05T17:28:05 Z | urd05 | 여왕벌 (KOI15_queen) | C++14 | 5000 ms | 67720 KB |
#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]; typedef pair<int,int> P; vector<P> v[700]; 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++) { if (ind==m-1||ind==m) { 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 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]+=cnt[ind]*grow[i][j]; } } } else if (ind<m-1) { v[0].push_back(P(ind-m+1,cnt[ind])); int col=m-ind; for(int i=1;i<m;i++) { if (col<m&&arr[col][i][0][1][1]==1) { col++; while (col<m&&arr[col][i][0][0][1]==1) { col++; } } v[i].push_back(P(i-col+1,cnt[ind])); } } else { v[0].push_back(P(ind-m+1,cnt[ind])); int row=ind-m+1; for(int i=1;i<m;i++) { if (row<m&&arr[i][row][0][0][1]==0) { row++; while (row<m&&arr[i][row][0][1][1]==0) { row++; } } v[i].push_back(P(row-i,cnt[ind])); } } } for(int i=0;i<m;i++) { int p=0; int ind=0; for(int j=-i+1;j<=i-1;j++) { while (ind<v[i].size()&&v[i][ind].first<=j) { p+=v[i][ind].second; ind++; } int x=i; int y=i; if (j<0) { x+=-j; } else { y+=j; } val[x][y]+=p; } } for(int i=0;i<m;i++) { for(int j=0;j<m;j++) { printf("%d ",val[i][j]); } printf("\n"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 512 KB | Output is correct |
2 | Correct | 5 ms | 512 KB | Output is correct |
3 | Correct | 20 ms | 2432 KB | Output is correct |
4 | Correct | 21 ms | 2432 KB | Output is correct |
5 | Correct | 145 ms | 12920 KB | Output is correct |
6 | Correct | 143 ms | 12920 KB | Output is correct |
7 | Correct | 141 ms | 13048 KB | Output is correct |
8 | Correct | 398 ms | 31992 KB | Output is correct |
9 | Correct | 376 ms | 32120 KB | Output is correct |
10 | Correct | 731 ms | 56952 KB | Output is correct |
11 | Correct | 787 ms | 56952 KB | Output is correct |
12 | Correct | 771 ms | 56952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 640 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 640 KB | Output is correct |
2 | Correct | 1170 ms | 2528 KB | Output is correct |
3 | Execution timed out | 5083 ms | 31608 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5078 ms | 43244 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 278 ms | 12152 KB | Output is correct |
6 | Correct | 275 ms | 12152 KB | Output is correct |
7 | Correct | 301 ms | 12152 KB | Output is correct |
8 | Correct | 296 ms | 12152 KB | Output is correct |
9 | Execution timed out | 5086 ms | 67720 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |