Submission #473774

# Submission time Handle Problem Language Result Execution time Memory
473774 2021-09-16T08:47:34 Z Ahmed_Solyman Crtanje (COCI20_crtanje) C++14
20 / 50
174 ms 16304 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(500,vector<char>(500,'.'));
    for(ll start=0;start<n;start++){
        ll prev=-1;
        vector<vector<char>>temp(500,vector<char>(500,'.'));
        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--;
                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<500;i++){
        bool b=0;
        for(ll j=0;j<500;j++){
            b|=(ans[i][j]!='.');
        }
        if(!b){
            for(ll j=0;j<500;j++){
                un_valid[{i,j}]=1;
            }
        }
    }
    for(ll i=0;i<500;i++){
        bool b=0;
        for(ll j=0;j<500;j++){
            b|=(ans[j][i]!='.');
        }
        if(!b){
            for(ll j=0;j<500;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;
}
# Verdict Execution time Memory Grader output
1 Correct 163 ms 16100 KB Output is correct
2 Incorrect 156 ms 16096 KB Output isn't correct
3 Incorrect 174 ms 16128 KB Output isn't correct
4 Incorrect 157 ms 16100 KB Output isn't correct
5 Correct 137 ms 16304 KB Output is correct