Submission #643538

#TimeUsernameProblemLanguageResultExecution timeMemory
643538mychecksedadSuperpozicija (COCI22_superpozicija)C++17
0 / 110
5 ms596 KiB
/* 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; for(int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second; 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].second - 1] = '0'; else t[a[j].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){ for(int j = 0; j < n; ++j) cout << ((1<<j)&mask>0) << ' '; exit(0); } } 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 (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:39:60: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   39 |             for(int j = 0; j < n; ++j) cout << ((1<<j)&mask>0) << ' ';
      |                                                        ~~~~^~
Main.cpp: In function 'int main()':
Main.cpp:52:16: warning: variable 'aa' set but not used [-Wunused-but-set-variable]
   52 |     int T = 1, aa;
      |                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...