답안 #1100120

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100120 2024-10-12T19:03:06 Z imarn Crossing (JOI21_crossing) C++14
26 / 100
194 ms 18276 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
using namespace std;
const ll inf=123456789,mxn=2e5+5,B=17;
vector<string>ans;
int n;string s[3];
map<string,int>mp;
int sz;
string cal(string a,string b,string rs=""){
    for(int i=0;i<n;i++){
        if(a[i]==b[i])rs+=a[i];
        else rs+=char('J'+'O'+'I'-a[i]-b[i]);
    }return rs;
}int c[200];
ll qs[mxn]{0},pw[mxn]{0},qp[mxn]{0};
struct node{
    ll tt,sz;
    node operator+(node b){
        return node{(tt+(b.tt*pw[sz])%inf)%inf,sz+b.sz};
    }
}t[4*mxn];string t0;
int lz[4*mxn];
void push(int i,int l,int r){
    if(lz[i]!=-1){
        t[i].tt=lz[i]*qp[t[i].sz];
        if(l<r)lz[2*i]=lz[i],lz[2*i+1]=lz[i];
        lz[i]=-1;
    }
}
void build(int i,int l,int r){
    lz[i]=-1;
    if(l==r)return void(t[i]={c[t0[l-1]],1});
    int m=(l+r)>>1;build(2*i,l,m);build(2*i+1,m+1,r);
    t[i]=t[2*i]+t[2*i+1];
}void check(){
    for(int i=0;i<ans.size();i++){if(((t[1].tt)%inf+inf)%inf==(qs[i]%inf+inf)%inf){cout<<"Yes\n";return;}}
    cout<<"No\n";
}
void upd(int i,int l,int r,int tl,int tr,int v){
    push(i,l,r);
    if(r<tl||l>tr)return;
    if(r<=tr&&l>=tl){
        lz[i]=v;push(i,l,r);return;
    }int m=(l+r)>>1;upd(2*i,l,m,tl,tr,v);upd(2*i+1,m+1,r,tl,tr,v);
    t[i]=t[2*i]+t[2*i+1];
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>s[0]>>s[1]>>s[2];mp[s[0]]=mp[s[1]]=mp[s[2]]=1;pw[0]=1;
    for(int i=1;i<=n;i++)pw[i]=(pw[i-1]*B)%inf;qp[0]=0;
    for(int i=1;i<=n;i++)qp[i]=(qp[i-1]+pw[i-1])%inf;
    ans.pb(s[0]);ans.pb(s[1]);ans.pb(s[2]);
    for(int i=0;i<ans.size();i++){
        for(int j=0;j<3;j++){
            string rs=cal(ans[i],ans[j]);
            if(mp.find(rs)==mp.end())mp[rs]=1,ans.pb(rs);
        }
    }sz=ans.size();c['J']=0,c['O']=1,c['I']=2;
    for(int i=0;i<sz;i++){
        for(int j=0;j<n;j++){
            qs[i]+=c[ans[i][j]]*pw[j];
            qs[i]%=inf;
        }
    }int q;cin>>q>>t0;build(1,1,n);check();
    while(q--){
        int l,r;char x;cin>>l>>r>>x;
        upd(1,1,n,l,r,c[x]);check();
    }

}

Compilation message

Main.cpp: In function 'void build(int, int, int)':
Main.cpp:42:40: warning: array subscript has type 'char' [-Wchar-subscripts]
   42 |     if(l==r)return void(t[i]={c[t0[l-1]],1});
      |                                        ^
Main.cpp: In function 'void check()':
Main.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=0;i<ans.size();i++){if(((t[1].tt)%inf+inf)%inf==(qs[i]%inf+inf)%inf){cout<<"Yes\n";return;}}
      |                 ~^~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:60:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   60 |     for(int i=1;i<=n;i++)pw[i]=(pw[i-1]*B)%inf;qp[0]=0;
      |     ^~~
Main.cpp:60:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   60 |     for(int i=1;i<=n;i++)pw[i]=(pw[i-1]*B)%inf;qp[0]=0;
      |                                                ^~
Main.cpp:63:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i=0;i<ans.size();i++){
      |                 ~^~~~~~~~~~~
Main.cpp:71:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   71 |             qs[i]+=c[ans[i][j]]*pw[j];
      |                               ^
Main.cpp:77:25: warning: array subscript has type 'char' [-Wchar-subscripts]
   77 |         upd(1,1,n,l,r,c[x]);check();
      |                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 1884 KB Output is correct
2 Correct 58 ms 1876 KB Output is correct
3 Correct 57 ms 1872 KB Output is correct
4 Correct 48 ms 2032 KB Output is correct
5 Correct 48 ms 1872 KB Output is correct
6 Correct 61 ms 1944 KB Output is correct
7 Correct 49 ms 1880 KB Output is correct
8 Correct 51 ms 1868 KB Output is correct
9 Correct 52 ms 1872 KB Output is correct
10 Correct 53 ms 2032 KB Output is correct
11 Correct 52 ms 2068 KB Output is correct
12 Correct 53 ms 1964 KB Output is correct
13 Correct 52 ms 1880 KB Output is correct
14 Correct 52 ms 1876 KB Output is correct
15 Correct 56 ms 1880 KB Output is correct
16 Correct 53 ms 1876 KB Output is correct
17 Correct 54 ms 1872 KB Output is correct
18 Correct 54 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 1884 KB Output is correct
2 Correct 58 ms 1876 KB Output is correct
3 Correct 57 ms 1872 KB Output is correct
4 Correct 48 ms 2032 KB Output is correct
5 Correct 48 ms 1872 KB Output is correct
6 Correct 61 ms 1944 KB Output is correct
7 Correct 49 ms 1880 KB Output is correct
8 Correct 51 ms 1868 KB Output is correct
9 Correct 52 ms 1872 KB Output is correct
10 Correct 53 ms 2032 KB Output is correct
11 Correct 52 ms 2068 KB Output is correct
12 Correct 53 ms 1964 KB Output is correct
13 Correct 52 ms 1880 KB Output is correct
14 Correct 52 ms 1876 KB Output is correct
15 Correct 56 ms 1880 KB Output is correct
16 Correct 53 ms 1876 KB Output is correct
17 Correct 54 ms 1872 KB Output is correct
18 Correct 54 ms 1880 KB Output is correct
19 Correct 194 ms 18092 KB Output is correct
20 Correct 179 ms 18268 KB Output is correct
21 Correct 134 ms 18008 KB Output is correct
22 Correct 135 ms 17300 KB Output is correct
23 Correct 86 ms 3300 KB Output is correct
24 Correct 85 ms 3396 KB Output is correct
25 Correct 128 ms 18276 KB Output is correct
26 Correct 137 ms 18192 KB Output is correct
27 Correct 143 ms 16224 KB Output is correct
28 Correct 144 ms 16172 KB Output is correct
29 Correct 144 ms 16148 KB Output is correct
30 Correct 89 ms 1876 KB Output is correct
31 Correct 152 ms 16204 KB Output is correct
32 Correct 151 ms 15716 KB Output is correct
33 Correct 83 ms 1804 KB Output is correct
34 Correct 145 ms 16224 KB Output is correct
35 Correct 129 ms 14856 KB Output is correct
36 Correct 87 ms 1876 KB Output is correct
37 Correct 88 ms 1876 KB Output is correct
38 Correct 153 ms 16032 KB Output is correct
39 Correct 114 ms 16228 KB Output is correct
40 Incorrect 124 ms 9552 KB Output isn't correct
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 1884 KB Output is correct
2 Correct 58 ms 1876 KB Output is correct
3 Correct 57 ms 1872 KB Output is correct
4 Correct 48 ms 2032 KB Output is correct
5 Correct 48 ms 1872 KB Output is correct
6 Correct 61 ms 1944 KB Output is correct
7 Correct 49 ms 1880 KB Output is correct
8 Correct 51 ms 1868 KB Output is correct
9 Correct 52 ms 1872 KB Output is correct
10 Correct 53 ms 2032 KB Output is correct
11 Correct 52 ms 2068 KB Output is correct
12 Correct 53 ms 1964 KB Output is correct
13 Correct 52 ms 1880 KB Output is correct
14 Correct 52 ms 1876 KB Output is correct
15 Correct 56 ms 1880 KB Output is correct
16 Correct 53 ms 1876 KB Output is correct
17 Correct 54 ms 1872 KB Output is correct
18 Correct 54 ms 1880 KB Output is correct
19 Correct 57 ms 852 KB Output is correct
20 Correct 62 ms 924 KB Output is correct
21 Correct 52 ms 848 KB Output is correct
22 Correct 45 ms 848 KB Output is correct
23 Correct 52 ms 860 KB Output is correct
24 Correct 50 ms 860 KB Output is correct
25 Correct 52 ms 904 KB Output is correct
26 Correct 49 ms 1036 KB Output is correct
27 Correct 51 ms 1040 KB Output is correct
28 Correct 46 ms 820 KB Output is correct
29 Correct 53 ms 904 KB Output is correct
30 Correct 46 ms 896 KB Output is correct
31 Correct 56 ms 1020 KB Output is correct
32 Correct 54 ms 848 KB Output is correct
33 Correct 56 ms 848 KB Output is correct
34 Correct 49 ms 860 KB Output is correct
35 Correct 55 ms 884 KB Output is correct
36 Correct 55 ms 860 KB Output is correct
37 Correct 56 ms 848 KB Output is correct
38 Correct 63 ms 848 KB Output is correct
39 Correct 55 ms 852 KB Output is correct
40 Correct 55 ms 1064 KB Output is correct
41 Correct 52 ms 988 KB Output is correct
42 Correct 68 ms 980 KB Output is correct
43 Correct 52 ms 852 KB Output is correct
44 Correct 53 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 1884 KB Output is correct
2 Correct 58 ms 1876 KB Output is correct
3 Correct 57 ms 1872 KB Output is correct
4 Correct 48 ms 2032 KB Output is correct
5 Correct 48 ms 1872 KB Output is correct
6 Correct 61 ms 1944 KB Output is correct
7 Correct 49 ms 1880 KB Output is correct
8 Correct 51 ms 1868 KB Output is correct
9 Correct 52 ms 1872 KB Output is correct
10 Correct 53 ms 2032 KB Output is correct
11 Correct 52 ms 2068 KB Output is correct
12 Correct 53 ms 1964 KB Output is correct
13 Correct 52 ms 1880 KB Output is correct
14 Correct 52 ms 1876 KB Output is correct
15 Correct 56 ms 1880 KB Output is correct
16 Correct 53 ms 1876 KB Output is correct
17 Correct 54 ms 1872 KB Output is correct
18 Correct 54 ms 1880 KB Output is correct
19 Correct 194 ms 18092 KB Output is correct
20 Correct 179 ms 18268 KB Output is correct
21 Correct 134 ms 18008 KB Output is correct
22 Correct 135 ms 17300 KB Output is correct
23 Correct 86 ms 3300 KB Output is correct
24 Correct 85 ms 3396 KB Output is correct
25 Correct 128 ms 18276 KB Output is correct
26 Correct 137 ms 18192 KB Output is correct
27 Correct 143 ms 16224 KB Output is correct
28 Correct 144 ms 16172 KB Output is correct
29 Correct 144 ms 16148 KB Output is correct
30 Correct 89 ms 1876 KB Output is correct
31 Correct 152 ms 16204 KB Output is correct
32 Correct 151 ms 15716 KB Output is correct
33 Correct 83 ms 1804 KB Output is correct
34 Correct 145 ms 16224 KB Output is correct
35 Correct 129 ms 14856 KB Output is correct
36 Correct 87 ms 1876 KB Output is correct
37 Correct 88 ms 1876 KB Output is correct
38 Correct 153 ms 16032 KB Output is correct
39 Correct 114 ms 16228 KB Output is correct
40 Incorrect 124 ms 9552 KB Output isn't correct
41 Halted 0 ms 0 KB -