답안 #541643

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541643 2022-03-24T00:12:01 Z skittles1412 Alternating Current (BOI18_alternating) C++17
19 / 100
40 ms 2768 KB
#include "bits/extc++.h"

using namespace std;

template <typename T>
void dbgh(const T& t) {
	cerr << t << endl;
}

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
	cerr << t << " | ";
	dbgh(u...);
}

#ifdef DEBUG
#define dbg(...)                                           \
	cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \
		 << ": ";                                          \
	dbgh(__VA_ARGS__)
#else
#define cerr   \
	if (false) \
	cerr
#define dbg(...)
#endif

#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())

void solve() {
	int n, m;
	cin >> n >> m;
	array<int, 3> arr[m];
	for (int i = 0; i < m; i++) {
		cin >> arr[i][0] >> arr[i][1];
		arr[i][2] = i;
	}
	sort(arr, arr + m);
	int c1 = 1, c2 = 1;
	bool ans[m];
	for (auto& [l, r, i] : arr) {
		dbg(c1, c2);
		if (l <= c1 && l <= c2) {
			if (c1 > c2) {
				c2 = max(c2, r + 1);
				ans[i] = true;
			} else {
				c1 = max(c1, r + 1);
				ans[i] = false;
			}
		} else if (l <= c1) {
			c1 = max(c1, r + 1);
			ans[i] = false;
		} else if (l <= c2) {
			c2 = max(c2, r + 1);
			ans[i] = true;
		}
	}
	dbg(c1, c2);
	if (c1 > n && c2 > n) {
		for (auto& a : ans) {
			cout << a;
		}
		cout << endl;
	} else {
		cout << "impossible" << endl;
	}
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cin.exceptions(ios::failbit);
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 272 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 272 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 272 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1616 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 10 ms 892 KB Output is correct
4 Correct 12 ms 980 KB Output is correct
5 Correct 40 ms 2652 KB Output is correct
6 Correct 26 ms 2624 KB Output is correct
7 Correct 25 ms 2508 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 32 ms 2760 KB Output is correct
11 Correct 26 ms 2164 KB Output is correct
12 Correct 27 ms 2520 KB Output is correct
13 Correct 0 ms 216 KB Output is correct
14 Correct 0 ms 216 KB Output is correct
15 Correct 38 ms 2760 KB Output is correct
16 Correct 10 ms 1472 KB Output is correct
17 Correct 35 ms 2768 KB Output is correct
18 Correct 39 ms 2508 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 31 ms 2744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 272 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -