답안 #171300

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171300 2019-12-28T08:53:49 Z Atalasion Alternating Current (BOI18_alternating) C++14
13 / 100
3000 ms 3740 KB
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, m, cnt[N], cnt2[N];
vector<pii> Q;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; i++){
		int l, r;
		cin >> l >> r;
		Q.pb({l, r});
	}
	for (int mask = 0; mask < (1 << m); mask ++){
		memset(cnt, 0, sizeof cnt);
		memset(cnt2, 0, sizeof cnt2);
		for (int i = 0; i < m; i++){
			if (mask & (1 << i)){
				if (Q[i].F > Q[i].S){
					for (int j = Q[i].F; j <= n; j++){
						cnt[j] ++;	
					}
					for (int j = 1; j <= Q[i].S; j++) cnt[j]++;
				}else{
					for (int j = Q[i].F; j <= Q[i].S; j++) cnt[j]++;
				}
			}else{
				if (Q[i].F > Q[i].S){
					for (int j = Q[i].F; j <= n; j++){
						cnt2[j] ++;	
					}
					for (int j = 1; j <= Q[i].S; j++) cnt2[j]++;
				}else{
					for (int j = Q[i].F; j <= Q[i].S; j++) cnt2[j]++;
				}	
			}
		}
		bool f = 1;
		for (int i = 1; i <= n; i++){
			if (cnt[i] == 0 || cnt2[i] == 0) f = 0;
		}
		if (f){
			for (int i = 0; i < m; i++) cout << ((mask & (1 << i)) != 0);
			return 0;
		}	
	}
	cout << "impossible";











	return 0;
}

Compilation message

alternating.cpp:8:0: warning: ignoring #pragma GCC optimise [-Wunknown-pragmas]
 #pragma GCC optimise ("ofast")
 
