제출 #879047

#제출 시각아이디문제언어결과실행 시간메모리
879047Elvin_FritlRed-blue table (IZhO19_stones)C++17
32 / 100
40 ms2960 KiB
#include <bits/stdc++.h> using namespace std; #define io \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long ll; ll bp(ll n,ll m){ if(m == 0){ return 1; } if(m == 1){ return n; } if(m%2==0){ return bp(n*n,m/2); } return n*bp(n,m-1); } const int N = 1020, M = 33, inf = 1e9 + 99; const ll inff = 1e12; void solve() { int n,m; cin >> n >> m; vector<vector<int>>a(n + 1 , vector<int>(m + 1 , 0)); if(n <= 4 && m <= 4) { 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++) { a[i][j] = -1; } } for(int i=1;i<=x; i++) { for(int j=1;j<=m;j++) { a[i][j] = 1; } } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cout << (a[i][j] == 1 ? '+' : '-'); } 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++) { a[i][j] = -1; } for(int j=1;j<=m- x;j++){ a[i][j] = 1; } } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cout << (a[i][j] == 1 ? '+' : '-'); } cout<<endl; } } } else if(n == m && n == 6) { for(int i=1;i<=n;i++) { for(int j=1;j<=3;j++){ a[i][j] = 1; } } int tmp=(n/2 - 2)*n, x=1, y=n; while(tmp > 0) { tmp--; a[x][y] = 1; x++; y--; if(y==3){ y=n; } if(x==n+1){ x=1; } } 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; } } } int main() { io; int t; cin >> t; while(t--) { solve(); } 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...