Submission #1113574

# Submission time Handle Problem Language Result Execution time Memory
1113574 2024-11-16T18:37:19 Z PagodePaiva Alternating Current (BOI18_alternating) C++17
0 / 100
200 ms 4548 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});
    }
    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;
                }
            }
        }
        int aux = false;
        for(int i = 1;i <= n;i++){
            if(valores[i][0] != 1 or valores[i][1] != 1) 
                aux = true;
        }
        if(aux) 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 Correct 1 ms 508 KB Output is correct
4 Incorrect 1 ms 380 KB no wires in direction 1 between segments 1 and 4
5 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 Correct 1 ms 508 KB Output is correct
4 Incorrect 1 ms 380 KB no wires in direction 1 between segments 1 and 4
5 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 Correct 1 ms 508 KB Output is correct
4 Incorrect 1 ms 380 KB no wires in direction 1 between segments 1 and 4
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 200 ms 4548 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 Correct 1 ms 508 KB Output is correct
4 Incorrect 1 ms 380 KB no wires in direction 1 between segments 1 and 4
5 Halted 0 ms 0 KB -