답안 #423419

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
423419 2021-06-11T05:39:45 Z qwerasdfzxcl Crossing (JOI21_crossing) C++14
100 / 100
2975 ms 78256 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
int mp[202];
string y;
string a[9];
struct Seg{
    pair<int, bool> tree[800800];
    int lazy[800800];
    pair<int, bool> combine(pair<int, bool> z, pair<int, bool> w){
        pair<int, bool> ret = {0, 0};
        if (z.first==w.first) ret.first = z.first;
        ret.second = z.second&w.second;
        return ret;
    }
    void init(int i, int l, int r, int idx){
        if (l!=r){
            int m = (l+r)>>1;
            init(i<<1, l, m, idx); init(i<<1|1, m+1, r, idx);
            tree[i] = combine(tree[i<<1], tree[i<<1|1]);
        }
        else{
            tree[i] = {mp[a[idx][l]], 0};
            if (a[idx][l]==y[l]) tree[i].second = 1;
        }
    }
    void propagate(int i, int l, int r){
        if (!lazy[i]) return;
        if (tree[i].first==lazy[i]) tree[i].second = 1;
        else tree[i].second = 0;
        if (l!=r){
            lazy[i<<1] = lazy[i], lazy[i<<1|1] = lazy[i];
        }
        lazy[i] = 0;
    }
    void update(int i, int l, int r, int s, int e, int val){
        propagate(i, l, r);
        if (r<s || e<l) return;
        if (s<=l && r<=e){
            lazy[i] = val; propagate(i, l, r);
            return;
        }
        int m = (l+r)>>1;
        update(i<<1, l, m, s, e, val);
        update(i<<1|1, m+1, r, s, e, val);
        tree[i] = combine(tree[i<<1], tree[i<<1|1]);
    }

}tree[9];

char inv[3];
string f(int a1, int a2, int a3){
    string ret;
    ret.resize(a[0].size());
    for (int i=0;i<(int)a[0].size();i++){
        int val = mp[a[0][i]]*a1+mp[a[1][i]]*a2+mp[a[2][i]]*a3;
        val %= 3;
        ret[i] = inv[val];
    }
    return ret;
}

bool chk(){
    bool ret = 0;
    for (int i=0;i<9;i++) ret |= tree[i].tree[1].second;
    return ret;
}

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    mp['J'] = 1, mp['O'] = 2, mp['I'] = 3;
    inv[0] = 'I', inv[1] = 'J', inv[2] = 'O';
    int n, q;
    cin >> n;
    cin >> a[0] >> a[1] >> a[2];
    a[3] = f(2, 2, 0);
    a[4] = f(0, 2, 2);
    a[5] = f(2, 0, 2);
    a[6] = f(1, 1, 2);
    a[7] = f(1, 2, 1);
    a[8] = f(2, 1, 1);
    cin >> q;
    cin >> y;
    for (int i=0;i<9;i++) tree[i].init(1, 0, n-1, i);
    if (chk()) cout << "Yes\n";
    else cout << "No\n";
    while(q--){
        int l, r;
        char tmp;
        cin >> l >> r >> tmp;
        for (int i=0;i<9;i++) tree[i].update(1, 1, n, l, r, mp[tmp]);
        if (chk()) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}

Compilation message

Main.cpp: In member function 'void Seg::init(int, int, int, int)':
Main.cpp:24:36: warning: array subscript has type 'char' [-Wchar-subscripts]
   24 |             tree[i] = {mp[a[idx][l]], 0};
      |                                    ^
Main.cpp: In function 'std::string f(int, int, int)':
Main.cpp:57:29: warning: array subscript has type 'char' [-Wchar-subscripts]
   57 |         int val = mp[a[0][i]]*a1+mp[a[1][i]]*a2+mp[a[2][i]]*a3;
      |                             ^
Main.cpp:57:44: warning: array subscript has type 'char' [-Wchar-subscripts]
   57 |         int val = mp[a[0][i]]*a1+mp[a[1][i]]*a2+mp[a[2][i]]*a3;
      |                                            ^
Main.cpp:57:59: warning: array subscript has type 'char' [-Wchar-subscripts]
   57 |         int val = mp[a[0][i]]*a1+mp[a[1][i]]*a2+mp[a[2][i]]*a3;
      |                                                           ^
Main.cpp: In function 'int main()':
Main.cpp:93:64: warning: array subscript has type 'char' [-Wchar-subscripts]
   93 |         for (int i=0;i<9;i++) tree[i].update(1, 1, n, l, r, mp[tmp]);
      |                                                                ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 350 ms 57268 KB Output is correct
2 Correct 342 ms 57352 KB Output is correct
3 Correct 380 ms 57368 KB Output is correct
4 Correct 277 ms 57284 KB Output is correct
5 Correct 267 ms 57356 KB Output is correct
6 Correct 291 ms 57444 KB Output is correct
7 Correct 278 ms 57488 KB Output is correct
8 Correct 332 ms 57396 KB Output is correct
9 Correct 293 ms 57384 KB Output is correct
10 Correct 289 ms 57284 KB Output is correct
11 Correct 304 ms 57320 KB Output is correct
12 Correct 296 ms 57300 KB Output is correct
13 Correct 307 ms 57360 KB Output is correct
14 Correct 310 ms 57324 KB Output is correct
15 Correct 294 ms 57364 KB Output is correct
16 Correct 293 ms 57376 KB Output is correct
17 Correct 299 ms 57284 KB Output is correct
18 Correct 320 ms 57384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 350 ms 57268 KB Output is correct
2 Correct 342 ms 57352 KB Output is correct
3 Correct 380 ms 57368 KB Output is correct
4 Correct 277 ms 57284 KB Output is correct
5 Correct 267 ms 57356 KB Output is correct
6 Correct 291 ms 57444 KB Output is correct
7 Correct 278 ms 57488 KB Output is correct
8 Correct 332 ms 57396 KB Output is correct
9 Correct 293 ms 57384 KB Output is correct
10 Correct 289 ms 57284 KB Output is correct
11 Correct 304 ms 57320 KB Output is correct
12 Correct 296 ms 57300 KB Output is correct
13 Correct 307 ms 57360 KB Output is correct
14 Correct 310 ms 57324 KB Output is correct
15 Correct 294 ms 57364 KB Output is correct
16 Correct 293 ms 57376 KB Output is correct
17 Correct 299 ms 57284 KB Output is correct
18 Correct 320 ms 57384 KB Output is correct
19 Correct 2375 ms 78144 KB Output is correct
20 Correct 1937 ms 63548 KB Output is correct
21 Correct 1567 ms 77712 KB Output is correct
22 Correct 1545 ms 77520 KB Output is correct
23 Correct 676 ms 58568 KB Output is correct
24 Correct 670 ms 58668 KB Output is correct
25 Correct 1702 ms 77892 KB Output is correct
26 Correct 1723 ms 78020 KB Output is correct
27 Correct 1893 ms 77916 KB Output is correct
28 Correct 2060 ms 78028 KB Output is correct
29 Correct 1858 ms 77772 KB Output is correct
30 Correct 719 ms 58704 KB Output is correct
31 Correct 1921 ms 77996 KB Output is correct
32 Correct 1941 ms 77800 KB Output is correct
33 Correct 672 ms 58564 KB Output is correct
34 Correct 2085 ms 77828 KB Output is correct
35 Correct 1415 ms 77404 KB Output is correct
36 Correct 728 ms 58648 KB Output is correct
37 Correct 698 ms 58720 KB Output is correct
38 Correct 1627 ms 63436 KB Output is correct
39 Correct 720 ms 59664 KB Output is correct
40 Correct 1526 ms 67972 KB Output is correct
41 Correct 2975 ms 78244 KB Output is correct
42 Correct 112 ms 59572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 350 ms 57268 KB Output is correct
2 Correct 342 ms 57352 KB Output is correct
3 Correct 380 ms 57368 KB Output is correct
4 Correct 277 ms 57284 KB Output is correct
5 Correct 267 ms 57356 KB Output is correct
6 Correct 291 ms 57444 KB Output is correct
7 Correct 278 ms 57488 KB Output is correct
8 Correct 332 ms 57396 KB Output is correct
9 Correct 293 ms 57384 KB Output is correct
10 Correct 289 ms 57284 KB Output is correct
11 Correct 304 ms 57320 KB Output is correct
12 Correct 296 ms 57300 KB Output is correct
13 Correct 307 ms 57360 KB Output is correct
14 Correct 310 ms 57324 KB Output is correct
15 Correct 294 ms 57364 KB Output is correct
16 Correct 293 ms 57376 KB Output is correct
17 Correct 299 ms 57284 KB Output is correct
18 Correct 320 ms 57384 KB Output is correct
19 Correct 353 ms 57432 KB Output is correct
20 Correct 372 ms 57448 KB Output is correct
21 Correct 324 ms 57388 KB Output is correct
22 Correct 261 ms 57336 KB Output is correct
23 Correct 299 ms 57448 KB Output is correct
24 Correct 296 ms 57316 KB Output is correct
25 Correct 316 ms 57364 KB Output is correct
26 Correct 280 ms 57252 KB Output is correct
27 Correct 298 ms 57380 KB Output is correct
28 Correct 278 ms 57308 KB Output is correct
29 Correct 303 ms 57284 KB Output is correct
30 Correct 264 ms 57404 KB Output is correct
31 Correct 302 ms 57328 KB Output is correct
32 Correct 300 ms 57304 KB Output is correct
33 Correct 313 ms 57332 KB Output is correct
34 Correct 271 ms 57316 KB Output is correct
35 Correct 304 ms 57352 KB Output is correct
36 Correct 307 ms 57384 KB Output is correct
37 Correct 306 ms 57312 KB Output is correct
38 Correct 309 ms 57332 KB Output is correct
39 Correct 308 ms 57540 KB Output is correct
40 Correct 308 ms 57344 KB Output is correct
41 Correct 305 ms 57448 KB Output is correct
42 Correct 314 ms 57332 KB Output is correct
43 Correct 289 ms 57316 KB Output is correct
44 Correct 314 ms 57344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 350 ms 57268 KB Output is correct
2 Correct 342 ms 57352 KB Output is correct
3 Correct 380 ms 57368 KB Output is correct
4 Correct 277 ms 57284 KB Output is correct
5 Correct 267 ms 57356 KB Output is correct
6 Correct 291 ms 57444 KB Output is correct
7 Correct 278 ms 57488 KB Output is correct
8 Correct 332 ms 57396 KB Output is correct
9 Correct 293 ms 57384 KB Output is correct
10 Correct 289 ms 57284 KB Output is correct
11 Correct 304 ms 57320 KB Output is correct
12 Correct 296 ms 57300 KB Output is correct
13 Correct 307 ms 57360 KB Output is correct
14 Correct 310 ms 57324 KB Output is correct
15 Correct 294 ms 57364 KB Output is correct
16 Correct 293 ms 57376 KB Output is correct
17 Correct 299 ms 57284 KB Output is correct
18 Correct 320 ms 57384 KB Output is correct
19 Correct 2375 ms 78144 KB Output is correct
20 Correct 1937 ms 63548 KB Output is correct
21 Correct 1567 ms 77712 KB Output is correct
22 Correct 1545 ms 77520 KB Output is correct
23 Correct 676 ms 58568 KB Output is correct
24 Correct 670 ms 58668 KB Output is correct
25 Correct 1702 ms 77892 KB Output is correct
26 Correct 1723 ms 78020 KB Output is correct
27 Correct 1893 ms 77916 KB Output is correct
28 Correct 2060 ms 78028 KB Output is correct
29 Correct 1858 ms 77772 KB Output is correct
30 Correct 719 ms 58704 KB Output is correct
31 Correct 1921 ms 77996 KB Output is correct
32 Correct 1941 ms 77800 KB Output is correct
33 Correct 672 ms 58564 KB Output is correct
34 Correct 2085 ms 77828 KB Output is correct
35 Correct 1415 ms 77404 KB Output is correct
36 Correct 728 ms 58648 KB Output is correct
37 Correct 698 ms 58720 KB Output is correct
38 Correct 1627 ms 63436 KB Output is correct
39 Correct 720 ms 59664 KB Output is correct
40 Correct 1526 ms 67972 KB Output is correct
41 Correct 2975 ms 78244 KB Output is correct
42 Correct 112 ms 59572 KB Output is correct
43 Correct 353 ms 57432 KB Output is correct
44 Correct 372 ms 57448 KB Output is correct
45 Correct 324 ms 57388 KB Output is correct
46 Correct 261 ms 57336 KB Output is correct
47 Correct 299 ms 57448 KB Output is correct
48 Correct 296 ms 57316 KB Output is correct
49 Correct 316 ms 57364 KB Output is correct
50 Correct 280 ms 57252 KB Output is correct
51 Correct 298 ms 57380 KB Output is correct
52 Correct 278 ms 57308 KB Output is correct
53 Correct 303 ms 57284 KB Output is correct
54 Correct 264 ms 57404 KB Output is correct
55 Correct 302 ms 57328 KB Output is correct
56 Correct 300 ms 57304 KB Output is correct
57 Correct 313 ms 57332 KB Output is correct
58 Correct 271 ms 57316 KB Output is correct
59 Correct 304 ms 57352 KB Output is correct
60 Correct 307 ms 57384 KB Output is correct
61 Correct 306 ms 57312 KB Output is correct
62 Correct 309 ms 57332 KB Output is correct
63 Correct 308 ms 57540 KB Output is correct
64 Correct 308 ms 57344 KB Output is correct
65 Correct 305 ms 57448 KB Output is correct
66 Correct 314 ms 57332 KB Output is correct
67 Correct 289 ms 57316 KB Output is correct
68 Correct 314 ms 57344 KB Output is correct
69 Correct 2159 ms 77712 KB Output is correct
70 Correct 1898 ms 63596 KB Output is correct
71 Correct 690 ms 58776 KB Output is correct
72 Correct 683 ms 58648 KB Output is correct
73 Correct 695 ms 58572 KB Output is correct
74 Correct 1465 ms 77732 KB Output is correct
75 Correct 662 ms 58564 KB Output is correct
76 Correct 1647 ms 78200 KB Output is correct
77 Correct 1563 ms 77732 KB Output is correct
78 Correct 678 ms 58560 KB Output is correct
79 Correct 707 ms 58692 KB Output is correct
80 Correct 1464 ms 77324 KB Output is correct
81 Correct 684 ms 58672 KB Output is correct
82 Correct 1659 ms 78052 KB Output is correct
83 Correct 1655 ms 77800 KB Output is correct
84 Correct 672 ms 58636 KB Output is correct
85 Correct 679 ms 58692 KB Output is correct
86 Correct 1837 ms 77456 KB Output is correct
87 Correct 1971 ms 78052 KB Output is correct
88 Correct 805 ms 58676 KB Output is correct
89 Correct 1790 ms 77768 KB Output is correct
90 Correct 1940 ms 78120 KB Output is correct
91 Correct 801 ms 58640 KB Output is correct
92 Correct 1463 ms 77604 KB Output is correct
93 Correct 696 ms 58564 KB Output is correct
94 Correct 678 ms 58660 KB Output is correct
95 Correct 736 ms 58644 KB Output is correct
96 Correct 1538 ms 63608 KB Output is correct
97 Correct 738 ms 59604 KB Output is correct
98 Correct 1512 ms 68072 KB Output is correct
99 Correct 2755 ms 78256 KB Output is correct
100 Correct 123 ms 59608 KB Output is correct