Submission #47492400
Source Code Expand
Copy
#include <iostream>#include <vector>using namespace std;int main(){unsigned int n, q;cin >> n >> q;vector<unsigned int> same_total(n, 0);unsigned int same = 0;char prev = '_';for (unsigned int i = 0; i < n; i++){char c = '_';cin >> c;if (prev == c){same++;}
#include <iostream> #include <vector> using namespace std; int main() { unsigned int n, q; cin >> n >> q; vector<unsigned int> same_total(n, 0); unsigned int same = 0; char prev = '_'; for (unsigned int i = 0; i < n; i++) { char c = '_'; cin >> c; if (prev == c) { same++; } same_total[i] = same; prev = c; } for (unsigned int i = 0; i < q; i++) { unsigned int l, r; cin >> l >> r; cout << same_total[r - 1] - same_total[l - 1] << endl; } }
Submission Info
Submission Time | |
---|---|
Task | C - Consecutive |
User | michimani |
Language | C++ 20 (Clang 16.0.6) |
Score | 300 |
Code Size | 545 Byte |
Status | AC |
Exec Time | 417 ms |
Memory | 4244 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 334 ms | 3376 KB |
001.txt | AC | 403 ms | 4096 KB |
002.txt | AC | 375 ms | 4244 KB |
003.txt | AC | 387 ms | 4208 KB |
004.txt | AC | 415 ms | 4180 KB |
005.txt | AC | 379 ms | 3476 KB |
006.txt | AC | 411 ms | 4212 KB |
007.txt | AC | 381 ms | 3564 KB |
008.txt | AC | 385 ms | 3408 KB |
009.txt | AC | 402 ms | 3900 KB |
010.txt | AC | 395 ms | 3612 KB |
011.txt | AC | 405 ms | 4184 KB |
012.txt | AC | 396 ms | 3672 KB |
013.txt | AC | 417 ms | 4216 KB |
014.txt | AC | 410 ms | 4004 KB |
015.txt | AC | 407 ms | 4204 KB |
016.txt | AC | 410 ms | 4192 KB |
017.txt | AC | 409 ms | 4164 KB |
018.txt | AC | 408 ms | 4236 KB |
019.txt | AC | 407 ms | 4212 KB |
020.txt | AC | 409 ms | 4232 KB |
021.txt | AC | 413 ms | 4148 KB |
example0.txt | AC | 1 ms | 3408 KB |
example1.txt | AC | 1 ms | 3512 KB |