Submission #967586

# Submission time Handle Problem Language Result Execution time Memory
967586 2024-04-22T13:13:58 Z Isam Superpozicija (COCI22_superpozicija) C++17
0 / 110
1000 ms 960 KB
#include<bits/stdc++.h>
using namespace std;

constexpr int sz = 200002;

int n, a[sz], b[sz];

string z;


signed main(){
	ios_base::sync_with_stdio(0);
	int T;
	cin >> T;
	
	function<void()> test_case = [](){
		cin >> n >> z;
		for(register int i = 1; i <= n; ++i){
			cin >> a[i] >> b[i];
			a[i]--, b[i]--;
		}
		assert(n<=10);
		
		
		for(register int mask = 0; mask <= (1 << (n << 1)); ++mask){
			
			bool flag = true;
			
			for(register int i = 1; i <= n; ++i){
				
				flag &= (bool(mask & (1 << (a[i])) + bool(mask & (1<<(b[i])))) == 1);
				
			}
			
			if(!flag) continue;
			
			int tot(0);
			
			for(register int i = 1; i <= n && flag; ++i){
				
				if(mask & (1<<(a[i]))){
					tot += (z[a[i]]=='('?1:-1);
				}
				
				flag &= (tot >= 0);
				
			}
			
			flag &= tot==0;
			
			if(flag){
				
				
				for(register int i = 1; i <= n; ++i){
					
					cout << (bool)(mask & (1<<b[i])) << " \n"[i==n];					
				}
				
				
				return;
			}
			
			
		}
		
		cout << -1 << '\n';
		
	};
	
	while(T--) test_case();
	return 0;
}

Compilation message

Main.cpp: In lambda function:
Main.cpp:18:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 |   for(register int i = 1; i <= n; ++i){
      |                    ^
Main.cpp:25:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   25 |   for(register int mask = 0; mask <= (1 << (n << 1)); ++mask){
      |                    ^~~~
Main.cpp:29:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   29 |    for(register int i = 1; i <= n; ++i){
      |                     ^
Main.cpp:31:40: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   31 |     flag &= (bool(mask & (1 << (a[i])) + bool(mask & (1<<(b[i])))) == 1);
      |                          ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:39:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |    for(register int i = 1; i <= n && flag; ++i){
      |                     ^
Main.cpp:54:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   54 |     for(register int i = 1; i <= n; ++i){
      |                      ^
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 960 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 960 KB Time limit exceeded
2 Halted 0 ms 0 KB -