Submission #992887

#TimeUsernameProblemLanguageResultExecution timeMemory
992887vivkostovRed-blue table (IZhO19_stones)C++14
11 / 100
24 ms2140 KiB
#include<bits/stdc++.h> #define endl "\n" using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int t,n,m,h; char a1,a2; string s[1005]; void print(int br) { cout<<br<<endl; if(h) { for(int i=1; i<=m; i++) { for(int j=1; j<=n; j++) { cout<<s[j][i-1]; } cout<<endl; } return; } for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { cout<<s[i][j-1]; } cout<<endl; } } void fil(int i) { for(int j=1;j<=m;j++)s[i]+=a1; } void fila2(int i,int st) { int gr=(((m-1)/2)*n)/(n/2+1); if(gr==0)return; for(int j=1;j<=(n-1)/2;j++) { s[i][st-1]=a2; st--; if(st<m-gr)st=m; } } void old() { int br=0; if(n==m&&m>=5) { for(int i=1; i<=(n-1)/2; i++) { for(int j=1; j<=m/2+1; j++) { s[i]+=a1; } for(int j=m/2+2; j<=m; j++) { s[i]+=a2; } br++; } for(int i=(n-1)/2+1; i<=n-2; i++) { for(int j=1; j<=(m-1)/2; j++) { s[i]+=a2; } for(int j=(m-1)/2+1; j<=m; j++) { s[i]+=a1; } br++; } for(int i=1; i<=m; i++) { s[n-1]+=a2; s[n]+=a2; } br+=((m-1)/2)*2; } //if(false); else { for(int i=1; i<=n; i++) { for(int j=1; j<=m/2+1; j++) { s[i]+=a1; } for(int j=m/2+2; j<=m; j++) { s[i]+=a2; } br++; } br+=(m-1)/2; } print(br); } void resheven() { old; return; int br=n+(((m-1)/2)*n)/(n/2+1),pos=m,gr=(((m-1)/2)*n)/(n/2+1); //cout<<(((m-1)/2)*n)/(n/2+1)<<endl; for(int i=1;i<=n;i++) { fil(i); fila2(i,pos); pos--; if(pos<=m-gr)pos=m; } print(br); } void resh() { int br=0; for(int i=1; i<=(n-1)/2; i++) { for(int j=1; j<=m/2+1; j++) { s[i]+=a1; } for(int j=m/2+2; j<=m; j++) { s[i]+=a2; } br++; } for(int i=(n-1)/2+1; i<=n-1; i++) { for(int j=1; j<=(m-1)/2; j++) { s[i]+=a2; } for(int j=(m-1)/2+1; j<=m; j++) { s[i]+=a1; } br++; } if(m>2) { for(int i=1; i<=m; i++) { s[n]+=a2; } br+=((m-1)/2)*2; } else { for(int i=1; i<=m; i++) { s[n]+=a1; } br++; } print(br); } void read() { cin>>t; for(int z=1; z<=t; z++) { cin>>n>>m; if(n<m) { swap(n,m); a1='-'; a2='+'; h=1; } else { a1='+'; a2='-'; } if(n%2==0)resheven(); else resh(); h=0; for(int i=1; i<=n; i++)s[i].clear(); } } int main() { speed(); read(); return 0; }

Compilation message (stderr)

stones.cpp: In function 'void resheven()':
stones.cpp:109:5: warning: statement is a reference, not call, to function 'old' [-Waddress]
  109 |     old;
      |     ^~~
stones.cpp:109:5: warning: statement has no effect [-Wunused-value]
#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...