답안 #473769

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473769 2021-09-16T08:43:08 Z Ahmed_Solyman Crtanje (COCI20_crtanje) C++14
20 / 50
4 ms 876 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n;
ll valid(ll i){
    if(i>=0 && i<n)return 1;
    return 0;
}
char con(char c){
    if(c=='+')return '/';
    else if(c=='-')return 92;
    else return '-';
}
int main()
{
    cin>>n;
    string s;cin>>s;
    vector<vector<char>>ans(n,vector<char>(n,'.'));
    for(ll start=0;start<n;start++){
        ll prev=-1;
        vector<vector<char>>temp(n,vector<char>(n,'.'));
        bool b=1;
        char c;
        for(ll i=0;i<n;i++){
            if(prev==-1){
                temp[start][i]=con(s[i]);
                prev=start;
                c=s[i];
            }
            else{
                ll x=0;
                if(s[i]=='-' && c!='+')x++;
                else if(s[i]=='+' && c!='-')x--;
                else if(s[i]=='='){
                    if(c=='+')x--;
                    else if(c=='-')x++;
                }
                ll j=prev+x;
                if(!valid(j)){
                    b=0;
                    break;
                }
                else{
                    temp[j][i]=con(s[i]);
                    prev=j;
                    c=s[i];
                }
            }
        }
        if(b){
            ans=temp;
            break;
        }
    }
    map<pair<ll,ll>,bool>un_valid;
    for(ll i=0;i<n;i++){
        bool b=0;
        for(ll j=0;j<n;j++){
            b|=(ans[i][j]!='.');
        }
        if(!b){
            for(ll j=0;j<n;j++){
                un_valid[{i,j}]=1;
            }
        }
    }
    for(ll i=0;i<n;i++){
        bool b=0;
        for(ll j=0;j<n;j++){
            b|=(ans[j][i]!='.');
        }
        if(!b){
            for(ll j=0;j<n;j++){
                un_valid[{j,i}]=1;
            }
        }
    }
    for(ll i=0;i<n;i++){
        bool b=0;
        for(ll j=0;j<n;j++){
            if(un_valid[{i,j}]){
                continue;
            }
            b=1;
            cout<<ans[i][j];
        }
        if(b)cout<<endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 844 KB Output is correct
2 Incorrect 4 ms 876 KB Output isn't correct
3 Incorrect 3 ms 844 KB Output isn't correct
4 Incorrect 3 ms 844 KB Output isn't correct
5 Correct 3 ms 844 KB Output is correct