Submission #170307

# Submission time Handle Problem Language Result Execution time Memory
170307 2019-12-24T16:04:50 Z bgspartan Red-blue table (IZhO19_stones) C++14
38 / 100
32 ms 2168 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxN=1001;
char table[maxN][maxN];
bool fr1=false,fr2=false;

void fillTable(ll n,ll m,bool my){
    ll mod=n/2+1,rep=m-(m/2+1);
    ll diff=(n/2+1)-(n-(n/2+1));
    if(m>2){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(j<rep*((i/mod)+1) and j>=rep*(i/mod)){
                table[i][j]='-';
            }else{
                table[i][j]='+';
            }
        }
    }
    if(my==true){
        for(int i=0;i<diff;i++){
            for(int j=0;j<m;j++){
                table[n/2-i][j]='-';
            }
        }
    }
    }else{
        for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
            table[i][j]='+';
                }
        }
    }
}
ll n[maxN],m[maxN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
ll t,ans1=0,ans2=0;
cin>>t;
for(int i=0;i<t;i++){
    cin>>n[i]>>m[i];
}
for(int i=0;i<t;i++){
    ll lef1=0,lef2,frmin1=0,frmin2=0;
     fr1=false;
    fr2=false;
    lef1=m[i]-(m[i]/2+1);
    lef2=n[i]-(n[i]/2+1);
    ans1=n[i]+lef1;
    ans2=m[i]+lef2;
    frmin1=(m[i]-(m[i]/2+1))*lef2;
    frmin2=(n[i]-(n[i]/2+1))*lef1;
    if(m[i]-m[i]/2-1>(n[i]/2+1)-(n[i]-(n[i]/2+1))){
        ans1+=m[i]-m[i]/2-1;
        ans1-=(n[i]/2+1)-(n[i]-(n[i]/2+1));
        fr1=true;

    }
     if(n[i]-n[i]/2-1>(m[i]/2+1)-(m[i]-(m[i]/2+1))){
        ans2+=n[i]-n[i]/2-1;
        ans2-=(m[i]/2+1)-(m[i]-(m[i]/2+1));
        fr2=true;
    }
    //cout<<frmin1<<" "<<frmin2<<"\n";
    //cout<<lef1<<" "<<lef2<<"\n";
   // cout<<ans1<<" "<<ans2<<"\n";

    if(ans1>=ans2){

              fillTable(n[i],m[i],fr1);
         cout<<ans1<<"\n";

        for(int j=0;j<n[i];j++){
            for(int h=0;h<m[i];h++){
                cout<<table[j][h];
            }
            cout<<"\n";
        }

    }else{
        fillTable(m[i],n[i],fr2);
       cout<<ans2<<"\n";
     for(int j=n[i]-1;j>=0;j--){
        for(int h=0;h<m[i];h++){
            if(table[h][j]=='-'){
                cout<<"+";
            }else{
                cout<<"-";
            }
        }
        cout<<"\n";
       }

    }
}
return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:46:20: warning: variable 'frmin1' set but not used [-Wunused-but-set-variable]
     ll lef1=0,lef2,frmin1=0,frmin2=0;
                    ^~~~~~
stones.cpp:46:29: warning: variable 'frmin2' set but not used [-Wunused-but-set-variable]
     ll lef1=0,lef2,frmin1=0,frmin2=0;
                             ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 424 KB Output is correct
4 Incorrect 4 ms 504 KB Wrong answer in test 38 5: 40 < 41
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1500 KB Output is correct
2 Correct 28 ms 2040 KB Output is correct
3 Correct 26 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 1528 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 424 KB Output is correct
4 Incorrect 4 ms 504 KB Wrong answer in test 38 5: 40 < 41