제출 #258888

#제출 시각아이디문제언어결과실행 시간메모리
258888uacoder123Red-blue table (IZhO19_stones)C++14
100 / 100
102 ms2296 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; char arr[1000][1000]; int main() { int test; cin>>test; for(;test>0;--test) { int n,m; cin>>n>>m; int nr=(m)/2+1; int nc=(n)/2+1; iii ans=mp(m,mp(0,m)); for(int i=0;i<=m;++i) { for(int j=0;j<=n;++j) { int c=nr-(m-i); if(c>0) { c=int((c*j)/i)+min((c*j)%i,1); if(c<=n-nc) ans=max(ans,mp(i+j,mp(j,i))); } else ans=max(ans,mp(i+j,mp(j,i))); } } for(int i=0;i<n;++i) { for(int j=0;j<m;++j) { if(j<ans.S.S) arr[i][j]='-'; else arr[i][j]='+'; } } int c=0; for(int i=0;i<ans.S.F;++i) { int co=0,t=nr-(m-ans.S.S); while(co!=t) { arr[i][c]='+'; c=(c+1)%ans.S.S; co++; } } cout<<ans.F<<endl; for(int i=0;i<n;++i) { for(int j=0;j<m;++j) cout<<arr[i][j]; cout<<endl; } } return(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...