Submission #329088

#TimeUsernameProblemLanguageResultExecution timeMemory
329088mat_vRed-blue table (IZhO19_stones)C++14
42 / 100
73 ms4076 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i)) #define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i)) #define mod 998244353 #define xx first #define yy second #define all(a) (a).begin(), (a).end() #define pb push_back #define ll long long #define pii pair<int,int> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less) mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int mat[1005][1005]; pii val[1005]; bool da[1005]; int n,m; void solve(){ cin >> n >> m; int p1 = 0; int p2 = m; ff(i,1,m)val[i] = {0,i}; ff(i,1,m)da[i] = 0; vector<int> izb; ff(i,1,n){ sort(val + 1, val + m + 1); int br = (m+2)/2; br -= (izb.size()); ff(j,1,br){ val[j].xx++; } ff(j,1,m){ if(val[j].xx > (n-1)/2 && da[val[j].yy] == 0){ da[val[j].yy] = 1; izb.pb(val[j].yy); } } int tr2 = m - (izb.size()); //cout << i << " " << tr2 << "\n"; if(tr2 + i > p1 + p2){ p1 = i; p2 = tr2; } } cout << p1 + p2 << "\n"; ff(i,1,n){ ff(j,1,m)mat[i][j] = 0; } if(p1 == 0){ ff(i,1,n){ ff(j,1,m)cout << '-'; cout << "\n"; } return; } ff(i,1,m)val[i] = {0,i}; izb.clear(); ff(i,1,m)da[i] = 0; ff(i,1,n){ sort(val + 1, val + m + 1); int br = (m+2)/2; br -= (izb.size()); for(auto c:izb){ mat[i][c] = 1; } ff(j,1,br){ mat[i][val[j].yy] = 1; val[j].xx++; } ff(j,1,m){ if(val[j].xx > (n-1)/2 && da[val[j].yy] == 0){ da[val[j].yy] = 1; izb.pb(val[j].yy); } } int tr2 = m - (izb.size()); //cout << i << " " << tr2 << "\n"; if(tr2 + i == p1 + p2){ ff(k,1,n){ ff(r,1,m){ if(mat[k][r] == 1)cout << '+'; else cout << '-'; } cout << "\n"; } return; } } } int main() { //ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while(t--)solve(); return 0; }

Compilation message (stderr)

stones.cpp: In function 'void solve()':
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:33:5: note: in expansion of macro 'ff'
   33 |     ff(i,1,m)val[i] = {0,i};
      |     ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:34:5: note: in expansion of macro 'ff'
   34 |     ff(i,1,m)da[i] = 0;
      |     ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:38:5: note: in expansion of macro 'ff'
   38 |     ff(i,1,n){
      |     ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:42:9: note: in expansion of macro 'ff'
   42 |         ff(j,1,br){
      |         ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:45:9: note: in expansion of macro 'ff'
   45 |         ff(j,1,m){
      |         ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:59:5: note: in expansion of macro 'ff'
   59 |     ff(i,1,n){
      |     ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:60:9: note: in expansion of macro 'ff'
   60 |         ff(j,1,m)mat[i][j] = 0;
      |         ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:63:9: note: in expansion of macro 'ff'
   63 |         ff(i,1,n){
      |         ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:64:13: note: in expansion of macro 'ff'
   64 |             ff(j,1,m)cout << '-';
      |             ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:69:5: note: in expansion of macro 'ff'
   69 |     ff(i,1,m)val[i] = {0,i};
      |     ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:71:5: note: in expansion of macro 'ff'
   71 |     ff(i,1,m)da[i] = 0;
      |     ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:72:5: note: in expansion of macro 'ff'
   72 |     ff(i,1,n){
      |     ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:79:9: note: in expansion of macro 'ff'
   79 |         ff(j,1,br){
      |         ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:83:9: note: in expansion of macro 'ff'
   83 |         ff(j,1,m){
      |         ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:92:13: note: in expansion of macro 'ff'
   92 |             ff(k,1,n){
      |             ^~
stones.cpp:6:27: warning: unnecessary parentheses in declaration of 'r' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
stones.cpp:93:17: note: in expansion of macro 'ff'
   93 |                 ff(r,1,m){
      |                 ^~
#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...