답안 #1100119

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100119 2024-10-12T19:02:27 Z imarn Crossing (JOI21_crossing) C++14
49 / 100
239 ms 22644 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=3;
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 56 ms 2388 KB Output is correct
2 Correct 62 ms 2388 KB Output is correct
3 Correct 59 ms 2388 KB Output is correct
4 Correct 46 ms 2444 KB Output is correct
5 Correct 46 ms 2388 KB Output is correct
6 Correct 46 ms 2388 KB Output is correct
7 Correct 47 ms 2396 KB Output is correct
8 Correct 49 ms 2384 KB Output is correct
9 Correct 49 ms 2580 KB Output is correct
10 Correct 50 ms 2580 KB Output is correct
11 Correct 52 ms 2384 KB Output is correct
12 Correct 53 ms 2512 KB Output is correct
13 Correct 50 ms 2388 KB Output is correct
14 Correct 49 ms 2364 KB Output is correct
15 Correct 50 ms 2596 KB Output is correct
16 Correct 54 ms 2452 KB Output is correct
17 Correct 58 ms 2384 KB Output is correct
18 Correct 55 ms 2388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 2388 KB Output is correct
2 Correct 62 ms 2388 KB Output is correct
3 Correct 59 ms 2388 KB Output is correct
4 Correct 46 ms 2444 KB Output is correct
5 Correct 46 ms 2388 KB Output is correct
6 Correct 46 ms 2388 KB Output is correct
7 Correct 47 ms 2396 KB Output is correct
8 Correct 49 ms 2384 KB Output is correct
9 Correct 49 ms 2580 KB Output is correct
10 Correct 50 ms 2580 KB Output is correct
11 Correct 52 ms 2384 KB Output is correct
12 Correct 53 ms 2512 KB Output is correct
13 Correct 50 ms 2388 KB Output is correct
14 Correct 49 ms 2364 KB Output is correct
15 Correct 50 ms 2596 KB Output is correct
16 Correct 54 ms 2452 KB Output is correct
17 Correct 58 ms 2384 KB Output is correct
18 Correct 55 ms 2388 KB Output is correct
19 Correct 191 ms 20064 KB Output is correct
20 Correct 223 ms 19804 KB Output is correct
21 Correct 133 ms 19304 KB Output is correct
22 Correct 135 ms 18680 KB Output is correct
23 Correct 83 ms 4180 KB Output is correct
24 Correct 90 ms 4180 KB Output is correct
25 Correct 150 ms 19700 KB Output is correct
26 Correct 157 ms 19916 KB Output is correct
27 Correct 154 ms 19868 KB Output is correct
28 Correct 167 ms 19812 KB Output is correct
29 Correct 152 ms 19728 KB Output is correct
30 Correct 93 ms 4176 KB Output is correct
31 Correct 155 ms 19764 KB Output is correct
32 Correct 156 ms 19400 KB Output is correct
33 Correct 89 ms 4188 KB Output is correct
34 Correct 169 ms 19920 KB Output is correct
35 Correct 130 ms 18160 KB Output is correct
36 Correct 90 ms 4304 KB Output is correct
37 Correct 90 ms 4176 KB Output is correct
38 Correct 161 ms 19496 KB Output is correct
39 Correct 118 ms 19748 KB Output is correct
40 Correct 127 ms 12640 KB Output is correct
41 Correct 218 ms 20064 KB Output is correct
42 Correct 49 ms 19300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 2388 KB Output is correct
2 Correct 62 ms 2388 KB Output is correct
3 Correct 59 ms 2388 KB Output is correct
4 Correct 46 ms 2444 KB Output is correct
5 Correct 46 ms 2388 KB Output is correct
6 Correct 46 ms 2388 KB Output is correct
7 Correct 47 ms 2396 KB Output is correct
8 Correct 49 ms 2384 KB Output is correct
9 Correct 49 ms 2580 KB Output is correct
10 Correct 50 ms 2580 KB Output is correct
11 Correct 52 ms 2384 KB Output is correct
12 Correct 53 ms 2512 KB Output is correct
13 Correct 50 ms 2388 KB Output is correct
14 Correct 49 ms 2364 KB Output is correct
15 Correct 50 ms 2596 KB Output is correct
16 Correct 54 ms 2452 KB Output is correct
17 Correct 58 ms 2384 KB Output is correct
18 Correct 55 ms 2388 KB Output is correct
19 Correct 63 ms 2388 KB Output is correct
20 Correct 65 ms 2432 KB Output is correct
21 Correct 55 ms 2384 KB Output is correct
22 Correct 47 ms 2280 KB Output is correct
23 Correct 52 ms 2388 KB Output is correct
24 Correct 54 ms 2436 KB Output is correct
25 Correct 53 ms 2568 KB Output is correct
26 Correct 48 ms 2476 KB Output is correct
27 Correct 53 ms 2388 KB Output is correct
28 Correct 44 ms 2384 KB Output is correct
29 Correct 49 ms 2404 KB Output is correct
30 Correct 44 ms 2232 KB Output is correct
31 Correct 54 ms 2388 KB Output is correct
32 Correct 52 ms 2592 KB Output is correct
33 Correct 53 ms 2388 KB Output is correct
34 Correct 50 ms 2320 KB Output is correct
35 Correct 52 ms 2564 KB Output is correct
36 Correct 53 ms 2392 KB Output is correct
37 Correct 53 ms 2388 KB Output is correct
38 Correct 53 ms 2556 KB Output is correct
39 Correct 52 ms 2388 KB Output is correct
40 Correct 55 ms 2520 KB Output is correct
41 Correct 58 ms 2388 KB Output is correct
42 Correct 58 ms 2384 KB Output is correct
43 Correct 53 ms 2384 KB Output is correct
44 Correct 56 ms 2440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 2388 KB Output is correct
2 Correct 62 ms 2388 KB Output is correct
3 Correct 59 ms 2388 KB Output is correct
4 Correct 46 ms 2444 KB Output is correct
5 Correct 46 ms 2388 KB Output is correct
6 Correct 46 ms 2388 KB Output is correct
7 Correct 47 ms 2396 KB Output is correct
8 Correct 49 ms 2384 KB Output is correct
9 Correct 49 ms 2580 KB Output is correct
10 Correct 50 ms 2580 KB Output is correct
11 Correct 52 ms 2384 KB Output is correct
12 Correct 53 ms 2512 KB Output is correct
13 Correct 50 ms 2388 KB Output is correct
14 Correct 49 ms 2364 KB Output is correct
15 Correct 50 ms 2596 KB Output is correct
16 Correct 54 ms 2452 KB Output is correct
17 Correct 58 ms 2384 KB Output is correct
18 Correct 55 ms 2388 KB Output is correct
19 Correct 191 ms 20064 KB Output is correct
20 Correct 223 ms 19804 KB Output is correct
21 Correct 133 ms 19304 KB Output is correct
22 Correct 135 ms 18680 KB Output is correct
23 Correct 83 ms 4180 KB Output is correct
24 Correct 90 ms 4180 KB Output is correct
25 Correct 150 ms 19700 KB Output is correct
26 Correct 157 ms 19916 KB Output is correct
27 Correct 154 ms 19868 KB Output is correct
28 Correct 167 ms 19812 KB Output is correct
29 Correct 152 ms 19728 KB Output is correct
30 Correct 93 ms 4176 KB Output is correct
31 Correct 155 ms 19764 KB Output is correct
32 Correct 156 ms 19400 KB Output is correct
33 Correct 89 ms 4188 KB Output is correct
34 Correct 169 ms 19920 KB Output is correct
35 Correct 130 ms 18160 KB Output is correct
36 Correct 90 ms 4304 KB Output is correct
37 Correct 90 ms 4176 KB Output is correct
38 Correct 161 ms 19496 KB Output is correct
39 Correct 118 ms 19748 KB Output is correct
40 Correct 127 ms 12640 KB Output is correct
41 Correct 218 ms 20064 KB Output is correct
42 Correct 49 ms 19300 KB Output is correct
43 Correct 63 ms 2388 KB Output is correct
44 Correct 65 ms 2432 KB Output is correct
45 Correct 55 ms 2384 KB Output is correct
46 Correct 47 ms 2280 KB Output is correct
47 Correct 52 ms 2388 KB Output is correct
48 Correct 54 ms 2436 KB Output is correct
49 Correct 53 ms 2568 KB Output is correct
50 Correct 48 ms 2476 KB Output is correct
51 Correct 53 ms 2388 KB Output is correct
52 Correct 44 ms 2384 KB Output is correct
53 Correct 49 ms 2404 KB Output is correct
54 Correct 44 ms 2232 KB Output is correct
55 Correct 54 ms 2388 KB Output is correct
56 Correct 52 ms 2592 KB Output is correct
57 Correct 53 ms 2388 KB Output is correct
58 Correct 50 ms 2320 KB Output is correct
59 Correct 52 ms 2564 KB Output is correct
60 Correct 53 ms 2392 KB Output is correct
61 Correct 53 ms 2388 KB Output is correct
62 Correct 53 ms 2556 KB Output is correct
63 Correct 52 ms 2388 KB Output is correct
64 Correct 55 ms 2520 KB Output is correct
65 Correct 58 ms 2388 KB Output is correct
66 Correct 58 ms 2384 KB Output is correct
67 Correct 53 ms 2384 KB Output is correct
68 Correct 56 ms 2440 KB Output is correct
69 Correct 192 ms 21204 KB Output is correct
70 Correct 239 ms 22644 KB Output is correct
71 Correct 88 ms 4184 KB Output is correct
72 Incorrect 92 ms 4176 KB Output isn't correct
73 Halted 0 ms 0 KB -