답안 #863395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
863395 2023-10-20T06:56:36 Z Trisanu_Das Alternating Current (BOI18_alternating) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
const int maxn5 = 2e5 + 10;
 
int a[200005], b[200005];
bool av[2][200005];
int n, m;
bool ty[200005];
vector <int> seg[200005], ex;
 
void kill(){
	cout << "impossible\n";
	exit(0);
}
 
void solve(){
	for(int i = 0; i < m; i++) seg[a[i]].push_back(i);
	int id1 = -1, id2 = -1;
	for(int i = 0; i < n; i++){
		if(b[id1] < i) id1 = -1;
		if(b[id2] < i) id2 = -1;
		while(!ex.empty() && b[ex.back()] < i) ex.pop_back();
		for(auto u : seg[i]) ex.pb(u);
		if(id1 == -1){
			if(ex.empty()) kill();
			id1 = ex.back();
			ty[id1] = true;
			ex.pop_back();
		}
		while(!ex.empty() && b[ex.back()] < i) ex.pop_back();
		if(id2 == -1){
			if(ex.empty()) kill();
			id2 = ex.back();
			ex.pop_back();
		}
	}
	for(int i = 0; i < m; i++) cout << ty[i];
	cout << '\n';
	exit(0);
}
 
 
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	if(max(n, m) > 20) 
		solve();
 
	for(int mask = 1; mask < (1 << m) - 1; mask++){
		memset(av, false, sizeof av);
		for(int i = 0; i < m; i++){
			int x = a[i];
			while(true){
				av[(mask >> i)&1][x] = true;
				if(x == b[i]) break;
				x++;
				if(x == n) x = 0;
			}
		}
		bool re = true;
		for(int i = 0; i < n; i++) if(!av[0][i] || !av[1][i]) re = false;
		if(re){
			for(int i = 0; i < m; i++) cout << ((mask >> i)&1);
			return cout << '\n', 0;
		}
	}
	cout << "impossible\n";
 
}

Compilation message

alternating.cpp: In function 'void solve()':
alternating.cpp:25:27: error: 'class std::vector<int>' has no member named 'pb'
   25 |   for(auto u : seg[i]) ex.pb(u);
      |                           ^~