# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173458 | 2020-01-04T07:44:48 Z | juggernaut | Red-blue table (IZhO19_stones) | C++14 | 33 ms | 2296 KB |
//Just try and the idea will come! #include<bits/stdc++.h> using namespace std; int t,n,m,cnt[1001]; bool a[1001][1001]; int run1(){ int res=m,i,j,last=1,cur,mid; for(i=1;i<=n;i++) for(j=1;j<=m;j++)a[i][j]=false,cnt[j]=n; for(i=1;i<=n;i++){ cur=last; mid=(m>>1)+1; while(mid){ if(cnt[cur]>n/2+1){ cnt[cur]--; a[i][cur]=true; mid--; } cur++; if(cur==m+1)cur=1; if(cur==last)break; } if(mid==0)res++,last=cur;else break; } return res; } int run2(){ int res=n,i,j,last=1,cur,mid; for(i=1;i<=n;i++) for(j=1;j<=m;j++)a[i][j]=true,cnt[i]=m; for(i=1;i<=m;i++){ cur=last; mid=(n>>1)+1; while(mid){ if(cnt[cur]>m/2+1){ cnt[cur]--; a[cur][i]=false; mid--; } cur++; if(cur==n+1)cur=1; if(cur==last)break; } if(mid==0)res++,last=cur;else break; } return res; } int main(){ scanf("%d",&t); while(t--){ scanf("%d%d",&n,&m); if(run1()>run2())printf("%d\n",run1()); else printf("%d\n",run2()); for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++)if(a[i][j])putchar('+'); else putchar('-'); puts(""); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 1528 KB | Output is correct |
2 | Correct | 28 ms | 2040 KB | Output is correct |
3 | Correct | 28 ms | 2168 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 1528 KB | Output is correct |
2 | Correct | 25 ms | 1836 KB | Output is correct |
3 | Correct | 23 ms | 1656 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 27 ms | 1528 KB | Output is correct |
6 | Correct | 28 ms | 2040 KB | Output is correct |
7 | Correct | 28 ms | 2168 KB | Output is correct |
8 | Correct | 26 ms | 1528 KB | Output is correct |
9 | Correct | 25 ms | 1836 KB | Output is correct |
10 | Correct | 23 ms | 1656 KB | Output is correct |
11 | Correct | 8 ms | 632 KB | Output is correct |
12 | Correct | 28 ms | 1912 KB | Output is correct |
13 | Correct | 27 ms | 2040 KB | Output is correct |
14 | Correct | 19 ms | 1656 KB | Output is correct |
15 | Correct | 33 ms | 2296 KB | Output is correct |
16 | Correct | 22 ms | 1912 KB | Output is correct |
17 | Correct | 12 ms | 1272 KB | Output is correct |