Submission #167676

# Submission time Handle Problem Language Result Execution time Memory
167676 2019-12-09T12:15:38 Z beso123 Red-blue table (IZhO19_stones) C++14
15 / 100
134 ms 5240 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int t;
bool sort21(pair<int,int> a,pair<int,int> b){
    return a.first<b.first;
}
main(){
cin>>t;
while(t--){
    int n,m;
    cin>>n>>m;
    int M=(n/2)+1;
    int N=(m/2)+1;
    int a[n+1][m+1];
    int b[max(n,m)+1];
    for(int k=1;k<=n;k++){
        b[k]=0;
        for(int i=1;i<=m;i++)
            a[k][i]=0;
    }
    if(n>=m){
    int ans=n;
    for(int i=1;i<=m;i++){
            vector<pair<int,int> > v;
        for(int k=1;k<=n;k++){
            v.push_back({b[k],k});
        }
        sort(v.begin(),v.end(),sort21);

        if(m-v[N-1].first==N)
            break;
            ans++;
        for(int k=0;k<N;k++){
            a[v[k].second][i]=1;
            b[v[k].second]++;
        }
    }
    cout<<ans<<endl;
    for(int k=1;k<=n;k++){
        for(int i=1;i<=m;i++)
            if(a[k][i])
            cout<<'-';
        else cout<<'+';
        cout<<endl;
    }
    }
    else{
       int ans=m;
    for(int i=1;i<=n;i++){
            vector<pair<int,int> > v;
        for(int k=1;k<=m;k++){
            v.push_back({b[k],k});
        }
        sort(v.begin(),v.end(),sort21);

        if(n-v[M-1].first==M)
            break;
            ans++;
        for(int k=0;k<M;k++){
            a[i][v[k].second]=1;
            b[v[k].second]++;
        }
    }
    cout<<ans<<endl;
    for(int k=1;k<=n;k++){
        for(int i=1;i<=m;i++)
            if(a[k][i])
            cout<<'+';
        else cout<<'-';
        cout<<endl;
    }
    }
}

return 0;
}

Compilation message

stones.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
stones.cpp: In function 'int main()':
stones.cpp:31:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(m-v[N-1].first==N)
         ^~
stones.cpp:33:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
             ans++;
             ^~~
stones.cpp:57:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(n-v[M-1].first==M)
         ^~
stones.cpp:59:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
             ans++;
             ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB in the table A+B is not equal to 6
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 376 KB in the table A+B is not equal to 48
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB in the table A+B is not equal to 6
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 1468 KB in the table A+B is not equal to 118
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 108 ms 1444 KB Output is correct
2 Correct 79 ms 5240 KB Output is correct
3 Correct 73 ms 3704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB in the table A+B is not equal to 6