Submission #1093907

# Submission time Handle Problem Language Result Execution time Memory
1093907 2024-09-28T04:47:21 Z KasymK Red-blue table (IZhO19_stones) C++17
0 / 100
43 ms 1504 KB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

void solve(int green_flecks){
    int n, m;
    scanf("%d%d", &n, &m);
    bool ok = 0;
    if(n < m){
        swap(n, m);
        ok = 1;
    }
    vector<vector<int>> A(n, vector<int> (m, 1));
    int answer = n;
    int cnt = 0, x = 0;
    for(int ad = 0; ad < (m-1)>>1; ++ad)
        for(int i = 0; i < n; ++i){
            A[i][x] = 0, cnt++;
            if(cnt == (n>>1)+1)
                x++, answer++, cnt = 0;
        }
    printf("%d\n", answer);
    if(ok){
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < m; ++j)
                A[i][j] ^= 1;
        for(int j = 0; j < m; ++j){
            for(int i = 0; i < n; ++i)
                printf("%d", A[i][j]);
            puts("");
        }
        return;
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j)
            printf("%d", A[i][j]);
        puts("");
    }
}

int main(){
    int tt;
    scanf("%d", &tt);
    while(tt--)
        solve(tt);
    return 0;
}

Compilation message

stones.cpp: In function 'void solve(int)':
stones.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
stones.cpp: In function 'int main()':
stones.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |     scanf("%d", &tt);
      |     ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB invalid character
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB invalid character
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB invalid character
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 1372 KB invalid character
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 1504 KB invalid character
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB invalid character
2 Halted 0 ms 0 KB -