답안 #857042

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857042 2023-10-05T09:47:53 Z elotelo966 Red-blue table (IZhO19_stones) C++17
0 / 100
18 ms 1420 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+2][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;
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 1368 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 1420 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -