답안 #967609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967609 2024-04-22T13:49:41 Z Isam Superpozicija (COCI22_superpozicija) C++17
0 / 110
111 ms 972 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); ++mask){
			
			bool flag = true;
			
			int tot(0);
			
			bitset<22> chosen;
			
			chosen.set();
			
			for(register int i = 1; i <= n; ++i){
				
				if(mask & (1<<(i-1))){
					chosen[b[i]] = true;
				}else{
					chosen[a[i]] = true;
				}
					
			}
			
			for(register int i = 0; i < (n << 1); ++i){
				
				if(chosen[i] == 1) tot += (z[i]=='('?1:-1);
				
				flag &= (tot>=0);
				
			}
			
			
			flag &= !tot;
			
			if(flag){
				
				
				for(register int i = 0; i < n; ++i){
					
					cout << (bool)(mask & (1 << i)) << " \n"[i==n-1];					
				}
				
				
				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); ++mask){
      |                    ^~~~
Main.cpp:35:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   35 |    for(register int i = 1; i <= n; ++i){
      |                     ^
Main.cpp:45:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   45 |    for(register int i = 0; i < (n << 1); ++i){
      |                     ^
Main.cpp:59:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   59 |     for(register int i = 0; i < n; ++i){
      |                      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 111 ms 972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 111 ms 972 KB Output isn't correct
2 Halted 0 ms 0 KB -