Submission #151304

#TimeUsernameProblemLanguageResultExecution timeMemory
151304hentai_loverRed-blue table (IZhO19_stones)C++14
38 / 100
99 ms16188 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define y1 yy #define tm hui_pizda #define ft first #define sd second #define pb push_back #define pf push_front #define sz size() #define cnt continue #define m_p make_pair #define fr(i, l, r) for(int i = l; i <= r; ++ i) #define rf(i, r, l) for(int i = r; i >= l; -- i) #pragma GCC optimize(-O3) #pragma GCC optimize(Ofast) #pragma GCC optimize("unroll-loops") using namespace __gnu_pbds; using namespace std; template <typename T> using _set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; typedef long long ll; typedef long double ld; typedef pair <ll, ll> pll; typedef pair <int, int> pii; typedef vector <int> vi; typedef vector <ll> vl; typedef vector <pii> vpi; typedef vector <pll> vpl; mt19937_64 rnd(time(NULL)); const ll N = 1010; const ll oo = 1e18 + 10; const ll mod = 1000003; ll a[N][N], ans[N][N], kx[N], ky[N], kans, n, m, T, w; void calc(ll n, ll m, ll s){ bool ft = 1; fr(i, 1, n)fr(j, 1, m){ if(a[i][j] < 0 && !ft){ a[i][j] = s; if((i + j) % 2)s = 1 - s; ft = 1; } else if(a[i][j] < 0){ if((i + j) % 2 == 0)a[i][j] = s; else a[i][j] = 1 - s; } if(a[i][j])kx[i] ++; else ky[j] ++; } ll now = 0; fr(i, 1, n)if(kx[i] * 2 > m)now ++; fr(i, 1, m)if(ky[i] * 2 > n)now ++; // cout << endl; // fr(i, 1, n){ // fr(j, 1, m)cout << a[i][j] << ' '; // cout << endl; // } // cout << "now: " << now << endl; if(now > kans){ kans = now; fr(i, 1, n)fr(j, 1, m)ans[i][j] = a[i][j]; } fr(i, 1, n)kx[i] = 0; fr(i, 1, m)ky[i] = 0; fr(i, 1, n)fr(j, 1, m)a[i][j] = -1; } int main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> T; while(T --){ cin >> n >> m; fr(i, 1, n)fr(j, 1, m)a[i][j] = ans[i][j] = -1; kans = -1; if(n < m)w = 0; else w = 1; //0..2 fr(i, 0, 3){ //0..2 fr(j, 0, 3){ if(n < m){ fr(x, 1, i)fr(y, 1, n)a[y][x] = 1; fr(x, 1, j)fr(y, 1, m)a[x][y] = 0; } else { fr(x, 1, j)fr(y, 1, m)a[x][y] = 0; fr(x, 1, i)fr(y, 1, n)a[y][x] = 1; } calc(n, m, w); } } fr(i, 1, n)fr(j, 1, m)a[i][j] = 0; calc(n, m, w); fr(i, 1, n)fr(j, 1, m)a[i][j] = 1; calc(n, m, w); cout << kans << endl; fr(i, 1, n){ fr(j, 1, m){ if(ans[i][j] == 0)cout << '-'; else cout << '+'; } cout << "\n"; } cout << endl; } return 0; } /* */

Compilation message (stderr)

stones.cpp:15:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(-O3)
                      ^
stones.cpp:16:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(Ofast)
                      ^~~~~
#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...