QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#755804 | #9565. Birthday Gift | Alucard | WA | 5ms | 3656kb | C++14 | 1.8kb | 2024-11-16 18:04:09 | 2024-11-16 18:04:11 |
Judging History
answer
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define i128 _int128
#define fi first
#define se second
#define pb push_back
#define endl '\n'
//#define int long long
const ll INF=0x3f3f3f3f;
const int N=1e9,M=1e9+9;
const ll mod=998244353;
int read(){
int s=0,w=1;
char c=getchar();
while(!isdigit(c)) (c=='-')?w=-1:w=1,c=getchar();
while(isdigit(c)) s=(s<<1)+(s<<3)+(c^48),c=getchar();
return s*w;
}
int qpow(int a,int b){
a%=mod;
int res=1;
while(b){
if(b&1){res=(res*a)%mod;}
a=(a*a)%mod;
b>>=1;
}
return res%mod;
}
// int inverse(int a){
// a%=mod;
// return qpow(fac[a%mod],mod-2)%mod;
// }
// int C(int n,int r){
// n%=mod,r%=mod;
// if(r>n)return 0;
// return ((fac[n%mod]*inverse(r))%mod*inverse(n-r))%mod;
// }
// int Lucas(int n,int r){
// if(r==0)return 1;
// return C(n%mod,r%mod)%mod*Lucas(n/mod,r/mod)%mod;
// }
string s;
int a,b,c;
void solve(){
cin>>s;a=b=c=0;
for(int i=0;i<s.size();++i){
if(!i&1){
if(s[i]=='0')a++;
else if(s[i]=='1')b++;
else c++;
}
else{
if(s[i]=='0')b++;
else if(s[i]=='1')a++;
else c++;
}
}
//cout<<a<<' '<<b<<' '<<c<<endl;
if(a==b)cout<<a+b-c<<endl;
else cout<<abs(a-b)-c<<endl;
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int _=1;
// fac[0]=1;
// for(int i=1;i<=N-9;++i)fac[i]=(fac[i-1]*i)%mod;
cin>>_;
while(_--)solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
input:
5 0110101 01020102 0000021111 1012121010 0100202010
output:
3 4 0 6 0
result:
ok 5 number(s): "3 4 0 6 0"
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 3656kb
input:
50000 1010110101 1010101010 0101010101 0101010010 0101010010 1010101010 0101001010 1010010010 0100101010 1010101001 1010100101 0101010100 0100101011 0101101010 1011010110 1011010101 1010010101 1010010010 0101010101 0010101010 0101011010 0100101010 1010101010 1010010101 1010101101 1101010101 10100101...
output:
10 2 2 10 10 2 10 4 10 2 2 10 2 2 10 10 2 4 2 10 2 10 2 2 10 10 2 10 10 10 10 10 4 2 4 10 10 2 2 2 2 2 10 2 10 2 10 2 2 2 10 2 4 2 10 10 4 10 10 2 10 10 2 2 4 2 4 2 2 2 2 2 2 10 2 10 2 4 10 10 10 2 10 2 10 2 2 2 2 10 2 10 2 10 2 2 2 2 2 2 2 2 10 2 2 2 2 2 10 2 2 2 2 10 10 2 2 2 2 2 10 2 2 10 2 10 2 ...
result:
wrong answer 1st numbers differ - expected: '0', found: '10'