Submission #1371030
Source Code Expand
#include <bits/stdc++.h>
#define lld long long
#define pp pair<int,int>
#define pb push_back
#define MOD 1000000007
#define left lleft
#define right rright
#define INF 2000000000
#define Linf 1000000000000000000LL
#define next nnext
#define minus mminus
using namespace std;
int N,M,Q,ans;
int sum1[100010],sum2[100010];
char s1[100010],s2[100010];
int change(pp x){
if(x.first == x.second) return 0;
if(x == pp(0,1) || x == pp(2,0) || x == pp(1,2)) return 1;
return 2;
}
int main(){
scanf("%s %s",s1,s2);
N = strlen(s1); M = strlen(s2);
for(int i=1; i<=N; i++){
sum1[i] = sum1[i-1];
if(s1[i-1] == 'A') sum1[i]++;
}
for(int i=1; i<=M; i++){
sum2[i] = sum2[i-1];
if(s2[i-1] == 'A') sum2[i]++;
}
scanf("%d",&Q);
for(int i=1; i<=Q; i++){
int s1,e1,s2,e2;
scanf("%d %d %d %d",&s1,&e1,&s2,&e2);
int cnta1,cntb1,cnta2,cntb2;
cnta1 = sum1[e1]-sum1[s1-1];
cntb1 = (e1-s1+1)-cnta1;
cnta2 = sum2[e2]-sum2[s2-1];
cntb2 = (e2-s2+1)-cnta2;
cnta1 %= 3; cntb1 %= 3; cnta2 %= 3; cntb2 %= 3;
int cnt1,cnt2;
cnt1 = change({cnta1,cntb1});
cnt2 = change({cnta2,cntb2});
if(cnt1 == cnt2) ans = 1;
else ans = 0;
if(ans == 1) puts("YES");
else puts("NO");
}
return 0;
}
Submission Info
Submission Time |
|
Task |
E - TrBBnsformBBtion |
User |
suhgyuho |
Language |
C++14 (GCC 5.4.1) |
Score |
600 |
Code Size |
1259 Byte |
Status |
AC |
Exec Time |
42 ms |
Memory |
1536 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s %s",s1,s2);
^
./Main.cpp:37:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&Q);
^
./Main.cpp:40:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d %d",&s1,&e1,&s2,&e2);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
600 / 600 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_000.txt, 0_001.txt |
All |
0_000.txt, 0_001.txt, bound_0.txt, bound_1.txt, bound_2.txt, bound_3.txt, min.txt, rnd_10000_10.txt, rnd_10000_10000.txt, rnd_10000_2.txt, rnd_10_10.txt, rnd_10_10000.txt, rnd_10_2.txt, rnd_2_10.txt, rnd_2_10000.txt, rnd_2_2.txt |
Case Name |
Status |
Exec Time |
Memory |
0_000.txt |
AC |
1 ms |
256 KB |
0_001.txt |
AC |
1 ms |
256 KB |
bound_0.txt |
AC |
36 ms |
1536 KB |
bound_1.txt |
AC |
39 ms |
1536 KB |
bound_2.txt |
AC |
39 ms |
1536 KB |
bound_3.txt |
AC |
42 ms |
1536 KB |
min.txt |
AC |
1 ms |
256 KB |
rnd_10000_10.txt |
AC |
41 ms |
1536 KB |
rnd_10000_10000.txt |
AC |
40 ms |
1536 KB |
rnd_10000_2.txt |
AC |
41 ms |
1536 KB |
rnd_10_10.txt |
AC |
41 ms |
1536 KB |
rnd_10_10000.txt |
AC |
41 ms |
1536 KB |
rnd_10_2.txt |
AC |
41 ms |
1536 KB |
rnd_2_10.txt |
AC |
41 ms |
1536 KB |
rnd_2_10000.txt |
AC |
41 ms |
1536 KB |
rnd_2_2.txt |
AC |
41 ms |
1536 KB |