Submission #544856

#TimeUsernameProblemLanguageResultExecution timeMemory
544856MilosMilutinovicRed-blue table (IZhO19_stones)C++14
0 / 100
2077 ms632 KiB
#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=0,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 (stderr)

stones.cpp: In function 'void solve()':
stones.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
stones.cpp: In function 'int main()':
stones.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |  scanf("%d",&T);
      |  ~~~~~^~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...