답안 #233266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233266 2020-05-20T07:53:28 Z VEGAnn Tenis (COI19_tenis) C++14
30 / 100
500 ms 2936 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const int md = int(1e9) + 7;
int loc[3][N], n, q, a[3][N], mn[3], men[3], lst[3];
bool mrk[N];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> q;

    for (int tp = 0; tp < 3; tp++)
    for (int i = 0; i < n; i++){
        int x; cin >> x;
        x--;

        loc[tp][x] = i;
        a[tp][i] = x;
    }

    for (; q; q--){
        int tp; cin >> tp;

        if (tp == 1){
            int x; cin >> x; x--;

            fill(mrk, mrk + n, 0);

            mn[0] = mn[1] = mn[2] = n;

            for (int tp = 0; tp < 3; tp++)
                lst[tp] = loc[tp][x];

            for (int tp = 0; tp < 3; tp++)
            for (int i = loc[tp][x]; i < n; i++) {
                mrk[a[tp][i]] = 1;

                for (int j = 0; j < 3; j++)
                    mn[j] = min(mn[j], loc[j][a[tp][i]]);
            }

            bool was = 1;

            while (was) {
                was = 0;

                men[0] = mn[0];
                men[1] = mn[1];
                men[2] = mn[2];

                for (int tp = 0; tp < 3; tp++)
                for (int i = mn[tp]; i < lst[tp]; i++)
                    if (!mrk[a[tp][i]]){
                        for (int j = 0; j < 3; j++)
                            men[j] = min(men[j], loc[j][a[tp][i]]);
                        was = 1;
                        mrk[a[tp][i]] = 1;
                    }

                lst[0] = mn[0];
                lst[1] = mn[1];
                lst[2] = mn[2];

                mn[0] = men[0];
                mn[1] = men[1];
                mn[2] = men[2];
            }

            bool ok = 1;

            for (int i = 0; i < n && ok; i++)
                if (!mrk[i])
                    ok = 0;

            cout << (ok ? "DA\n" : "NE\n");
        } else {
            int x, y; cin >> tp >> x >> y;
            tp--; x--; y--;

            swap(loc[tp][x], loc[tp][y]);
            swap(a[tp][loc[tp][x]], a[tp][loc[tp][y]]);
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 46 ms 2808 KB Output is correct
14 Correct 43 ms 2808 KB Output is correct
15 Correct 45 ms 2816 KB Output is correct
16 Correct 44 ms 2816 KB Output is correct
17 Correct 55 ms 2808 KB Output is correct
18 Correct 47 ms 2808 KB Output is correct
19 Correct 47 ms 2816 KB Output is correct
20 Correct 38 ms 2680 KB Output is correct
21 Correct 50 ms 2816 KB Output is correct
22 Correct 47 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1091 ms 2936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 46 ms 2808 KB Output is correct
14 Correct 43 ms 2808 KB Output is correct
15 Correct 45 ms 2816 KB Output is correct
16 Correct 44 ms 2816 KB Output is correct
17 Correct 55 ms 2808 KB Output is correct
18 Correct 47 ms 2808 KB Output is correct
19 Correct 47 ms 2816 KB Output is correct
20 Correct 38 ms 2680 KB Output is correct
21 Correct 50 ms 2816 KB Output is correct
22 Correct 47 ms 2808 KB Output is correct
23 Execution timed out 1091 ms 2936 KB Time limit exceeded
24 Halted 0 ms 0 KB -