# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
544857 | 2022-04-02T22:11:53 Z | MilosMilutinovic | Red-blue table (IZhO19_stones) | C++14 | 2000 ms | 764 KB |
#include<bits/stdc++.h> #define fi first #define se second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;} template<typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;} int n,m; void solve(){ scanf("%d%d",&n,&m); int ans=n,tx=0,ty=0; for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){ vector<int> row(n+1),col(m+1); for(int x=1;x<=n;x++)for(int y=1;y<=m;y++){ int b=((x<=i&&y<=j)?-1:1); row[x]+=b; col[y]+=b; } int tans=0; for(int x=1;x<=n;x++)if(row[x]>0)tans++; for(int y=1;y<=m;y++)if(col[y]<0)tans++; if(tans>ans)ans=tans,tx=i,ty=j; } printf("%d\n",ans); for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++)printf("%c",(i<=tx&&j<=ty?'-':'+')); printf("\n"); } } int main(){ int T; scanf("%d",&T); while(T--)solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 6 ms | 212 KB | Output is correct |
4 | Incorrect | 12 ms | 300 KB | Wrong answer in test 5 29: 31 < 32 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2070 ms | 764 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2075 ms | 652 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 6 ms | 212 KB | Output is correct |
4 | Incorrect | 12 ms | 300 KB | Wrong answer in test 5 29: 31 < 32 |
5 | Halted | 0 ms | 0 KB | - |