Submission #37025869
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,q;
char S[N];
int s[3][N];
int main(){
cin>>n>>q;
scanf("\n%s",S+1);
for(int i=1;i<=n;i++){
for(int t=0;t<3;t++) s[t][i]=s[t][i-1];
if(S[i]!=S[i-1]) s[S[i]-'A'][i]++;
}
while(q--){
int l,r; cin>>l>>r;
cout<<(s[0][r]-s[0][l-1]+s[1][r]-s[1][l-1]+s[2][r]-s[2][l-1]+(S[l]==S[l-1])+(S[l]!=S[r]))/2<<'\n';
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - My Last ABC Problem |
| User | Appleblue17 |
| Language | C++ (GCC 9.2.1) |
| Score | 500 |
| Code Size | 414 Byte |
| Status | AC |
| Exec Time | 193 ms |
| Memory | 4896 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:11:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
11 | scanf("\n%s",S+1);
| ~~~~~^~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 01.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 8 ms | 3600 KiB |
| 02.txt | AC | 170 ms | 3556 KiB |
| 03.txt | AC | 169 ms | 3644 KiB |
| 04.txt | AC | 173 ms | 3656 KiB |
| 05.txt | AC | 193 ms | 4804 KiB |
| 06.txt | AC | 190 ms | 4892 KiB |
| 07.txt | AC | 187 ms | 4840 KiB |
| 08.txt | AC | 192 ms | 4836 KiB |
| 09.txt | AC | 189 ms | 4896 KiB |