QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#474405 | #5501. Ctrl+C Ctrl+V | piratZnachor# | WA | 21ms | 3664kb | C++14 | 1.6kb | 2024-07-12 17:52:59 | 2024-07-12 17:52:59 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
template<typename _T> void _debug(const char *s, _T x){ cerr << s << " = " << x << "\n";}
template<typename _T, typename... R> void _debug(const char *s, _T x, R... r){ while(*s != ',') cerr << *s++; cerr << " = " << x << ", "; _debug(s + 1, r...);}
#define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
#define sz(s) int32_t(s.size())
#define all(x) begin(x), end(x)
#define getuniqe(x) x.erase(unique(all(x)), end(x))
#define X first
#define Y second
using ll = long long;
using ld = long double;
#define int ll
const int N = 2e5 + 5;
const string ania = "ania";
const string aniania = "aniania";
void solve() {
string s; cin >> s;
int n = sz(s), m = sz(ania), k = sz(aniania);
int result = 0;
for (int i = 0; i < n; i++) {
bool is_ania = true;
for (int j = 0; j < m; j++) {
if (i + j >= n) is_ania = false;
else is_ania &= (ania[j] == s[i + j]);
}
bool is_ania_ania = (i + k - 1 < n) && is_ania;
for (int j = 0; j < k; j++) {
if (i + j >= n) is_ania_ania = false;
else is_ania_ania &= (aniania[j] == s[i + j]);
}
if (is_ania_ania) {
result++;
i += k - 1;
} else if (is_ania) {
result++;
i += m - 1;
}
}
cout << result << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tests = 1; cin >> tests;
for (int test_case = 1; test_case <= tests; test_case++) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
input:
3 aniasieurodzilaapotemnicsieniedzialo nicciekawegouanianiagnieszkianialicji jeszczekrotszaautobiografiaani
output:
1 2 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 21ms
memory: 3664kb
input:
10000 aniaanianianianiaviananibnianianianianianiapianianianianianianiaanianianianiananianianianiananifw ananiacnganiaaywbwrkaniahaniaganiaglljaniaouaqrdyaniaypvsgjltrbcvjssrtnehqfzpfvaniahwaniauzncovwfmiqejteiuaniacblxyfikauptesitsitvananianiajndy anianianianianianiaanianianianianiaanianianianianiaa...
output:
11 11 40 12 9 10 35 2 38 7 18 10 37 5 60 27 41 44 21 13 22 18 18 9 55 3 19 14 33 48 17 25 14 4 27 37 9 45 13 21 40 23 3 13 18 55 5 15 31 22 22 13 25 2 18 2 18 21 53 38 20 9 5 6 16 22 55 1 47 41 8 19 37 13 6 12 51 18 22 19 19 4 55 17 25 6 19 60 10 28 51 6 32 21 18 19 15 40 49 14 2 7 10 5 32 55 0 29 1...
result:
wrong answer 1st lines differ - expected: '13', found: '11'