답안 #522399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522399 2022-02-04T20:10:26 Z LucaDantas Alternating Current (BOI18_alternating) C++17
0 / 100
36 ms 3100 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) < 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});
      |   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1860 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 10 ms 1224 KB Output is correct
4 Correct 14 ms 1220 KB Output is correct
5 Correct 34 ms 2968 KB Output is correct
6 Correct 31 ms 2968 KB Output is correct
7 Correct 33 ms 2964 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 36 ms 3100 KB Output is correct
11 Correct 27 ms 2712 KB Output is correct
12 Correct 31 ms 3016 KB Output is correct
13 Incorrect 0 ms 292 KB no wires in direction 0 between segments 100000 and 100000
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -