Submission #643546

# Submission time Handle Problem Language Result Execution time Memory
643546 2022-09-22T11:35:56 Z mychecksedad Superpozicija (COCI22_superpozicija) C++17
10 / 110
16 ms 2724 KB
/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20;


int n;
string s;
pair<int, int> a[N];
void solve(){
    cin >> n >> s;
    bool o = 1;
    string t = s;
    for(int i = 0; i < n; ++i){
        cin >> a[i].first >> a[i].second; 
        if(s[a[i].first - 1] == '(') t[a[i].second - 1] = '0';
        else t[a[i].first - 1] = '0';
    }
    bool ok = 1;
    int sum = 0;
    for(int j = 0; j < 2 * n; ++j){
        if(t[j] == '(') sum++;
        else if(t[j] == ')') sum--;
        if(sum<0) ok = 0;
    }
    if(sum!=0) ok = 0;
    if(!ok){
        cout << -1;
    }else{
        for(int i = 0; i < n; ++i){
            if(s[a[i].first - 1] == '(') cout << 0 << ' ';
            else cout << 1 << ' ';
        }
    }
    return;
    for(int mask = 0; mask < (1<<n); ++mask){
        string t = s;
        for(int j = 0; j < n; ++j){
            if((1<<j)&mask) 
                t[a[j].first - 1] = '0';
            else
                t[a[j].second - 1] = '0';
        }
        bool ok = 1;
        int sum = 0;
        for(int j = 0; j < 2 * n; ++j){
            if(t[j] == '(') sum++;
            else if(t[j] == ')') sum--;
            if(sum<0) ok = 0;
        }
        if(sum!=0) ok = 0;
        if(ok){
            for(int j = 0; j < n; ++j){
                cout << (((1<<j)&mask)>0) << ' ';
            }
            o = 0;
            break;
        }
    }
    if(o)
        cout << -1;
}





int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    int T = 1, aa;
    cin >> T;aa=T;
    while(T--){
        // cout << "Case #" << aa-T << ": ";
        solve();
        cout << '\n';
    }
    return 0;
 
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:79:16: warning: variable 'aa' set but not used [-Wunused-but-set-variable]
   79 |     int T = 1, aa;
      |                ^~
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 340 KB Output is correct
2 Correct 15 ms 1492 KB Output is correct
3 Correct 13 ms 1560 KB Output is correct
4 Correct 15 ms 1928 KB Output is correct
5 Correct 13 ms 1860 KB Output is correct
6 Correct 10 ms 1596 KB Output is correct
7 Correct 11 ms 1868 KB Output is correct
8 Correct 12 ms 2252 KB Output is correct
9 Correct 15 ms 2472 KB Output is correct
10 Correct 16 ms 2724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -