Submission #1113572

# Submission time Handle Problem Language Result Execution time Memory
1113572 2024-11-16T18:35:16 Z PagodePaiva Alternating Current (BOI18_alternating) C++17
0 / 100
192 ms 4540 KB
#include<bits/stdc++.h>

using namespace std;

int res[20];

int main(){
    int n, m;
    cin >> n >> m;
    vector <array <int, 3>> v;
    for(int i = 0;i < m;i++){
        int a, b;
        cin >> a >> b;
        v.push_back({a, b, i-1});
    }
    for(int mask = 0;mask < (1<<m);mask++){
        int valores[n+1][2];
        for(int i = 1;i <= n;i++){
            valores[i][0] = valores[i][1] = 1;
        }
        for(int i = 0;i < m;i++){
            int cor = 0;
            if((1<<i)&m) cor = 1;
            auto [a, b, _] = v[i];
            res[_] = cor;
            if(a <= b){
                for(int j = a;j <= b;j++){
                    valores[j][cor] = 1;
                }
            }
            else{
                for(int j = a;j <= n;j++){
                    valores[j][cor] = 1;
                }
                for(int j = 1;j <= b;j++){
                    valores[j][cor] = 1;
                }
            }
        }
        for(int i = 1;i <= n;i++){
            if(valores[i][0] != 1 or valores[i][1] != 1) continue;
        }
        for(int i = 0;i < m;i++){
            cout << res[i];
        }
        cout << '\n';
        return 0;
    }
    cout << "impossible\n";
    return  0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 2 ms 336 KB no wires in direction 1 between segments 1 and 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 2 ms 336 KB no wires in direction 1 between segments 1 and 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 2 ms 336 KB no wires in direction 1 between segments 1 and 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 192 ms 4540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 2 ms 336 KB no wires in direction 1 between segments 1 and 11
4 Halted 0 ms 0 KB -