QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745992 | #5577. Alchemy | i24 | WA | 0ms | 3784kb | C++14 | 1.3kb | 2024-11-14 12:52:05 | 2024-11-14 12:52:06 |
Judging History
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)+1;
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 = 0;}
}
if (c > 0) x.pb(c);
ll st = 0;
if (a[0] == 1) st = 1;
rep(i, st, x.size()) {
if (x[i]%2==0) ans += x[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) ans += 2;
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: 3632kb
input:
ioi
output:
0
result:
ok single line: '0'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3784kb
input:
noi
output:
2
result:
wrong answer 1st lines differ - expected: '1', found: '2'