답안 #441477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
441477 2021-07-05T08:48:56 Z Haruto810198 Alternating Current (BOI18_alternating) C++17
13 / 100
3000 ms 4276 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d))
#define szof(x) ((int)(x).size())

#define vi vector<int>
#define pii pair<int,int>

#define F first
#define S second

#define pb push_back
#define eb emplace_back
#define mkp make_pair

const int INF = 2147483647;
const int LNF = INF*INF;
const int MOD = 1000000007;
const int mod = 998244353;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

const int MAX = 100010;

int n, m;
int L[MAX], R[MAX];
int cnt1[MAX], cnt2[MAX];
int res[MAX];
bool solved;

void check(int mask){

    vi arr;
    FOR(i, 0, m-1, 1){
        if((mask & (1<<i)) != 0){
            arr.pb(1);
        }
        else{
            arr.pb(0);
        }
    }

    FOR(i, 1, n, 1){
        cnt1[i] = 0;
        cnt2[i] = 0;
    }

    FOR(i, 0, m-1, 1){

        if(arr[i]==1){

            if(L[i] <= R[i]){
                FOR(j, L[i], R[i], 1){
                    cnt1[j]++;
                }
            }
            else{
                FOR(j, L[i], n, 1){
                    cnt1[j]++;
                }
                FOR(j, 1, R[i], 1){
                    cnt1[j]++;
                }
            }

        }
        else{

            if(L[i] <= R[i]){
                FOR(j, L[i], R[i], 1){
                    cnt2[j]++;
                }
            }
            else{
                FOR(j, L[i], n, 1){
                    cnt2[j]++;
                }
                FOR(j, 1, R[i], 1){
                    cnt2[j]++;
                }
            }

        }

    }

    bool flag = 1;
    FOR(i, 1, n, 1){
        if(cnt1[i]==0 or cnt2[i]==0){
            flag = 0;
        }
    }

    if(flag){
        solved = 1;
        FOR(i, 0, m-1, 1){
            res[i] = arr[i];
        }
    }

}

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    FOR(i, 0, m-1, 1){
        cin>>L[i]>>R[i];
    }

    solved = 0;
    FOR(mask, 0, (1<<m)-1, 1){
        check(mask);
    }

    if(solved){
        FOR(i, 0, m-1, 1){
            cout<<res[i];
        }
        cout<<'\n';
    }
    else{
        cout<<"impossible"<<'\n';
    }

    return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 12 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 13 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 12 ms 340 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 14 ms 340 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 13 ms 332 KB Output is correct
36 Correct 13 ms 216 KB Output is correct
37 Correct 13 ms 332 KB Output is correct
38 Correct 14 ms 336 KB Output is correct
39 Correct 12 ms 332 KB Output is correct
40 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 12 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 13 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 12 ms 340 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 14 ms 340 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 13 ms 332 KB Output is correct
36 Correct 13 ms 216 KB Output is correct
37 Correct 13 ms 332 KB Output is correct
38 Correct 14 ms 336 KB Output is correct
39 Correct 12 ms 332 KB Output is correct
40 Correct 2 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 2 ms 332 KB Output is correct
43 Incorrect 0 ms 332 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 12 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 13 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 12 ms 340 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 14 ms 340 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 13 ms 332 KB Output is correct
36 Correct 13 ms 216 KB Output is correct
37 Correct 13 ms 332 KB Output is correct
38 Correct 14 ms 336 KB Output is correct
39 Correct 12 ms 332 KB Output is correct
40 Correct 2 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 2 ms 332 KB Output is correct
43 Incorrect 0 ms 332 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3080 ms 4276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 12 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 13 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 12 ms 340 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 14 ms 340 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 13 ms 332 KB Output is correct
36 Correct 13 ms 216 KB Output is correct
37 Correct 13 ms 332 KB Output is correct
38 Correct 14 ms 336 KB Output is correct
39 Correct 12 ms 332 KB Output is correct
40 Correct 2 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 2 ms 332 KB Output is correct
43 Incorrect 0 ms 332 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -