Submission #541640

# Submission time Handle Problem Language Result Execution time Memory
541640 2022-03-24T00:01:51 Z skittles1412 Alternating Current (BOI18_alternating) C++17
0 / 100
24 ms 2492 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) {
		if (l <= c1 && l <= c2) {
			if (c1 > c2) {
				c2 = r + 1;
				ans[i] = true;
			} else {
				c1 = r + 1;
				ans[i] = false;
			}
		} else if (l <= c1) {
			c1 = r + 1;
			ans[i] = false;
		} else if (l <= c2) {
			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();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 292 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 292 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 292 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2492 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 10 ms 1532 KB Output is correct
4 Incorrect 10 ms 1480 KB 'impossible' claimed, but there is a solution
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 292 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -