QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#762033 | #9565. Birthday Gift | HaijieTan | WA | 0ms | 3556kb | C++23 | 2.1kb | 2024-11-19 12:45:54 | 2024-11-19 12:45:54 |
Judging History
answer
#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
#include<cmath>
#include<queue>
#include<numeric>//iota -- iota(all(a), x) a从头到尾从x开始递增
#include<cstring>
#include<ctime>
#include<array>
#include<list>
#include<random>
#include<tuple>
#include<deque>
#include<map>
#include<stack>
#include<set>
using namespace std;
template <typename Dtype>
unsigned int __builtin_popcount(Dtype u)
{
u = (u & 0x55555555) + ((u >> 1) & 0x55555555);
u = (u & 0x33333333) + ((u >> 2) & 0x33333333);
u = (u & 0x0F0F0F0F) + ((u >> 4) & 0x0F0F0F0F);
u = (u & 0x00FF00FF) + ((u >> 8) & 0x00FF00FF);
u = (u & 0x0000FFFF) + ((u >> 16) & 0x0000FFFF);
return u;
}//wishchin!!!
#define IOS ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define int long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define lowbit(x) (x & (-x))
const int xy[][2] = { 0,1, 0, -1, 1, 0, -1, 0 };
#define mem(a, x) memset(a, x, sizeof a)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<char, char> PCC;
typedef pair<int, char> PIC;
typedef pair<char, int> PCI;
#define x first
#define y second
#define NO cout << "NO\n"
#define YES cout << "YES\n"
inline int read();
const int INF = 0x3f3f3f3f, N = 1e6 + 10, MOD = 1e9 + 7, M = 1e4 + 10, K = 131;
const double PI = acos(-1.0);
void solve() {
string s; cin >> s;
vector<int>a(3, 0);
for (int i = 1; i < s.size(); i += 2)
if (s[i] != '2')
s[i] ^= 1;
for (int i = 0; i < s.size(); i++)a[s[i] - '0']++;
int t = abs(a[1] - a[0]);
int ans = t + a[2];
if (a[2] >= t) {
a[2] -= t;
}
ans -= a[2] * 2;
cout << max(0ll,ans) << endl;
}
signed main() {
IOS;
int _ = 1;
cin >> _;
while (_--)solve();
return 0;
}
inline int read()
{
int x = 0, f = 1; char ch = getchar();
while (ch < '0' || ch>'9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
return x * f;
}
/* /\_/\
* (= ._.)
* / > \>
*/
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3556kb
input:
5 0110101 01020102 0000021111 1012121010 0100202010
output:
3 4 2 6 4
result:
wrong answer 3rd numbers differ - expected: '0', found: '2'