Submission #705025

# Submission time Handle Problem Language Result Execution time Memory
705025 2023-03-03T08:26:19 Z browntoad Superpozicija (COCI22_superpozicija) C++14
0 / 110
23 ms 25876 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n+1)
#define RREP(i, n) for (int i=(n)-1; i>=0; i--)
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())

const int maxn = 8e5+5;

int n;
string str;
vector<pii> op(maxn);
bool typ = 1;

void solve0(){
    // assert(0);

}
void solve1(){
    assert(0);
    if (n%2){
        cout<<-1<<endl;
        return;
    }

}
signed main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t; cin>>t;
    while(t--){
        cin>>n;
        cin>>str;
        REP(i, n){
            cin>>op[i].f>>op[i].s;
            op[i].f--; op[i].s--;
        }
        if (n%2){
            cout<<-1<<endl;
            continue;
        }
        string ret;
        REP(i, 2*n) ret+=' ';
        REP(i, n){
            assert(str[op[i].f] == str[op[i].s]);
            if (str[op[i].f] == '('){
                ret[op[i].f] = '(';
            }
            else {
                ret[op[i].s] = ')';
            }
        }
        int cval = 0;
        bool gg = 0;
        REP(i, 2*n){
            if (str[i] == ' ') continue;
            if (str[i] == '('){
                cval++;
            }
            else {
                cval--;
            }
            if (cval<0) {
                gg=1;
                break;
            }
        }
        if (cval != 0) gg=1;
        if (gg){
            cout<<-1<<endl;
        }
        else {
            REP(i, n){
                if (str[op[i].f] == '(') cout<<0<<' ';
                else cout<<1<<' ';
            }
            cout<<endl;
        }
    }

}
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 25812 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 12756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 25876 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 25812 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -