QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#139505#5501. Ctrl+C Ctrl+Vammardab3an#AC ✓57ms6384kbC++172.3kb2023-08-13 19:07:452023-08-13 19:07:45

Judging History

你现在查看的是最新测评结果

  • [2023-08-13 19:07:45]
  • 评测
  • 测评结果:AC
  • 用时:57ms
  • 内存:6384kb
  • [2023-08-13 19:07:45]
  • 提交

answer


// By AmmarDab3an 

#include "bits/stdc++.h"

using namespace std;

#define int int64_t
#define ll  int64_t

// typedef unsigned int        uint;
// typedef long long int       ll;
// typedef unsigned long long  ull;
typedef pair<int, int>    pii;
typedef pair<ll, ll>      pll;
typedef pair<int, pii>    iii;
typedef pair<ll, pll>     lll;
typedef vector<int>       vi;
typedef vector<ll>        vl;
typedef vector<pii>       vpii;
typedef vector<pll>       vpll;

#define endl '\n'
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define freopenI freopen("input.txt", "r", stdin);
#define freopenO freopen("output.txt", "w", stdout);

const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double  PI = acos(-1);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int rand(int x, int y) {
	return uniform_int_distribution<int>(x, y)(rng);
}

int mul(int a, int b){
	int ret = (1ll * (a%MOD) * (b%MOD)) % MOD;
	return (ret+MOD)%MOD;
}
 
int add(int a, int b){
	int ret = (1ll * (a%MOD) + (b%MOD)) % MOD;
	return (ret+MOD)%MOD;
}
 
int pow_exp(int n, int p){
	if(!p) return 1;
	if(p&1) return mul(n, pow_exp(n, p-1));
	int tmp = pow_exp(n, p/2);
	return mul(tmp, tmp);
}

int inv(int x){
	return pow_exp(x, MOD-2);
}
 
const int  MAX = 2e5 + 10;
const int NMAX = 2e5 + 10;
const int MMAX = 2e5 + 10;
const int LOG_MAX = ceil(log2(double(NMAX)));
const int BLOCK = ceil(sqrt(double(NMAX)));

int fac[NMAX], ifac[NMAX];

void init(){
	
	fac[0] = 1;
	for(int i = 1; i < NMAX; i++){
		fac[i] = mul(fac[i-1], i);
	}
	
	ifac[NMAX-1] = inv(fac[NMAX-1]);
	for(int i = NMAX-2; i >= 0; i--){
		ifac[i] = mul(ifac[i+1], i+1);
	}
}

int choose(int n, int c){
	assert(n >= c);
	return mul(fac[n], mul(ifac[c], ifac[n-c]));
}

int32_t main(){
    
    fastIO;
    
#ifdef LOCAL
    freopenI;
    freopenO;
#endif

    // freopen("name.in", "r", stdin);
    
	// init();
	
    int t; cin >> t; while(t--){

		string str;
		cin >> str;
		
		int n = str.size();
		
		int ans = 0;
		
		for(int i = 0; i+3 < n; i++){	
			if(str.substr(i, 4) == "ania"){
				ans++;
				str[i+3] = 'z';
			}
		}
		
		cout << ans << endl;
    }	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

3
aniasieurodzilaapotemnicsieniedzialo
nicciekawegouanianiagnieszkianialicji
jeszczekrotszaautobiografiaani

output:

1
2
0

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 34ms
memory: 3636kb

input:

10000
aniaanianianianiaviananibnianianianianianiapianianianianianianiaanianianianiananianianianiananifw
ananiacnganiaaywbwrkaniahaniaganiaglljaniaouaqrdyaniaypvsgjltrbcvjssrtnehqfzpfvaniahwaniauzncovwfmiqejteiuaniacblxyfikauptesitsitvananianiajndy
anianianianianianiaanianianianianiaanianianianianiaa...

output:

13
11
53
16
10
13
35
2
39
7
19
14
47
7
78
34
59
60
21
13
22
18
18
9
77
3
19
14
44
64
18
26
14
4
27
38
9
65
13
27
51
23
3
13
26
69
5
20
32
23
22
13
29
2
23
2
18
21
68
50
21
9
5
6
21
22
77
1
60
54
8
19
51
13
6
18
70
18
22
19
20
4
74
17
26
8
19
78
11
28
72
8
45
21
23
21
15
54
65
14
2
9
10
5
33
78
0
30
...

result:

ok 10000 lines

Test #3:

score: 0
Accepted
time: 57ms
memory: 3552kb

input:

335
ananianianianianianianianianianianianianianianianianianianianianianianianianianiaanianianianianianianianianianianianianianianianianianianianianianianianianianianianianianianianianianianianianianiananianianianianianianianiananianianianianianianianianianianianianianianianianianianianianianianiania...

output:

3075
476
650
443
510
2446
624
560
2256
679
3138
361
512
300
484
1726
659
559
1887
381
3048
700
507
2769
2688
615
706
631
3009
367
516
535
3150
1759
418
489
1738
2676
497
666
655
2391
547
405
677
2189
492
465
413
2008
2477
2125
2586
1788
439
2765
2781
667
279
294
523
654
414
2126
2156
2175
1855
3135
...

result:

ok 335 lines

Test #4:

score: 0
Accepted
time: 52ms
memory: 6384kb

input:

5
aanninaiiiiiaaaaaiiniaaiaaanniiaaaiiiainainananinannnaiaiiainnianaainaaiaanannnnnniaiaiainanaaniaaaainaaanaanianiininiaiiaaaaaainaniinaininniiiinaaaannnananniianaananiainiiiniinninnnainaiiiaanaananinaininiiaaanaiiininnanannannnnaiaaaniiaaniaaanaaaiinianniaiiaiinaannaanniiaininaiianaiiiniinaaiiania...

output:

15253
17190
166607
49472
166658

result:

ok 5 lines