Submission #683819

#TimeUsernameProblemLanguageResultExecution timeMemory
683819dostigatorRed-blue table (IZhO19_stones)C++17
0 / 100
139 ms1236 KiB
//izho gold #include <bits/stdc++.h> using namespace std; #define all(a) a.begin(),a.end() #define pb push_back #define vt vector #define endl '\n' #define Y second #define X first typedef long long ll; typedef long double ld; const ll mod=1e9+7; const ll INF=1e18; const int inf=1e9; const int N=2e5+505; const int M=1e3+10; const int dx[]={0,0,1,-1}; const int dy[]={1,-1,0,0}; int n,m; void solve(){ cin>>n>>m; if(n<=m){ int nd=m/2+1; char matrix[n+1][m+1]; int l=1; vt<pair<int,int>>lst; for(int i=1; i<=n; ++i)for(int j=1; j<=m; ++j)matrix[i][j]='-'; lst.pb({m,0}); for(int i=1; i<=n; ++i){ if(l+nd-1<=m) { for(int j=l; j<=l+nd-1; ++j) matrix[i][j]='+'; l+=2; if(l>m) l%=m; } if(l+nd-1>m){ for(int j=l; j<=m; ++j) matrix[i][j]='+'; l+=nd; --l; l%=m; for(int j=1; j<=l; ++j)matrix[i][j]='+'; l+=2; if(l>m)l%=m; }int cnt=i; int mn=inf; for(int j=1; j<=m; ++j){ int cur=0; for(int x=1; x<=n; ++x)if(matrix[x][j]=='-')++cur; if(cur>=n/2+1)++cnt; }lst.pb({cnt,i}); }l=1; sort(all(lst)); for(int i=1; i<=n; ++i)for(int j=1; j<=m; ++j)matrix[i][j]='-'; for(int i=1; i<=lst.back().Y; ++i){ if(l+nd-1<=m) { for(int j=l; j<=l+nd-1; ++j) matrix[i][j]='+'; l+=2; if(l>m) l%=m; } if(l+nd-1>m){ for(int j=l; j<=m; ++j) matrix[i][j]='+'; l+=nd; --l; l%=m; for(int j=1; j<=l; ++j)matrix[i][j]='+'; l+=2; if(l>m)l%=m; } }cout<<lst.back().X<<endl; for(int i=1; i<=n; ++i){ for(int j=1; j<=m; ++j){ cout<<matrix[i][j]; }cout<<endl; }return; }cout<<1/0; } int main(){ //srand(time(0)); //freopen("hotel.in","r",stdin); //freopen("hotel.out","w",stdout); ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int tt=1,lolol=0; cin>>tt; while(tt--) { //cout<<"Case "<<++lolol<<": "; solve(); } }

Compilation message (stderr)

stones.cpp: In function 'void solve()':
stones.cpp:48:8: warning: unused variable 'mn' [-Wunused-variable]
   48 |    int mn=inf;
      |        ^~
stones.cpp:78:10: warning: division by zero [-Wdiv-by-zero]
   78 |  }cout<<1/0;
      |         ~^~
stones.cpp: In function 'int main()':
stones.cpp:86:11: warning: unused variable 'lolol' [-Wunused-variable]
   86 |  int tt=1,lolol=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...