답안 #441418

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
441418 2021-07-05T07:15:20 Z abc864197532 Alternating Current (BOI18_alternating) C++17
0 / 100
27 ms 1916 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define test(args...) abc("[" + string(#args) + "]", args)
void abc() {cerr << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
    cerr << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
    while (l != r) cout << *l << " \n"[++l == r];
}
const int mod = 1e9 + 7, N = 200000;

int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector <pii> a(m);
    int mx1 = 1, mx2 = 1;
    for (int i = 0; i < m; ++i) cin >> a[i].X >> a[i].Y;
    vector <int> ans(m, 0);
    vector <int> p(m);
    iota(all(p), 0);
    sort(all(p), [&](int i, int j) {
        return a[i].X < a[j].X;
    });
    for (int i : p) {
        if (mx1 + 1 < a[i].X || mx2 + 1 < a[i].X) break;
        if (mx1 < mx2) {
            mx1 = max(mx1, a[i].Y);
        } else {
            mx2 = max(mx2, a[i].Y);
            ans[i] = 1;
        }
    }
    if (mx1 < n || mx2 < n) return cout << "impossible\n", 0;
    for (int i : ans) cout << i;
    cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1916 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 15 ms 1668 KB Output is correct
4 Incorrect 14 ms 1740 KB no wires in direction 0 between segments 1 and 1
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -