답안 #705041

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
705041 2023-03-03T09:20:27 Z browntoad Superpozicija (COCI22_superpozicija) C++14
0 / 110
53 ms 25852 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(){
    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;
        }
    }

}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 25812 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 12756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 25852 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 25812 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -