Submission #423426

# Submission time Handle Problem Language Result Execution time Memory
423426 2021-06-11T05:48:02 Z 장태환(#7573) Crossing (JOI21_crossing) C++17
100 / 100
2974 ms 116024 KB
#include <bits/stdc++.h>
using namespace std;
struct laz
{
    int stree[1<<20][2];
    int lazy[1<<20];
    int treeN;
    void init(int N,vector<int>arr)
    {
        for(treeN=1;treeN<N;treeN*=2);
        memset(stree,-1,sizeof(stree));
        memset(lazy,-1,sizeof(lazy));
        int i;
        for(i=treeN;i<treeN+arr.size();i++)
        {
            stree[i][0]=arr[i-treeN];
            stree[i][1]=0;
        }
        for(;i<2*treeN;i++)
        {
            stree[i][1]=1;
        }
        for(i=treeN-1;i>0;i--)
        {
            stree[i][0]=(stree[i*2][0]==stree[i*2+1][0])?stree[i*2][0]:-1;
            stree[i][1]=stree[i*2][1]&stree[i*2+1][1];
        }
    }
    void ul(int n)
    {
        if(lazy[n]==-1)
            return;
        stree[n][1]=lazy[n]==stree[n][0];
        if(n<treeN)
        {
            lazy[2*n]=lazy[n];
            lazy[2*n+1]=lazy[n];
        }
        lazy[n]=-1;
    }
    void upd(int s,int e,int qs,int qe,int i,int v)
    {
        ul(i);
        if(s>qe||qs>e)
            return;
        if(qs<=s&&e<=qe)
        {
            lazy[i]=v;
            ul(i);
            return;
        }
        upd(s,(s+e)/2,qs,qe,i*2,v);
        upd((s+e)/2+1,e,qs,qe,i*2+1,v);
        stree[i][1]=stree[i*2][1]&stree[i*2+1][1];
    }
}segtree[9];
string s[3];
int arr[3][200100];
int qs[200100];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    cin >>s[0]>>s[1]>>s[2];
    int i,j,k;
    for(i=0;i<3;i++)
    {
        for(j=0;j<N;j++)
        {
            arr[i][j]=(s[i][j]=='J')?0:(s[i][j]=='O'?1:2);
        }
    }
    int c=0;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            for(k=0;k<3;k++)
            {
                if((i+j+k)%3==1)
                {
                    vector<int>x;
                    int l;
                    for(l=0;l<N;l++)
                    {
                        x.push_back((i*arr[0][l]+j*arr[1][l]+k*arr[2][l])%3);

                    }
                    segtree[c++].init(N,x);
                }
            }
        }
    }
    int Q;
    cin >> Q;
    string q;
    cin >> q;
    for(j=0;j<N;j++)
    {
        qs[j]=(q[j]=='J')?0:(q[j]=='O'?1:2);
    }
    for(i=0;i<N;i++)
    {
        int j;
        for(j=0;j<9;j++)
        {
            segtree[j].upd(0,segtree[j].treeN-1,i,i,1,qs[i]);
        }
    }
    int an=0;
    for(j=0;j<9;j++)
    {
        an|=segtree[j].stree[1][1];
    }
    cout <<(an?"Yes":"No")<<'\n';
    while(Q--)
    {
        int a,b;
        char c;
        cin >> a >> b >> c;
        int d=(c=='J')?0:(c=='O'?1:2);
        int j;
        int an=0;
        for(j=0;j<9;j++)
        {
            segtree[j].upd(0,segtree[j].treeN-1,a-1,b-1,1,d);
            an|=segtree[j].stree[1][1];
        }
        cout <<(an?"Yes":"No")<<'\n';
    }
}

Compilation message

Main.cpp: In member function 'void laz::init(int, std::vector<int>)':
Main.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for(i=treeN;i<treeN+arr.size();i++)
      |                     ~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 334 ms 111604 KB Output is correct
2 Correct 302 ms 111692 KB Output is correct
3 Correct 306 ms 111716 KB Output is correct
4 Correct 263 ms 111612 KB Output is correct
5 Correct 253 ms 111832 KB Output is correct
6 Correct 302 ms 111660 KB Output is correct
7 Correct 260 ms 111720 KB Output is correct
8 Correct 263 ms 111688 KB Output is correct
9 Correct 258 ms 111652 KB Output is correct
10 Correct 256 ms 111704 KB Output is correct
11 Correct 262 ms 111748 KB Output is correct
12 Correct 291 ms 111688 KB Output is correct
13 Correct 269 ms 111700 KB Output is correct
14 Correct 262 ms 111684 KB Output is correct
15 Correct 288 ms 111636 KB Output is correct
16 Correct 258 ms 111800 KB Output is correct
17 Correct 285 ms 111708 KB Output is correct
18 Correct 291 ms 111716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 334 ms 111604 KB Output is correct
2 Correct 302 ms 111692 KB Output is correct
3 Correct 306 ms 111716 KB Output is correct
4 Correct 263 ms 111612 KB Output is correct
5 Correct 253 ms 111832 KB Output is correct
6 Correct 302 ms 111660 KB Output is correct
7 Correct 260 ms 111720 KB Output is correct
8 Correct 263 ms 111688 KB Output is correct
9 Correct 258 ms 111652 KB Output is correct
10 Correct 256 ms 111704 KB Output is correct
11 Correct 262 ms 111748 KB Output is correct
12 Correct 291 ms 111688 KB Output is correct
13 Correct 269 ms 111700 KB Output is correct
14 Correct 262 ms 111684 KB Output is correct
15 Correct 288 ms 111636 KB Output is correct
16 Correct 258 ms 111800 KB Output is correct
17 Correct 285 ms 111708 KB Output is correct
18 Correct 291 ms 111716 KB Output is correct
19 Correct 2683 ms 115924 KB Output is correct
20 Correct 2465 ms 115904 KB Output is correct
21 Correct 1823 ms 115768 KB Output is correct
22 Correct 1746 ms 115320 KB Output is correct
23 Correct 787 ms 112068 KB Output is correct
24 Correct 698 ms 112004 KB Output is correct
25 Correct 1886 ms 115836 KB Output is correct
26 Correct 1946 ms 115816 KB Output is correct
27 Correct 2338 ms 115976 KB Output is correct
28 Correct 2212 ms 115824 KB Output is correct
29 Correct 2130 ms 115752 KB Output is correct
30 Correct 746 ms 111960 KB Output is correct
31 Correct 2247 ms 115820 KB Output is correct
32 Correct 2041 ms 115560 KB Output is correct
33 Correct 675 ms 111988 KB Output is correct
34 Correct 2261 ms 115808 KB Output is correct
35 Correct 1673 ms 114864 KB Output is correct
36 Correct 696 ms 111952 KB Output is correct
37 Correct 662 ms 112028 KB Output is correct
38 Correct 2191 ms 115920 KB Output is correct
39 Correct 1193 ms 115864 KB Output is correct
40 Correct 1669 ms 114640 KB Output is correct
41 Correct 2864 ms 115984 KB Output is correct
42 Correct 954 ms 116020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 334 ms 111604 KB Output is correct
2 Correct 302 ms 111692 KB Output is correct
3 Correct 306 ms 111716 KB Output is correct
4 Correct 263 ms 111612 KB Output is correct
5 Correct 253 ms 111832 KB Output is correct
6 Correct 302 ms 111660 KB Output is correct
7 Correct 260 ms 111720 KB Output is correct
8 Correct 263 ms 111688 KB Output is correct
9 Correct 258 ms 111652 KB Output is correct
10 Correct 256 ms 111704 KB Output is correct
11 Correct 262 ms 111748 KB Output is correct
12 Correct 291 ms 111688 KB Output is correct
13 Correct 269 ms 111700 KB Output is correct
14 Correct 262 ms 111684 KB Output is correct
15 Correct 288 ms 111636 KB Output is correct
16 Correct 258 ms 111800 KB Output is correct
17 Correct 285 ms 111708 KB Output is correct
18 Correct 291 ms 111716 KB Output is correct
19 Correct 347 ms 111744 KB Output is correct
20 Correct 301 ms 111652 KB Output is correct
21 Correct 269 ms 111724 KB Output is correct
22 Correct 254 ms 111684 KB Output is correct
23 Correct 282 ms 111672 KB Output is correct
24 Correct 285 ms 111748 KB Output is correct
25 Correct 259 ms 111620 KB Output is correct
26 Correct 272 ms 111652 KB Output is correct
27 Correct 260 ms 111636 KB Output is correct
28 Correct 249 ms 111688 KB Output is correct
29 Correct 269 ms 111768 KB Output is correct
30 Correct 266 ms 111724 KB Output is correct
31 Correct 303 ms 111632 KB Output is correct
32 Correct 259 ms 111628 KB Output is correct
33 Correct 268 ms 111648 KB Output is correct
34 Correct 238 ms 111620 KB Output is correct
35 Correct 302 ms 111668 KB Output is correct
36 Correct 287 ms 111644 KB Output is correct
37 Correct 260 ms 111748 KB Output is correct
38 Correct 259 ms 111724 KB Output is correct
39 Correct 323 ms 111672 KB Output is correct
40 Correct 265 ms 111728 KB Output is correct
41 Correct 255 ms 111672 KB Output is correct
42 Correct 259 ms 111684 KB Output is correct
43 Correct 251 ms 111604 KB Output is correct
44 Correct 258 ms 111640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 334 ms 111604 KB Output is correct
2 Correct 302 ms 111692 KB Output is correct
3 Correct 306 ms 111716 KB Output is correct
4 Correct 263 ms 111612 KB Output is correct
5 Correct 253 ms 111832 KB Output is correct
6 Correct 302 ms 111660 KB Output is correct
7 Correct 260 ms 111720 KB Output is correct
8 Correct 263 ms 111688 KB Output is correct
9 Correct 258 ms 111652 KB Output is correct
10 Correct 256 ms 111704 KB Output is correct
11 Correct 262 ms 111748 KB Output is correct
12 Correct 291 ms 111688 KB Output is correct
13 Correct 269 ms 111700 KB Output is correct
14 Correct 262 ms 111684 KB Output is correct
15 Correct 288 ms 111636 KB Output is correct
16 Correct 258 ms 111800 KB Output is correct
17 Correct 285 ms 111708 KB Output is correct
18 Correct 291 ms 111716 KB Output is correct
19 Correct 2683 ms 115924 KB Output is correct
20 Correct 2465 ms 115904 KB Output is correct
21 Correct 1823 ms 115768 KB Output is correct
22 Correct 1746 ms 115320 KB Output is correct
23 Correct 787 ms 112068 KB Output is correct
24 Correct 698 ms 112004 KB Output is correct
25 Correct 1886 ms 115836 KB Output is correct
26 Correct 1946 ms 115816 KB Output is correct
27 Correct 2338 ms 115976 KB Output is correct
28 Correct 2212 ms 115824 KB Output is correct
29 Correct 2130 ms 115752 KB Output is correct
30 Correct 746 ms 111960 KB Output is correct
31 Correct 2247 ms 115820 KB Output is correct
32 Correct 2041 ms 115560 KB Output is correct
33 Correct 675 ms 111988 KB Output is correct
34 Correct 2261 ms 115808 KB Output is correct
35 Correct 1673 ms 114864 KB Output is correct
36 Correct 696 ms 111952 KB Output is correct
37 Correct 662 ms 112028 KB Output is correct
38 Correct 2191 ms 115920 KB Output is correct
39 Correct 1193 ms 115864 KB Output is correct
40 Correct 1669 ms 114640 KB Output is correct
41 Correct 2864 ms 115984 KB Output is correct
42 Correct 954 ms 116020 KB Output is correct
43 Correct 347 ms 111744 KB Output is correct
44 Correct 301 ms 111652 KB Output is correct
45 Correct 269 ms 111724 KB Output is correct
46 Correct 254 ms 111684 KB Output is correct
47 Correct 282 ms 111672 KB Output is correct
48 Correct 285 ms 111748 KB Output is correct
49 Correct 259 ms 111620 KB Output is correct
50 Correct 272 ms 111652 KB Output is correct
51 Correct 260 ms 111636 KB Output is correct
52 Correct 249 ms 111688 KB Output is correct
53 Correct 269 ms 111768 KB Output is correct
54 Correct 266 ms 111724 KB Output is correct
55 Correct 303 ms 111632 KB Output is correct
56 Correct 259 ms 111628 KB Output is correct
57 Correct 268 ms 111648 KB Output is correct
58 Correct 238 ms 111620 KB Output is correct
59 Correct 302 ms 111668 KB Output is correct
60 Correct 287 ms 111644 KB Output is correct
61 Correct 260 ms 111748 KB Output is correct
62 Correct 259 ms 111724 KB Output is correct
63 Correct 323 ms 111672 KB Output is correct
64 Correct 265 ms 111728 KB Output is correct
65 Correct 255 ms 111672 KB Output is correct
66 Correct 259 ms 111684 KB Output is correct
67 Correct 251 ms 111604 KB Output is correct
68 Correct 258 ms 111640 KB Output is correct
69 Correct 2290 ms 115268 KB Output is correct
70 Correct 2325 ms 115864 KB Output is correct
71 Correct 676 ms 111980 KB Output is correct
72 Correct 756 ms 111944 KB Output is correct
73 Correct 683 ms 112000 KB Output is correct
74 Correct 1703 ms 115200 KB Output is correct
75 Correct 698 ms 111920 KB Output is correct
76 Correct 1866 ms 115816 KB Output is correct
77 Correct 1836 ms 115212 KB Output is correct
78 Correct 690 ms 111988 KB Output is correct
79 Correct 705 ms 112080 KB Output is correct
80 Correct 1602 ms 114800 KB Output is correct
81 Correct 681 ms 112016 KB Output is correct
82 Correct 1858 ms 115856 KB Output is correct
83 Correct 1934 ms 115652 KB Output is correct
84 Correct 682 ms 112168 KB Output is correct
85 Correct 693 ms 112000 KB Output is correct
86 Correct 2017 ms 114888 KB Output is correct
87 Correct 2265 ms 115816 KB Output is correct
88 Correct 750 ms 111932 KB Output is correct
89 Correct 1996 ms 115412 KB Output is correct
90 Correct 2188 ms 115864 KB Output is correct
91 Correct 755 ms 112140 KB Output is correct
92 Correct 1622 ms 114904 KB Output is correct
93 Correct 632 ms 112000 KB Output is correct
94 Correct 719 ms 111952 KB Output is correct
95 Correct 680 ms 111940 KB Output is correct
96 Correct 2178 ms 115840 KB Output is correct
97 Correct 1205 ms 115856 KB Output is correct
98 Correct 1709 ms 114536 KB Output is correct
99 Correct 2974 ms 116004 KB Output is correct
100 Correct 1047 ms 116024 KB Output is correct