답안 #1093909

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1093909 2024-09-28T04:55:02 Z KasymK Red-blue table (IZhO19_stones) C++17
100 / 100
23 ms 5212 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, cnt = 0, j_ = 0;
    for(int ad = 0; ad < (m-1)>>1; ++ad)
        for(int i = 0; i < n; ++i){
            A[i][j_] = 0, cnt++;
            if(cnt == (n>>1)+1)
                j_++, answer++, cnt = 0;
        }
    // wr;
    // for(int i = 0; i < n; ++i){
    //     for(int j = 0; j < m; ++j)
    //         printf("%d", A[i][j]);
    //     puts("");
    // }
    // wr;
    // printf("%d %d %d\n", cnt, answer, j_);
    // wr;
    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)
                if(A[i][j])
                    printf("+");
                else
                    printf("-");
            puts("");
        }
        return;
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j)
            if(A[i][j])
                printf("+");
            else
                printf("-"); 
        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:68:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |     scanf("%d", &tt);
      |     ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1480 KB Output is correct
2 Correct 18 ms 3924 KB Output is correct
3 Correct 23 ms 4084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1372 KB Output is correct
2 Correct 17 ms 3016 KB Output is correct
3 Correct 18 ms 2360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 23 ms 1480 KB Output is correct
6 Correct 18 ms 3924 KB Output is correct
7 Correct 23 ms 4084 KB Output is correct
8 Correct 20 ms 1372 KB Output is correct
9 Correct 17 ms 3016 KB Output is correct
10 Correct 18 ms 2360 KB Output is correct
11 Correct 6 ms 856 KB Output is correct
12 Correct 19 ms 2908 KB Output is correct
13 Correct 20 ms 2240 KB Output is correct
14 Correct 16 ms 1624 KB Output is correct
15 Correct 22 ms 5212 KB Output is correct
16 Correct 16 ms 3928 KB Output is correct
17 Correct 8 ms 1884 KB Output is correct