답안 #338936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338936 2020-12-24T10:06:13 Z jenkinsser Red-blue table (IZhO19_stones) C++17
0 / 100
56 ms 1408 KB
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define st first
#define nd second
#define pii pair<int,int>
#define N 200005
#define INF 1000000005
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define ll long long
#define int ll
using namespace std;

int n,m,ans;

void solve(){
    cin >> n >> m;
    char table[n][m];
    vector<int> cnt(n,0);
    int ans;
    if(n>=m){
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                table[i][j]='+';
            }
        }
        ans=n;
        int cur=0;
        int l=n*(m-1)/(n+2);
        for(int i=0;i<n;i++){
            for(int j=0;j<(m-1)/2;j++){
                table[i][cur]='-';
                cnt[cur]++;
                cur++;
                cur%=l;
            }
        }
        for(int i=0;i<l;i++){
            if(cnt[i]>=n/2+1)
                ans++;
        }
    }
    else{
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                table[i][j]='-';
            }
        }
        ans=m;
        int cur=0;
        int l=m*(n-1)/(m+2);
        for(int i=0;i<m;i++){
            for(int j=0;j<(n-1)/2;j++){
                table[i][cur]='+';
                cnt[cur]++;
                cur++;
                cur%=l;
            }
        }
        for(int i=0;i<l;i++){
            if(cnt[i]>=m/2+1)
                ans++;
        }
    }
    cout << ans << endl;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout << table[i][j];
        }
        cout << endl;
    }
}

int32_t main(){
    fastio()
    int t=1;
    cin >> t;
    while(t--)
        solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 4 4: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 4 4: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 1408 KB Wrong answer in test 24 24: 36 < 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 4: 4 < 5