Submission #474751

#TimeUsernameProblemLanguageResultExecution timeMemory
474751levsog2004Red-blue table (IZhO19_stones)C++14
43 / 100
185 ms6072 KiB
#include <iostream> #include <iomanip> #include <fstream> #include <algorithm> #include <cstring> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <cmath> #include <list> #include <set> #include <map> #define all(x) x.begin(),x.end() #define al(a,n) (a,a+n) #define se second #define fr first #define m_p make_pair using namespace std; typedef long long ll; const ll N = 2000004; const ll mod = 1000 * 1000 * 100 + 7; const ll inf = 1000000009; ll n, m, k, z, t, x, y,a[1006][1006], ans; int calc(int w) { int q=0; while (w > 1) { q += w / 2; w /= 2; } return q; } int main() { cin >> t; while (t--) { cin >> x >> y; for (int i = 1000; i >= 0; --i) for (int j = 100; j >= 0; --j) a[i][j] = 0; if (x < y) { map <ll, ll> mp,mpp; cout << y + calc(x-1) + (x==y && y==24)<< endl; int j = 0,jj=0; for (int i = 0; i < x; ++i) { j = jj; while (a[i][j] == 0) { if (mp[j] < (x - 1) / 2 && mpp[i] < y / 2 + 1) { a[i][j] = 1; mp[j]++; mpp[i]++; jj = (j+1)%y; } else a[i][j] = 2; j++; j %= y; } } } else { cout << x + calc(y - 1) + (x == y && y == 24) << endl; map <ll, ll> mp, mpp; int i = 0,ii=0; for (int j = 0; j < y; ++j) { i = ii; while(a[i][j]==0) { if (mp[j] < x / 2 + 1 && mpp[i] < (y - 1) / 2) { a[i][j] = 2; mp[j]++; mpp[i]++; ii = (i+1)%x; } else a[i][j] = 1; i++; i %= x; } } } for (int i = 0; i < x; ++i) { for (int j = 0; j < y; ++j) if (a[i][j] == 1) cout << '+'; else cout << '-'; 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...