답안 #329083

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329083 2020-11-19T00:37:33 Z mat_v Red-blue table (IZhO19_stones) C++14
0 / 100
52 ms 1900 KB
#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];
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,n){
        sort(val + 1, val + m + 1);
        ff(j,1,m){
            val[j].xx++;
        }
        int tr2 = m;
        ff(j,1,m)if(val[j].xx > (n-1)/2)tr2--;
        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};
    ff(i,1,n){
        sort(val + 1, val + m + 1);
        ff(j,1,m){
            val[j].xx++;
            mat[i][val[j].yy] = 1;
        }
        int tr2 = m;
        ff(j,1,m)if(val[j].xx > (n-1)/2)tr2--;
        if(p1 == i && p2 == tr2){
            ff(k,1,n){
                ff(r,1,m){
                    if(mat[k][r] == 0)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

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:32:5: note: in expansion of macro 'ff'
   32 |     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,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:36:9: note: in expansion of macro 'ff'
   36 |         ff(j,1,m){
      |         ^~
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:40:9: note: in expansion of macro 'ff'
   40 |         ff(j,1,m)if(val[j].xx > (n-1)/2)tr2--;
      |         ^~
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:47:5: note: in expansion of macro 'ff'
   47 |     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:48:9: note: in expansion of macro 'ff'
   48 |         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:51:9: note: in expansion of macro 'ff'
   51 |         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:52:13: note: in expansion of macro 'ff'
   52 |             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:57:5: note: in expansion of macro 'ff'
   57 |     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:58:5: note: in expansion of macro 'ff'
   58 |     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){
      |         ^~
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:65:9: note: in expansion of macro 'ff'
   65 |         ff(j,1,m)if(val[j].xx > (n-1)/2)tr2--;
      |         ^~
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:67:13: note: in expansion of macro 'ff'
   67 |             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:68:17: note: in expansion of macro 'ff'
   68 |                 ff(r,1,m){
      |                 ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 4 3: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 620 KB Wrong answer in test 4 3: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 4 3: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 1772 KB Wrong answer in test 97 21: 97 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 1900 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 4 3: 4 < 5