QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#719650 | #5577. Alchemy | nickbelov# | WA | 0ms | 3544kb | C++20 | 3.2kb | 2024-11-07 06:32:36 | 2024-11-07 06:32:37 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
ostream_iterator<T> oit(const string &s = " "){ return ostream_iterator<T>(cout,s.c_str()); }
inline auto rep(int l, int r) { return views::iota(min(l, r), r); }
inline auto rep(int n) { return rep(0, n); }
inline auto rep1(int l, int r) { return rep(l, r + 1); }
inline auto rep1(int n) { return rep(1, n + 1); }
inline auto per(int l, int r) { return rep(l, r) | views::reverse; }
inline auto per(int n) { return per(0, n); }
inline auto per1(int l, int r) { return per(l, r + 1); }
inline auto per1(int n) { return per(1, n + 1); }
#define A(a) begin(a),end(a)
inline auto len = ranges::ssize;
struct chash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
template<typename T, typename U> using pb_map = gp_hash_table<T, U, chash>;
template<typename T> using pb_set = gp_hash_table<T, null_type, chash>;
#define K first
#define V second
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
typedef vector<ll> vll;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
constexpr ll NN = 2e5, M = 1000000007, L = 20;
ll f1[NN], f2[NN];
ll inv(ll a, ll b=M) { return 1 < a ? b - inv(b % a, a) * b / a : 1; } // inv a mod b
ll choose(ll n, ll k) { return f1[n] * f2[k] % M * f2[n - k] % M; } // n choose k
void run()
{
string s; cin >> s; int n = len(s); int odd = n%2;
string a = s.substr(0,n/2);
string b = s.substr(n/2 + n%2);
ranges::reverse(a);
assert(len(a)==len(b));
n = len(a);
int ans = 0;
//compute the lengths of the runs that are neq
//we care about their parity
//consider the first one as even
//then do +1 for every odd
//minus one for pairs of adjacent odds
//bang ?
bool first_flag = false;
vector<ll> runs;
ll ln = 0;
for(int i : rep(n)){
if(a[i]!=b[i]){
ln++;
if(i==0) first_flag=true;
} else if(ln){
runs.push_back(ln);
}
} if(ln) runs.push_back(ln);
int sz = len(runs);
for(ll i : rep(sz)){
ll x = runs[i];
if(x%2 == 0 or (!i and first_flag)) ans += x/2;
else{
ans += x/2 + x%2;
if(!(i==0 and first_flag)) ans++; //cuz the very first one isnt odd ? lol ?
}
}
for(int i : rep(1,sz)){
if(runs[i]%2 and (runs[i-1]%2)){
if(i==1 and first_flag) continue; //?
ans--;
runs[i]=0;
}
}
cout << ans << '\n';
}
int main()
{
//KING OF THE WORLD...... U.W.T.B
cin.tie(0);
ios_base::sync_with_stdio(false);
run();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3472kb
input:
ioi
output:
0
result:
ok single line: '0'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3544kb
input:
noi
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'