QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#496449 | #1289. A + B Problem | rollerZ | WA | 1ms | 5928kb | C++23 | 1.7kb | 2024-07-28 10:31:53 | 2024-07-28 10:31:53 |
Judging History
answer
#include <bits/stdc++.h>
#define pii pair<int, int>
#define fi first
#define se second
#define MP make_pair
#define ep emplace
#define eb emplace_back
//#define int long long
#define rep(i, j, k) for (int i = j; i <= k; i++)
#define per(i, j, k) for (int i = j; i >= k; i--)
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef __int128 lll;
typedef unsigned long long ull;
typedef unsigned int ui;
using namespace std;
int read() {
int s = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') f ^= (c == '-'), c = getchar();
while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
return f ? s : -s;
}
int n,m,s[200005],a[100005],b[100005],pos[200005],id[200005],ans[100005],tot;
signed main() {
for(int T=read();T--;){
n=read(),m=read();
int nn=n,mm=m,top=0;tot=0;
rep(i,1,n+m)scanf("%1d",&s[i]);
rep(i,1,max(n,m))a[i]=b[i]=0;
rep(i,1,n+m)if(s[i])++top,id[pos[top]=i]=top;
rep(i,1,n+m)printf("id[%d]=%d\n",i,id[i]);
rep(i,1,nn+mm){
printf("(%d %d)\n",n,m);
if(!n||!m){
if(!n)b[m--]=s[i];
if(!m)a[n--]=s[i];
continue;
}
if(s[i]){
if(n<m){
if(pos[id[i]+m-n]&&nn+mm-pos[id[i]+m-n]+m-n>=m)a[n--]=1;
else b[m--]=1;
}else{
if(pos[id[i]+n-m]&&nn+mm-pos[id[i]+n-m]+n-m>=n)b[m--]=1;
else a[n--]=1;
}
}else{
if(n<m)n--;
else m--;
}
}
n=nn,m=mm;
int j=0;
rep(i,1,max(n,m)){
ans[++tot]=(a[i]^b[i]^j)&1;
j=(a[i]+b[i]+j)>>1;
}
if(j)ans[++tot]=1;
bool flag=1;
per(i,tot,1){
flag&=!ans[i];
if(!flag)putchar(ans[i]+'0');
}
if(flag)putchar('0');
putchar('\n');
rep(i,1,top)pos[i]=id[pos[i]]=0;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5928kb
input:
3 4 3 1000101 2 2 1111 1 1 00
output:
id[1]=1 id[2]=0 id[3]=0 id[4]=0 id[5]=2 id[6]=0 id[7]=3 (4 3) (3 3) (3 2) (3 1) (3 0) (2 0) (1 0) 1101 id[1]=1 id[2]=2 id[3]=3 id[4]=4 (2 2) (2 1) (2 0) (1 0) 110 id[1]=0 id[2]=0 (1 1) (1 0) 0
result:
wrong answer 1st lines differ - expected: '1101', found: 'id[1]=1'