QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#536424#8058. Binary vs Ternaryucup-team3591#WA 0ms1616kbC++141.4kb2024-08-29 11:41:592024-08-29 11:42:00

Judging History

你现在查看的是最新测评结果

  • [2024-08-29 11:42:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1616kb
  • [2024-08-29 11:41:59]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline ll read(){
	ll x=0;
	int f=0,ch=0;
	while(ch<48||ch>57) f=(ch=='-'),ch=getchar();
	while(ch>47&&ch<58) x=(x<<3)+(x<<1)+(ch&15),ch=getchar();
	return f?-x:x;
}
inline void write(ll x,char end='\n'){
	if(x==0){
		putchar('0');
		putchar(end);
		return;
	}
	if(x<0) putchar('-'),x=-x;
	int ch[40]={0},cnt=0;
	while(x){
		ch[cnt++]=(int)(x%10);
		x/=10;
	}
	while(cnt--) putchar(ch[cnt]+48);
	putchar(end);
}
const int N=72;
#define mp make_pair
#define pii pair<int,int>
char a[N],b[N];
int ans;
pii plan[N<<3];
inline void solve(){
	scanf("%s%s",a+1,b+1);
	int n=strlen(a+1),m=strlen(b+1);
	if(n==1||m==1){
		if(n==m) puts("0");
		else puts("-1");
		return;
	}
	ans=0;
	for(int i=1;i<n;++i){
		if(a[i+1]=='0'){
			a[i+1]='1';
			plan[++ans]=mp(i,i+1);
		}
	}
	while(n<m){
		plan[++ans]=mp(1,2);
		plan[++ans]=mp(1,2);
		plan[++ans]=mp(2,3);
		++n;
	}
	while(n>m){
		plan[++ans]=mp(2,3);
		plan[++ans]=mp(2,4);
		plan[++ans]=mp(2,3);
		plan[++ans]=mp(2,4);
		plan[++ans]=mp(1,2);
		--n; 
	}
	for(int i=1;i<=n;++i) a[i]='1';
	for(int i=1;i<n;++i){
		if(b[i+1]=='0'){
			plan[++ans]=mp(i,i+1);
			plan[++ans]=mp(i+1,i+2);
		}
	}
	write(ans,'\n');
	for(int i=1;i<=ans;++i)
		printf("%d %d\n",plan[i].first,plan[i].second);
}
int main(){
	int T=read();
	while(T--) solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 1616kb

input:

3
1
111
110110
1101010
1111
111111

output:

-1
11
2 3
5 6
1 2
1 2
2 3
2 3
3 4
4 5
5 6
6 7
7 8
6
1 2
1 2
2 3
1 2
1 2
2 3

result:

ok Haitang Suki (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 1612kb

input:

1000
11100
111
1
11110
10001
10
1011
1111
10
1110
1100
11
11010
11
110
11
1
10001
10110
10
10
11111
10000
1001
10
1
11
10111
11
10
1
100
11
10100
1
10
101
11
1100
110
11
1110
1
1001
1
11111
10
10010
10
11001
110
1010
10011
1110
10100
1001
1001
101
100
1
1001
11
101
11
101
1001
1
1
1011
1
10
10
1011
...

output:

12
3 4
4 5
2 3
2 4
2 3
2 4
1 2
2 3
2 4
2 3
2 4
1 2
-1
20
1 2
2 3
3 4
2 3
2 4
2 3
2 4
1 2
2 3
2 4
2 3
2 4
1 2
2 3
2 4
2 3
2 4
1 2
1 2
2 3
1
1 2
9
1 2
1 2
1 2
2 3
1 2
1 2
2 3
3 4
4 5
12
2 3
3 4
2 3
2 4
2 3
2 4
1 2
2 3
2 4
2 3
2 4
1 2
17
2 3
4 5
2 3
2 4
2 3
2 4
1 2
2 3
2 4
2 3
2 4
1 2
2 3
2 4
2 3
2 4
1...

result:

wrong answer S!=T after all operations (test case 1)