이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;
map<vector<int>,bool>odw;
const int N=200007,pot=1<<18;
int a[N][3];
int b[N][9];
int c[N];
int id[300];
int n;
void get()
{
bool ans=0;
for(int j=0;j<9;j++)
{
bool is=1;
for(int i=1;i<=n;i++) is&=b[i][j]==c[i];
ans|=is;
}
if(ans) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector<vector<int>>V;
V.pb({1,0,0});
odw[{1,0,0}]=1;
V.pb({0,1,0});
odw[{0,1,0}]=1;
V.pb({0,0,1});
odw[{0,0,1}]=1;
for(int i=0;i<sz(V);i++)
{
for(int j=0;j<i;j++)
{
vector<int>X(3);
for(int l=0;l<3;l++)
{
X[l]=(-V[i][l]-V[j][l]+6)%3;
}
if(!odw[X])
{
V.pb(X);
odw[X]=1;
}
}
}
id['J']=0;
id['O']=1;
id['I']=2;
cin>>n;
string s;
for(int j=0;j<3;j++)
{
cin>>s;
for(int i=1;i<=n;i++) a[i][j]=id[s[i-1]];
}
for(int j=0;j<9;j++)
{
for(int i=1;i<=n;i++)
{
for(int l=0;l<3;l++)
{
b[i][j]=(b[i][j]+a[i][l]*V[j][l])%3;
}
}
}
int q;
cin>>q>>s;
for(int i=1;i<=n;i++) c[i]=id[s[i-1]];
get();
while(q--)
{
int l,r;
char x;
cin>>l>>r>>x;
for(int i=l;i<=r;i++) c[i]=id[x];
get();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:76:48: warning: array subscript has type 'char' [-Wchar-subscripts]
76 | for(int i=1;i<=n;i++) a[i][j]=id[s[i-1]];
| ^
Main.cpp:90:41: warning: array subscript has type 'char' [-Wchar-subscripts]
90 | for(int i=1;i<=n;i++) c[i]=id[s[i-1]];
| ^
Main.cpp:97:39: warning: array subscript has type 'char' [-Wchar-subscripts]
97 | for(int i=l;i<=r;i++) c[i]=id[x];
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |