QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88576#5501. Ctrl+C Ctrl+VJerryBlack#AC ✓18ms6392kbC++179.6kb2023-03-16 15:56:432023-03-16 15:56:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-16 15:56:44]
  • 评测
  • 测评结果:AC
  • 用时:18ms
  • 内存:6392kb
  • [2023-03-16 15:56:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast,unroll-loops")

#define DECIMAL 6
namespace fastIO
{
#ifdef LOCAL
#define DEBUG
#endif
#define BUF_SIZE 100000
#define LL long long
    static bool IOerror=false;
#ifdef DEBUG
    inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;}
#else
    inline char nc(){static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;if(p1==pend){p1=buf;pend=buf+fread(buf,1,BUF_SIZE,stdin);if(pend==p1){IOerror=true;return -1;}}return *p1++;}
#endif
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    template<class T> inline bool read(T&x){bool sign=false;char ch=nc();x=0;for(;blank(ch);ch=nc());if(IOerror)return false;if(ch=='-')sign=true,ch=nc();for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';if(sign)x=-x;return true;}
    inline bool read(unsigned long long&x){char ch=nc();x=0;for(;blank(ch);ch=nc());if(IOerror)return false;for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';return true;}
    inline bool read(unsigned int&x){char ch=nc();x=0;for(;blank(ch);ch=nc());if(IOerror)return false;for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';return true;}
    inline bool read(double&x){bool sign=false;char ch=nc();x=0;for(;blank(ch);ch=nc());if(IOerror)return false;if(ch=='-')sign=true,ch=nc();for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';if(ch=='.'){double tmp=1;ch=nc();for(;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');}if(sign)x=-x;return true;}
    inline bool read(char*s){char ch=nc();for(;blank(ch);ch=nc());if(IOerror)return false;for(;!blank(ch)&&!IOerror;ch=nc())*s++=ch;*s=0;return true;}
    inline bool read(char&c){for(c=nc();blank(c);c=nc());if(IOerror){c=-1;return false;}return true;}
    inline bool read(std::string&s){s.clear();char ch=nc();for(;blank(ch);ch=nc());if(IOerror)return false;for(;!blank(ch)&&!IOerror;ch=nc())s+=ch;return true;}
    template<class T,class... U> bool read(T&h,U&... t){return read(h)&&read(t...);}
    struct Ostream_fwrite
    {
#ifdef DEBUG
        inline void out(char ch) { putchar(ch); }
#else
        char*buf,*p1,*pend;
        Ostream_fwrite(){buf=new char[BUF_SIZE];p1=buf;pend=buf+BUF_SIZE;}
        inline void out(char ch){if(p1==pend){fwrite(buf,1,BUF_SIZE,stdout);p1=buf;}*p1++=ch;}
#endif
        template<class T> inline void print(T x){static char s[41],*s1;s1=s;if(!x)*s1++='0';if(x<0)out('-'),x=-x;while(x)*s1++=x%10+'0',x/=10;while(s1--!=s)out(*s1);}
        inline void print(char ch){out(ch);}
        inline void print(unsigned long long x){static char s[41],*s1;s1=s;if(!x)*s1++='0';while(x)*s1++=x%10+'0',x/=10;while(s1--!=s)out(*s1);}
        inline void print(unsigned int x){static char s[41],*s1;s1=s;if(!x)*s1++='0';while(x)*s1++=x%10+'0',x/=10;while(s1--!=s)out(*s1);}
        inline void print(double x,int y=DECIMAL){static LL mul[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000LL,100000000000LL,1000000000000LL,10000000000000LL,100000000000000LL,1000000000000000LL,10000000000000000LL,100000000000000000LL};if(x<-1e-12)out('-'),x=-x;x*=mul[y];LL x1=(LL)floor(x);if(x-floor(x)>=0.5)++x1;LL x2=x1/mul[y],x3=x1-x2*mul[y];print(x2);if(y>0){out('.');for(size_t i=1;i<y&&x3*mul[i]<mul[y];out('0'),++i);print(x3);}}
        inline void print(char*s){while(*s)out(*s++);}
        inline void print(const char*s){while(*s)out(*s++);}
        inline void print(std::string s){print(s.c_str());}
#ifndef DEBUG
        inline void flush(){if(p1!=buf){fwrite(buf,1,p1-buf,stdout);p1=buf;}}
        ~Ostream_fwrite(){flush();}
#endif // !DEBUG
    }Ostream;
    template<class T> inline void print(T x){Ostream.print(x);}
    template<class T> inline void println(T x){Ostream.print(x);Ostream.out('\n');}
    inline void print(double x,int y=DECIMAL){Ostream.print(x,y);}
    inline void println(double x,int y=DECIMAL){Ostream.print(x,y);Ostream.out('\n');}
    template<class T,class... U> void print(const T&h,const U&... t){print(h);Ostream.out(' ');print(t...);}
    template<class T,class... U> void println(const T&h,const U&... t){print(h);Ostream.out(' ');println(t...);}
#ifndef DEBUG
    inline void flush(){Ostream.flush();}
#endif
#undef LL
#undef DECIMAL
#undef BUF_SIZE
    //本地 getchar/putchar ,提交 fread/fwrite
    //本地支持终端交互输入输出
}
using namespace fastIO;

#define ll long long
#define ull unsigned ll
#define fi first
#define se second
const double eps=1e-9;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
mt19937 rnd(time(0));

int P=1e9+9;
namespace modint
{
    int norm(int x){if(x<0)x+=P;if(x>=P)x-=P;return x;}
    template<class T>
    T power(T a,ll n){T ans=1;while(n){if(n&1)ans=ans*a;a=a*a;n>>=1;}return ans;}
    struct Z
    {
        int x;
        Z(int x=0):x(norm(x)){}
        Z(ll x):x(norm(x%P)){}
        int val() const{return x;}
        Z operator-() const{return Z(norm(P-x));}
        Z inv() const{assert(x!=0);return power(*this,P-2);}
        Z&operator*=(const Z&rhs){x=(ll)x*rhs.x%P;return *this;}
        Z&operator+=(const Z&rhs){x=norm(x+rhs.x);return *this;}
        Z&operator-=(const Z&rhs){x=norm(x-rhs.x);return *this;}
        Z&operator/=(const Z&rhs){return *this*=rhs.inv();}
        friend Z operator*(const Z&lhs,const Z&rhs){Z res=lhs;res*=rhs;return res;}
        friend Z operator+(const Z&lhs,const Z&rhs){Z res=lhs;res+=rhs;return res;}
        friend Z operator-(const Z&lhs,const Z&rhs){Z res=lhs;res-=rhs;return res;}
        friend Z operator/(const Z&lhs,const Z&rhs){Z res=lhs;res/=rhs;return res;}
        friend istream&operator>>(istream&is,Z&a){ll v;is>>v;a=Z(v);return is;}
        friend ostream&operator<<(ostream&os,const Z&a){return os<<a.val();}
    };
}
using namespace modint;

#define int ll



void solve()
{
    string s;
    cin>>s;
    int ans=0;
    int n=s.size();
    char pre=' ';
    for(int i=0;i<n;i++)
    {
        int cnt=0;
        int j=i;
        int ck=0;
        while(j<n)
        {
            if(pre==' '&&s[j]=='a')pre=s[j],j++,ck=1;
            else if(pre=='a'&&s[j]=='n')pre=s[j],j++;
            else if(pre=='n'&&s[j]=='i')pre=s[j],j++;
            else if(pre=='i'&&s[j]=='a')pre=s[j],j++,cnt++;
            else break;
        }
        ans+=cnt/2+cnt%2;
        pre=' ';
        if(ck)i=j-1;
        else i=j;
//        cout<<"i="<<i<<" j="<<j<<'\n';
//        cout.flush();
    }
    cout<<ans<<'\n';
}



#undef int

int main()
{
    ios::sync_with_stdio(false);cin.tie(nullptr);
    cout<<fixed<<setprecision(15);

	int _;cin>>_;while(_--)
    {
        solve();
    }
    return 0;
}
/* ┌───┐   ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┐ ┌───┬───┬───┬───┐
 * │Esc│   │ F1│ F2│ F3│ F4│ │ F5│ F6│ F7│ F8│ │ F9│F10│F11│F12│ │P/S│S/L│P/B│ │Cal│   │   │   │
 * └───┘   └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┘ └───┴───┴───┴───┘
 * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┬───┬───┐ ┌───┬───┬───┬───┐
 * │~ `│! 1│@ 2│# 3│$ 4│% 5│^ 6│& 7│* 8│( 9│) 0│_ -│+ =│ BacSp │ │Ins│Hom│PUp│ │Num│ / │ * │ - │
 * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┼───┼───┤ ├───┼───┼───┼───┤
 * │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │{ [│} ]│ | \ │ │Del│End│PDn│ │ 7 │ 8 │ 9 │   │
 * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ └───┴───┴───┘ ├───┼───┼───┤ + │
 * │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │: ;│" '│  Enter │               │ 4 │ 5 │ 6 │   │
 * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤     ┌───┐     ├───┼───┼───┼───┤
 * │  Shift │ Z │ X │ C │ V │ B │ N │ M │< ,│> .│? /│   Shift  │     │ ↑ │     │ 1 │ 2 │ 3 │   │
 * ├─────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ ┌───┼───┼───┐ ├───┴───┼───┤ E││
 * │ Ctrl│ Win│ Alt│         Space         │ Alt│ Win│ Fn │Ctrl│ │ ← │ ↓ │ → │ │   0   │ . │←─┘│
 * └─────┴────┴────┴───────────────────────┴────┴────┴────┴────┘ └───┴───┴───┘ └───────┴───┴───┘
 */

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3420kb

input:

3
aniasieurodzilaapotemnicsieniedzialo
nicciekawegouanianiagnieszkianialicji
jeszczekrotszaautobiografiaani

output:

1
2
0

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 13ms
memory: 3396kb

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: 13ms
memory: 3488kb

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: 18ms
memory: 6392kb

input:

5
aanninaiiiiiaaaaaiiniaaiaaanniiaaaiiiainainananinannnaiaiiainnianaainaaiaanannnnnniaiaiainanaaniaaaainaaanaanianiininiaiiaaaaaainaniinaininniiiinaaaannnananniianaananiainiiiniinninnnainaiiiaanaananinaininiiaaanaiiininnanannannnnaiaaaniiaaniaaanaaaiinianniaiiaiinaannaanniiaininaiianaiiiniinaaiiania...

output:

15253
17190
166607
49472
166658

result:

ok 5 lines