alternating.cpp:9:0: warning: ignoring #pragma GCC optimise [-Wunknown-pragmas]
 #pragma GCC optimise("unroll-loops")
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1912 KB Output is correct
2 Correct 3 ms 1912 KB Output is correct
3 Correct 4 ms 1912 KB Output is correct
4 Correct 15 ms 1912 KB Output is correct
5 Correct 6 ms 1912 KB Output is correct
6 Correct 5 ms 1912 KB Output is correct
7 Correct 3 ms 1912 KB Output is correct
8 Correct 13 ms 1912 KB Output is correct
9 Correct 4 ms 1912 KB Output is correct
10 Correct 44 ms 1912 KB Output is correct
11 Correct 14 ms 1912 KB Output is correct
12 Correct 22 ms 1884 KB Output is correct
13 Correct 174 ms 2040 KB Output is correct
14 Correct 6 ms 1912 KB Output is correct
15 Correct 4 ms 1912 KB Output is correct
16 Correct 348 ms 1984 KB Output is correct
17 Correct 42 ms 1912 KB Output is correct
18 Correct 40 ms 1912 KB Output is correct
19 Correct 4 ms 1912 KB Output is correct
20 Correct 4 ms 1912 KB Output is correct
21 Correct 3 ms 1912 KB Output is correct
22 Correct 290 ms 1944 KB Output is correct
23 Correct 2 ms 1916 KB Output is correct
24 Correct 24 ms 1988 KB Output is correct
25 Correct 10 ms 2168 KB Output is correct
26 Correct 5 ms 1912 KB Output is correct
27 Correct 333 ms 2012 KB Output is correct
28 Correct 6 ms 1912 KB Output is correct
29 Correct 15 ms 1912 KB Output is correct
30 Correct 8 ms 1912 KB Output is correct
31 Correct 4 ms 1912 KB Output is correct
32 Correct 6 ms 1912 KB Output is correct
33 Correct 4 ms 1912 KB Output is correct
34 Correct 3 ms 1912 KB Output is correct
35 Correct 2697 ms 1984 KB Output is correct
36 Correct 110 ms 1912 KB Output is correct
37 Correct 18 ms 1912 KB Output is correct
38 Correct 2768 ms 1912 KB Output is correct
39 Correct 14 ms 1912 KB Output is correct
40 Correct 9 ms 1912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1912 KB Output is correct
2 Correct 3 ms 1912 KB Output is correct
3 Correct 4 ms 1912 KB Output is correct
4 Correct 15 ms 1912 KB Output is correct
5 Correct 6 ms 1912 KB Output is correct
6 Correct 5 ms 1912 KB Output is correct
7 Correct 3 ms 1912 KB Output is correct
8 Correct 13 ms 1912 KB Output is correct
9 Correct 4 ms 1912 KB Output is correct
10 Correct 44 ms 1912 KB Output is correct
11 Correct 14 ms 1912 KB Output is correct
12 Correct 22 ms 1884 KB Output is correct
13 Correct 174 ms 2040 KB Output is correct
14 Correct 6 ms 1912 KB Output is correct
15 Correct 4 ms 1912 KB Output is correct
16 Correct 348 ms 1984 KB Output is correct
17 Correct 42 ms 1912 KB Output is correct
18 Correct 40 ms 1912 KB Output is correct
19 Correct 4 ms 1912 KB Output is correct
20 Correct 4 ms 1912 KB Output is correct
21 Correct 3 ms 1912 KB Output is correct
22 Correct 290 ms 1944 KB Output is correct
23 Correct 2 ms 1916 KB Output is correct
24 Correct 24 ms 1988 KB Output is correct
25 Correct 10 ms 2168 KB Output is correct
26 Correct 5 ms 1912 KB Output is correct
27 Correct 333 ms 2012 KB Output is correct
28 Correct 6 ms 1912 KB Output is correct
29 Correct 15 ms 1912 KB Output is correct
30 Correct 8 ms 1912 KB Output is correct
31 Correct 4 ms 1912 KB Output is correct
32 Correct 6 ms 1912 KB Output is correct
33 Correct 4 ms 1912 KB Output is correct
34 Correct 3 ms 1912 KB Output is correct
35 Correct 2697 ms 1984 KB Output is correct
36 Correct 110 ms 1912 KB Output is correct
37 Correct 18 ms 1912 KB Output is correct
38 Correct 2768 ms 1912 KB Output is correct
39 Correct 14 ms 1912 KB Output is correct
40 Correct 9 ms 1912 KB Output is correct
41 Correct 3 ms 1912 KB Output is correct
42 Correct 82 ms 1952 KB Output is correct
43 Incorrect 4 ms 1912 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1912 KB Output is correct
2 Correct 3 ms 1912 KB Output is correct
3 Correct 4 ms 1912 KB Output is correct
4 Correct 15 ms 1912 KB Output is correct
5 Correct 6 ms 1912 KB Output is correct
6 Correct 5 ms 1912 KB Output is correct
7 Correct 3 ms 1912 KB Output is correct
8 Correct 13 ms 1912 KB Output is correct
9 Correct 4 ms 1912 KB Output is correct
10 Correct 44 ms 1912 KB Output is correct
11 Correct 14 ms 1912 KB Output is correct
12 Correct 22 ms 1884 KB Output is correct
13 Correct 174 ms 2040 KB Output is correct
14 Correct 6 ms 1912 KB Output is correct
15 Correct 4 ms 1912 KB Output is correct
16 Correct 348 ms 1984 KB Output is correct
17 Correct 42 ms 1912 KB Output is correct
18 Correct 40 ms 1912 KB Output is correct
19 Correct 4 ms 1912 KB Output is correct
20 Correct 4 ms 1912 KB Output is correct
21 Correct 3 ms 1912 KB Output is correct
22 Correct 290 ms 1944 KB Output is correct
23 Correct 2 ms 1916 KB Output is correct
24 Correct 24 ms 1988 KB Output is correct
25 Correct 10 ms 2168 KB Output is correct
26 Correct 5 ms 1912 KB Output is correct
27 Correct 333 ms 2012 KB Output is correct
28 Correct 6 ms 1912 KB Output is correct
29 Correct 15 ms 1912 KB Output is correct
30 Correct 8 ms 1912 KB Output is correct
31 Correct 4 ms 1912 KB Output is correct
32 Correct 6 ms 1912 KB Output is correct
33 Correct 4 ms 1912 KB Output is correct
34 Correct 3 ms 1912 KB Output is correct
35 Correct 2697 ms 1984 KB Output is correct
36 Correct 110 ms 1912 KB Output is correct
37 Correct 18 ms 1912 KB Output is correct
38 Correct 2768 ms 1912 KB Output is correct
39 Correct 14 ms 1912 KB Output is correct
40 Correct 9 ms 1912 KB Output is correct
41 Correct 3 ms 1912 KB Output is correct
42 Correct 82 ms 1952 KB Output is correct
43 Incorrect 4 ms 1912 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3029 ms 3740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1912 KB Output is correct
2 Correct 3 ms 1912 KB Output is correct
3 Correct 4 ms 1912 KB Output is correct
4 Correct 15 ms 1912 KB Output is correct
5 Correct 6 ms 1912 KB Output is correct
6 Correct 5 ms 1912 KB Output is correct
7 Correct 3 ms 1912 KB Output is correct
8 Correct 13 ms 1912 KB Output is correct
9 Correct 4 ms 1912 KB Output is correct
10 Correct 44 ms 1912 KB Output is correct
11 Correct 14 ms 1912 KB Output is correct
12 Correct 22 ms 1884 KB Output is correct
13 Correct 174 ms 2040 KB Output is correct
14 Correct 6 ms 1912 KB Output is correct
15 Correct 4 ms 1912 KB Output is correct
16 Correct 348 ms 1984 KB Output is correct
17 Correct 42 ms 1912 KB Output is correct
18 Correct 40 ms 1912 KB Output is correct
19 Correct 4 ms 1912 KB Output is correct
20 Correct 4 ms 1912 KB Output is correct
21 Correct 3 ms 1912 KB Output is correct
22 Correct 290 ms 1944 KB Output is correct
23 Correct 2 ms 1916 KB Output is correct
24 Correct 24 ms 1988 KB Output is correct
25 Correct 10 ms 2168 KB Output is correct
26 Correct 5 ms 1912 KB Output is correct
27 Correct 333 ms 2012 KB Output is correct
28 Correct 6 ms 1912 KB Output is correct
29 Correct 15 ms 1912 KB Output is correct
30 Correct 8 ms 1912 KB Output is correct
31 Correct 4 ms 1912 KB Output is correct
32 Correct 6 ms 1912 KB Output is correct
33 Correct 4 ms 1912 KB Output is correct
34 Correct 3 ms 1912 KB Output is correct
35 Correct 2697 ms 1984 KB Output is correct
36 Correct 110 ms 1912 KB Output is correct
37 Correct 18 ms 1912 KB Output is correct
38 Correct 2768 ms 1912 KB Output is correct
39 Correct 14 ms 1912 KB Output is correct
40 Correct 9 ms 1912 KB Output is correct
41 Correct 3 ms 1912 KB Output is correct
42 Correct 82 ms 1952 KB Output is correct
43 Incorrect 4 ms 1912 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -