Submission #857040

# Submission time Handle Problem Language Result Execution time Memory
857040 2023-10-05T09:37:50 Z elotelo966 Red-blue table (IZhO19_stones) C++17
0 / 100
20 ms 1396 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY 1000000005
#define mod 1000000007
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mid (start+end)/2
#define lim 1000005
//char di[lim][lim],di2[lim][lim],di3[lim][lim],di4[lim][lim];
int32_t main(){
    faster
    int t;cin>>t;
    while(t--){
        int as1=0,as2=0;
        int n,m;cin>>n>>m;
        char dizi[n][m],di[n][m];
        //if(n/2+m>=m/2+n){
            if(n&1){
                //cout<<n/2+m<<'\n';
                as1=n/2+m;
                for(int i=0;i<n;i++){
                    if(!(i&1)){
                        for(int j=0;j<m;j++){
                            dizi[i][j]='-';
                        }
                    }
                    else {
                        for(int j=0;j<m;j++){
                            dizi[i][j]='+';
                        }
                    }
                   // cout<<'\n';
                }
            }
            else{
                
                int deg=n-2;
               // cout<<abs(deg)/2+m<<'\n';
                as1=abs(deg)/2+m;
                for(int i=0;i<deg;i++){
                    if(!(i&1)){
                        for(int j=0;j<m;j++){
                            dizi[i][j]='-';
                        }
                    }
                    else for(int j=0;j<m;j++){
                        dizi[i][j]='+';
                    }
                   // cout<<'\n';
                }
                deg=abs(deg);
                if(n-deg>=2){
                    for(int j=0;j<m;j++)dizi[deg][j]='+';
                    //cout<<'\n';
                }
                deg=abs(deg-1);
                if(n-deg>=1){
                    for(int j=0;j<m;j++)dizi[deg+1][j]='-';
                   // cout<<'\n';
                }
                
            }
            
       // }
       // else{
            if(m&1){
              //  cout<<m/2+n<<'\n';
                as2=m/2+n;
                for(int i=0;i<n;i++){
                   for(int j=0;j<m;j++){
                       if(!(j&1)){
                           di[i][j]='+';
                       }
                       else di[i][j]='-';
                   }
                   //cout<<'\n';
                }
            }
            else{
                int dg=n-2;
               // cout<<abs(dg)/2+m<<'\n';
                as2=abs(dg)/2+m;
                for(int i=0;i<dg;i++){
                    for(int j=0;j<m;j++){
                       if(!(j&1)){
                           di[i][j]='+';
                       }
                       else if(j==m-1)di[i][j]='+';
                       else di[i][j]='-';
                   }
                   //cout<<'\n';
                }
                
            }
            if(as1<as2){
                cout<<as2<<'\n';
                for(int i=0;i<n;i++){
                    for(int j=0;j<m;j++){
                        cout<<di[i][j];
                    }
                    cout<<'\n';
                }
            }
            else{
                cout<<as1<<'\n';
                for(int i=0;i<n;i++){
                    for(int j=0;j<m;j++){
                        cout<<dizi[i][j];
                    }
                    cout<<'\n';
                }
            }
      //  }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB invalid character
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB invalid character
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1396 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1368 KB invalid character
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB invalid character
3 Halted 0 ms 0 KB -