Submission #338942

#TimeUsernameProblemLanguageResultExecution timeMemory
338942jenkinsserRed-blue table (IZhO19_stones)C++17
10 / 100
78 ms1516 KiB
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define vi vector<int> #define st first #define nd second #define pii pair<int,int> #define N 200005 #define INF 1000000005 #define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define all(x) (x).begin(),(x).end() #define ll long long #define int ll using namespace std; int n,m,ans; int cnt[N]; void solve(){ cin >> n >> m; char table[n+1][m+1]; int ans; if(n>=m){ for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ table[i][j]='+'; } } ans=n; int cur=1; int l=n*(m-1)/(n+2); for(int i=1;i<=n;i++){ for(int j=1;j<=(m-1)/2;j++){ table[i][cur]='-'; cnt[cur]++; cur++; if(cur-1==l) cur=1; } } for(int i=1;i<=l;i++){ if(cnt[i]>=n/2+1) ans++; cnt[i]=0; } } else{ for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ table[i][j]='-'; } } ans=m; int cur=1; int l=m*(n-1)/(m+2); for(int i=1;i<=m;i++){ for(int j=1;j<=(n-1)/2;j++){ table[cur][i]='+'; cnt[cur]++; cur++; if(cur-1==l) cur=1; cnt[i]=0; } } for(int i=1;i<=l;i++){ if(cnt[i]>=m/2+1) ans++; } } cout << ans << endl; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cout << table[i][j]; } cout << endl; } } int32_t main(){ fastio() int t=1; cin >> t; while(t--) solve(); }

Compilation message (stderr)

stones.cpp: In function 'void solve()':
stones.cpp:41:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   41 |             if(cnt[i]>=n/2+1) ans++; cnt[i]=0;
      |             ^~
stones.cpp:41:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   41 |             if(cnt[i]>=n/2+1) ans++; cnt[i]=0;
      |                                      ^~~
stones.cpp:58:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   58 |                 if(cur-1==l) cur=1; cnt[i]=0;
      |                 ^~
stones.cpp:58:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   58 |                 if(cur-1==l) cur=1; cnt[i]=0;
      |                                     ^~~
#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...