QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#746055#5577. Alchemyi24WA 0ms3868kbC++141.5kb2024-11-14 13:10:162024-11-14 13:10:17

Judging History

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

  • [2024-11-14 13:10:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3868kb
  • [2024-11-14 13:10:16]
  • 提交

answer

// File generated on 24/11/13 20:14 by Anand

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

#define fastio ios::sync_with_stdio(false); cin.tie(0)
#define rep(i, m, n)  for (long long i = m; i < n; i++)
#define DEBUG(x) cout << "debug: " << x << "\n"
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define pb push_back
#define sz size

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vec;
typedef vector<vec> vecc;
typedef vector<pll> vecp;

void SOLVE() {
    string s;
    cin >> s;
    ll n = s.size();
    ll m = ceil(n/2.0);
    vec a(m);
    ll ans = 0;
    rep(i,0,m) 
        if (s[i] == s[n-1-i]) a[i] = 1;
    vec x;
    ll c = 0, p = a[0];
    rep(i,0,m) {
        if (a[i] == p) c++;
        else {p = a[i]; x.pb(c); c = 1;}
    }
    if (c > 0) x.pb(c);
    ll st = 0;
    if (a[0] == 1) st = 1;
    for(ll i = st; i < x.size();) {
        if (x[i]%2==0) ans += x[i]/2;
        else if (i+2 < x.size() && x[i+1] == 2 && x[i+2]%2 == 1) {ans += ((x[i] + x[i+2]) / 2 + 2); i+=2;}
        else if (i+2 < x.size() && x[i+1] == 1 && x[i+2]%2 == 1) {ans += ((x[i] + x[i+2])/2 + 1); i+=2;}
        else if (x[i] == 1 && i < x.size() - 1 && n%2 == 0) ans += 2;
        else if (x[i] == 1 && i < x.size() - 2 && n%2 == 1) ans++;
        else if (x[i] == 1) ans++;
        else ans += (x[i] - 1) / 2 + 1;
        i+=2;
    }

    cout << ans << "\n";
}

signed main() {
    fastio;

    //ll _;
    //cin >> _;

    //while(_--) 
		SOLVE();

    return 0;
}


详细

Test #1:

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

input:

ioi

output:

0

result:

ok single line: '0'

Test #2:

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

input:

noi

output:

1

result:

ok single line: '1'

Test #3:

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

input:

ctsc

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

fool

output:

2

result:

ok single line: '2'

Test #5:

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

input:

vetted

output:

2

result:

ok single line: '2'

Test #6:

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

input:

aa

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

ic

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

tlffohemdcncrfrxaqsbzcoyodvbxmhqukvfpahnakexcmacqa

output:

12

result:

ok single line: '12'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

qrgld

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

ejyfprguvwrnrsrykyrotmdjuzroohvlxqhvyeukkvmshtpczyyecpzhsqvkxueqvhlxldhofrzcjdhtotykgrsdnrnvuyrphyjy

output:

26

result:

ok single line: '26'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

xcpccpcy

output:

2

result:

ok single line: '2'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

abpccpcp

output:

1

result:

ok single line: '1'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

ixpccpci

output:

2

result:

ok single line: '2'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

xcxccpci

output:

2

result:

ok single line: '2'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

xcpxcpci

output:

3

result:

ok single line: '3'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

ixxccpci

output:

1

result:

ok single line: '1'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

ixpxcpci

output:

2

result:

ok single line: '2'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

ixpxxycpci

output:

3

result:

ok single line: '3'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

yxxxyxxxxxyyxxyxxyxyyyxyxyyyyxyxxxxxxxxxxxxyyxxyxyxyyxxyyxyxxyyxxyyyyyyxxyyxxyyxxxxyyyxxxyyxyxyxxyxx

output:

19

result:

ok single line: '19'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

caacbbacc

output:

2

result:

ok single line: '2'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

xjnfkxxjfnjx

output:

2

result:

ok single line: '2'

Test #22:

score: -100
Wrong Answer
time: 0ms
memory: 3640kb

input:

baabaaa

output:

1

result:

wrong answer 1st lines differ - expected: '2', found: '1'