Submission #769759

# Submission time Handle Problem Language Result Execution time Memory
769759 2023-06-30T08:18:01 Z Trunkty Red-blue table (IZhO19_stones) C++14
15 / 100
22 ms 1840 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
 
int t;
char arr[1005][1005];
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> t;
    for(int e=1;e<=t;e++){
        int n,m,ans;
        cin >> n >> m;
        if(n>=m){
            int rem = m-m/2-1, need = n-(n-n/2-1);
            for(int i=1;i<=n;i++){
                for(int j=1;j<=m;j++){
                    arr[i][j] = '+';
                }
            }
            int curr=1,cnt=0;
            for(int c=0;c<rem*n;c++){
                if(cnt==need){
                    cnt = 0;
                    curr++;
                }
                arr[c%n+1][curr] = '-';
                cnt++;
            }
            if(cnt==need){
                cnt = 0;
                curr++;
            }
            ans = n+curr-1LL;
        }
        else{
            int rem = n-n/2-1, need = m-(m-m/2-1);
            for(int i=1;i<=n;i++){
                for(int j=1;j<=m;j++){
                    arr[i][j] = '-';
                }
            }
            int curr=1,cnt=0;
            for(int c=0;c<rem*m;c++){
                if(cnt==need){
                    cnt = 0;
                    curr++;
                }
                arr[curr][c%m+1] = '-';
                cnt++;
            }
            if(cnt==need){
                cnt = 0;
                curr++;
            }
            ans = m+curr-1LL;
        }
        cout << ans << "\n";
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                cout << arr[i][j];
            }
            cout << "\n";
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB in the table A+B is not equal to 5
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB in the table A+B is not equal to 46
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB in the table A+B is not equal to 5
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1396 KB in the table A+B is not equal to 78
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1384 KB Output is correct
2 Correct 17 ms 1840 KB Output is correct
3 Correct 15 ms 1644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB in the table A+B is not equal to 5
3 Halted 0 ms 0 KB -