Submission #522397

# Submission time Handle Problem Language Result Execution time Memory
522397 2022-02-04T19:40:01 Z LucaDantas Alternating Current (BOI18_alternating) C++17
0 / 100
26 ms 2744 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 = wires[i].first.second + 1;
		ans[wires[i].second] = cor;
	}

	if(min(a, b) < m+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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 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 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 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 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 292 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2744 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 11 ms 1828 KB Output is correct
4 Incorrect 14 ms 1728 KB 'impossible' claimed, but there is a solution
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 292 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -