Submission #146465

# Submission time Handle Problem Language Result Execution time Memory
146465 2019-08-24T08:23:44 Z achibasadzishvili Red-blue table (IZhO19_stones) C++14
11 / 100
82 ms 2168 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 + 1) / 2;
        ned2 = (n + 1) / 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 2
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 456 KB in the table A+B is not equal to 2
# 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 2
# Verdict Execution time Memory Grader output
1 Correct 82 ms 1528 KB Output is correct
2 Correct 36 ms 2040 KB Output is correct
3 Correct 31 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 1400 KB in the table A+B is not equal to 48
2 Halted 0 ms 0 KB -
# 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 2