Submission #522400

# Submission time Handle Problem Language Result Execution time Memory
522400 2022-02-04T20:13:55 Z LucaDantas Alternating Current (BOI18_alternating) C++17
19 / 100
43 ms 3088 KB
// subtask não circular
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;

vector<pair<pii, int>> wires;

int main() {
	int n, m; scanf("%d %d", &n, &m);
	for(int i = 0, a, b; i < m; i++)
		scanf("%d %d", &a, &b), wires.push_back({{a, b}, i});
	sort(wires.begin(), wires.end());

	vector<int> ans(m);
	int a = 1, b = 1, cor = 0;
	for(int i = 0; i < m; i++) {
		if(a > b) swap(a, b), cor ^= 1;
		if(wires[i].first.first > a) return puts("impossible"), 0;
		a = max(a, wires[i].first.second + 1);
		ans[wires[i].second] = cor;
	}

	if(min(a, b) < n+1) return puts("impossible"), 0;

	for(int i = 0; i < m; i++)
		printf("%d", ans[i]);
	puts("");
}

Compilation message

alternating.cpp: In function 'int main()':
alternating.cpp:10:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  int n, m; scanf("%d %d", &n, &m);
      |            ~~~~~^~~~~~~~~~~~~~~~~
alternating.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d %d", &a, &b), wires.push_back({{a, b}, i});
      |   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1904 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 10 ms 1096 KB Output is correct
4 Correct 15 ms 1124 KB Output is correct
5 Correct 34 ms 1872 KB Output is correct
6 Correct 27 ms 1860 KB Output is correct
7 Correct 36 ms 1848 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 33 ms 1964 KB Output is correct
11 Correct 26 ms 1896 KB Output is correct
12 Correct 34 ms 1860 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 43 ms 3064 KB Output is correct
16 Correct 14 ms 1696 KB Output is correct
17 Correct 33 ms 3088 KB Output is correct
18 Correct 38 ms 2852 KB Output is correct
19 Correct 2 ms 588 KB Output is correct
20 Correct 36 ms 2960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -