Submission #868493

#TimeUsernameProblemLanguageResultExecution timeMemory
868493KiaRezRed-blue table (IZhO19_stones)C++17
69 / 100
19 ms4956 KiB
/* IN THE NAME OF GOD */ #include <bits/stdc++.h> // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef long double ld; #define F first #define S second #define Mp make_pair #define pb push_back #define pf push_front #define size(x) ((ll)x.size()) #define all(x) (x).begin(),(x).end() #define kill(x) cout << x << '\n', exit(0); #define fuck(x) cout << "(" << #x << " , " << x << ")" << endl #define endl '\n' const int N = 3e5+23, lg = 18; ll Mod = 1e9+7; //998244353; inline ll MOD(ll a, ll mod=Mod) {a%=mod; (a<0)&&(a+=mod); return a;} inline ll poww(ll a, ll b, ll mod=Mod) { ll ans = 1; a=MOD(a, mod); while (b) { if (b & 1) ans = MOD(ans*a, mod); b >>= 1; a = MOD(a*a, mod); } return ans; } int t, n, m, x; void solve44() { if(n<=m) { cout<<(n-1)/2+m<<endl; int x = (n-1)/2; for(int i=1; i<=n-x; i++) { for(int j=1; j<=m; j++) { cout<<'-'; } cout<<endl; } for(int i=1; i<=x; i++) { for(int j=1; j<=m; j++) { cout<<"+"; } cout<<endl; } } else { cout<<(m-1)/2+n<<endl; int x = (m-1)/2; for(int i=1; i<=n; i++) { for(int j=1; j<=x; j++) { cout<<'-'; } for(int j=1; j<=m-x; j++){ cout<<'+'; } cout<<endl; } } } int a[1005][1005]; int main () { ios_base::sync_with_stdio(false), cin.tie(0); cin>>t; while(t--) { cin>>n>>m; for(int i=1; i<=n; i++) fill(a[i], a[i]+m+2, 0); if(n<=4 || m<=4) { solve44(); } else if((n==5 || m==5) && (n+m)%2==1) { if(n == 5) { for(int i=1; i<=2; i++) { for(int j=1; j<=m; j++) a[i][j] = -1; } int x=3, y=1; while(y <= m) { a[x][y] = -1; x++; y++; if(x==n+1) x=3; } cout<<3+m<<endl; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { cout<<(a[i][j] == -1 ? '-' : '+'); } cout<<endl; } } else { for(int i=1; i<=2; i++) { for(int j=1; j<=n; j++) a[j][i] = 1; } int x=1, y=3; while(x <= n) { a[x][y] = 1; x++; y++; if(y==m+1) y=3; } cout<<3+n<<endl; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { cout<<(a[i][j] == 1 ? '+' : '-'); } cout<<endl; } } } else if(m==6 || n==6) { if(n == 6) { for(int i=1; i<=3; i++) { for(int j=1; j<=m; j++) a[i][j] = -1; } int x=4, y=1; while(y <= m) { a[x][y] = -1; x++; y++; if(x==n+1) x=4; } cout<<3+m<<endl; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { cout<<(a[i][j] == -1 ? '-' : '+'); } cout<<endl; } } else { for(int i=1; i<=3; i++) { for(int j=1; j<=n; j++) a[j][i] = 1; } int x=1, y=4; while(x <= n) { a[x][y] = 1; x++; y++; if(y==m+1) y=4; } cout<<3+n<<endl; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { cout<<(a[i][j] == 1 ? '+' : '-'); } cout<<endl; } } /*for(int i=1; i<=n; i++) { for(int j=1; j<=3; j++) a[i][j] = 1; } int ptr=1, num=(n/2-2), x=1, y=n; while(x<=n) { int f = num; while(f > 0) { a[x][y] = 1; y--; if(y==3) y=n; f--; } x++; } cout<<n+m-3<<endl; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { cout<<(a[i][j] == 1 ? '+' : '-'); } cout<<endl; }*/ } else { for(int i=1; i<=n-(n-1)/2; i++) { for(int j=1; j<=(m-1)/2; j++) { a[i][j] = -1; } } for(int i=(n-1)/2+1; i<=n; i++) { for(int j=(m)/2+2; j<=m; j++) { a[i][j] = -1; } } cout<<2*((n-1)/2 + (m-1)/2)<<endl; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { cout<<(a[i][j] == -1 ? '-' : '+'); } 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...