Submission #704966

# Submission time Handle Problem Language Result Execution time Memory
704966 2023-03-03T07:24:51 Z Cookie197 Superpozicija (COCI22_superpozicija) C++17
0 / 110
564 ms 1108 KB
#pragma GCC optimize("O4,unroll-loops")
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define endl "\n"
#define mp make_pair
#define out(x) cout << #x << " = " << x << endl

int n,a[100005], b[100005], arr[100005];
string s;
void solve(){
    cin>>n>>s;
    for (int i=1;i<=n*2;i++) s[i-1] == '(' ? arr[i] = 1 : arr[i] = -1;
    for (int i=1;i<=n;i++) cin>>a[i]>>b[i];

    int flag = false;
    if (n<=10){
        for (int bit=0;bit<(1<<n);bit++){
            set<int> st;
            for (int i=0;i<n;i++) {
                if ((bit >> i) & 1) st.insert(b[i+1]);
                else st.insert(a[i+1]);
            }
            int now = 0;
            for (int u:st){
                now += arr[u];
                if (now < 0) break;
            }
            if (now==0){
                for (int i=0;i<n;i++) cout<<((bit>>i) & 1)<<" ";
                cout<<endl;
                flag = true;
                break;
            }
        }

        if (!flag) cout<<-1<<endl;
    }
}
signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t; cin>>t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 564 ms 1076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 564 ms 1076 KB Output isn't correct
2 Halted 0 ms 0 KB -