Submission #146466

# Submission time Handle Problem Language Result Execution time Memory
146466 2019-08-24T08:25:01 Z achibasadzishvili Red-blue table (IZhO19_stones) C++14
26 / 100
83 ms 2040 KB
#include<bits/stdc++.h>
#define ll int
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,m,ind,ned1,ned2,ans,indx,indy;
char a[1005][1005];
int main(){
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    
    while(t--){
        cin >> n >> m;
        ned1 = (m + 2) / 2;
        ned2 = (n + 2) / 2;
        ans = 0;
        for(int i=0; i<=n; i++){
            int l=0,r=m,mid;
            ind = 0;
            while(r >= l){
                mid = (l + r) / 2;
                if(i * (mid - ned1 + (m - mid)) >= mid * (ned2 - (n - i))){
                    l = mid + 1;
                    ind = mid;
                }
                else {
                    r = mid - 1;
                }
            }
            if(i + ind > ans){
                ans = i + ind;
                indx = i;
                indy = ind;
            }
        }
        cout << ans << endl;
        for(int i=indx+1; i<=n; i++)
            for(int j=1; j<=m; j++)
                a[i][j] = '-';
        for(int j=indy + 1; j<=m; j++)
            for(int i=1; i<=n; i++)
                a[i][j] = '+';
        int k = indy - ned1 + (m - indy),p;
        if(k <= 0){
            for(int i=1; i<=indx; i++)
                for(int j=1; j<=indy; j++)
                    a[i][j] ='-';
        }
        else {
            int l = 1;
            for(int i=1; i<=indx; i++)
                for(int j=1; j<=indy; j++)
                    a[i][j] = '+';
            for(int i=1; i<=indx; i++){
                p = k;
                while(p--){
                    a[i][l] = '-';
                    l++;
                    if(l == indy + 1)
                        l = 1;
                }
            }
        }
        for(int i=1; i<=n; i++){
            for(int j=1; j<=m; j++)
                cout << a[i][j];
            cout << endl;
        }
    }
    
    
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 3
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 376 KB in the table A+B is not equal to 3
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 3
# Verdict Execution time Memory Grader output
1 Correct 83 ms 1404 KB Output is correct
2 Correct 32 ms 2040 KB Output is correct
3 Correct 31 ms 2040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 1508 KB Output is correct
2 Correct 34 ms 1884 KB Output is correct
3 Correct 27 ms 1672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 3