Submission #336929

# Submission time Handle Problem Language Result Execution time Memory
336929 2020-12-17T11:12:27 Z BY_KUTBILIM Red-blue table (IZhO19_stones) C++14
100 / 100
76 ms 2284 KB
/** @BY_KUTBILIM **/
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();

    int t;
    cin >> t;
    while(t--){
        int n, m;
        cin >> n >> m;
        char ans[n][m];
        bool f = false;
        if(n < m){
            swap(n, m);
            f = 1;
        }
        char a[n][m];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                a[i][j] = '+';
            }
        }
        
        int half = n / 2 + 1, J = 0, Ans = n;
        for(int j = 0; j < (m - 1) / 2; j++){
            for(int i = 0; i < n; i++){
                a[i][J] = '-';
                half--;
                if(!half){
                    half = n / 2 + 1;
                    J++;
                    Ans++;
                }
            }
        }
        
        cout << Ans << endl;
        if(f)swap(n, m);
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(f)cout << char('+' + '-' - a[j][i]);
                else cout << a[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:19:14: warning: unused variable 'ans' [-Wunused-variable]
   19 |         char ans[n][m];
      |              ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Correct 18 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 1388 KB Output is correct
2 Correct 34 ms 1900 KB Output is correct
3 Correct 32 ms 1900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 1388 KB Output is correct
2 Correct 30 ms 1644 KB Output is correct
3 Correct 28 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Correct 18 ms 384 KB Output is correct
5 Correct 76 ms 1388 KB Output is correct
6 Correct 34 ms 1900 KB Output is correct
7 Correct 32 ms 1900 KB Output is correct
8 Correct 54 ms 1388 KB Output is correct
9 Correct 30 ms 1644 KB Output is correct
10 Correct 28 ms 1516 KB Output is correct
11 Correct 39 ms 620 KB Output is correct
12 Correct 30 ms 1516 KB Output is correct
13 Correct 34 ms 1536 KB Output is correct
14 Correct 26 ms 1144 KB Output is correct
15 Correct 35 ms 2284 KB Output is correct
16 Correct 27 ms 1772 KB Output is correct
17 Correct 13 ms 1004 KB Output is correct