Submission #441381

# Submission time Handle Problem Language Result Execution time Memory
441381 2021-07-05T06:22:40 Z sam571128 Paths (BOI18_paths) C++17
0 / 100
3000 ms 9052 KB
#include <bits/stdc++.h>

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
    //fastio
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> v;
    for(int i = 0;i < m;i++){
        int l,r;
        cin >> l >> r;
        l--, r--;
        v.push_back({l,r});
    }

    for(int i = 0;i < (1<<m);i++){
        int cnt[n] = {};
        for(int j = 0;j < m;j++){
            if(i&(1<<j)){
                int l = v[j].first, r = v[j].second;
                while(true){
                    cnt[l] |= 2;
                    if(l==r) break;
                    l = (l+1)%n;
                }
            }else{
                int l = v[j].first, r = v[j].second;
                while(true){
                    cnt[l] |= 1;
                    if(l==r) break;
                    l = (l+1)%n;
                }
            }
        }
        bool check = true;
        for(int j = 0;j < n;j++){
            if(cnt[j]!=3){
                check = false;
            }
        }

        if(check){
            for(int j = 0;j < m;j++){
                if(i&(1<<j)) cout << 1;
                else cout << 0;
            }
            return 0;
        }
    }
    cout << "impossible\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3067 ms 9052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -