Submission #683832

#TimeUsernameProblemLanguageResultExecution timeMemory
683832dostigatorRed-blue table (IZhO19_stones)C++17
27 / 100
145 ms1416 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 && m==1){ cout<<n<<endl; for(int i=1; i<=n; ++i){ cout<<'+'; cout<<endl; }return; } if(n<=m || 1){ 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; }/*int nd=n/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 j=1; j<=m; ++j){ if(l+nd-1<=n) { for(int i=l; i<=l+nd-1; ++i) matrix[i][j]='+'; l+=2; if(l>n) l%=n; } if(l+nd-1>n){ for(int i=l; i<=n; ++i) matrix[i][j]='+'; l+=nd; --l; l%=n; for(int i=1; i<=l; ++i)matrix[i][j]='+'; l+=2; if(l>n)l%=n; }int cnt=j; int mn=inf; for(int i=1; i<=n; ++i){ int cur=0; for(int x=1; x<=m; ++x)if(matrix[j][x]=='-')++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; }*/ } 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:55:8: warning: unused variable 'mn' [-Wunused-variable]
   55 |    int mn=inf;
      |        ^~
stones.cpp: In function 'int main()':
stones.cpp:143:11: warning: unused variable 'lolol' [-Wunused-variable]
  143 |  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...