Submission #498693

# Submission time Handle Problem Language Result Execution time Memory
498693 2021-12-26T07:35:07 Z LittleCube Alternating Current (BOI18_alternating) C++14
0 / 100
16 ms 2144 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;

ll N, M;
vector<pii> v;

signed main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> N >> M;
    for (int i = 1; i <= M; i++)
    {
        int a, b;
        cin >> a >> b;
        v.emplace_back(pii{a, b});
    }
    if (N <= 15)
    {
        for (int mask = 0; mask < (1 << M); mask++)
        {
            bool valid[2] = {1, 1};
            for (int i = 1; i <= N; i++)
            {
                bool exist[2] = {0, 0};
                for (int j = 0; j < M; j++)
                {
                    if ((v[j].F <= i && i <= v[j].S) || (v[j].F > v[j].S && !(v[j].S < i && i < v[j].F)))
                        exist[(mask >> j) & 1] = 1;
                }
                valid[0] &= exist[0];
                valid[1] &= exist[1];
            }
            if (valid[0] && valid[1])
            {
                for (int j = M - 1; j >= 0; j--)
                    cout << ((mask >> j) & 1);
                cout << '\n';
                return 0;
            }
        }
        cout << "impossible\n";
    }
    else
    {
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 1 ms 208 KB no wires in direction 0 between segments 11 and 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 1 ms 208 KB no wires in direction 0 between segments 11 and 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 1 ms 208 KB no wires in direction 0 between segments 11 and 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2144 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 1 ms 208 KB no wires in direction 0 between segments 11 and 11
4 Halted 0 ms 0 KB -