QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#403444#6749. Targetccsu_zx#WA 2ms5128kbC++141.3kb2024-05-02 13:15:472024-05-02 13:15:48

Judging History

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

  • [2024-05-02 13:15:48]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5128kb
  • [2024-05-02 13:15:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int mod = 998244353;
const int N = 1e5+10;
int dis[N];
int p[N];
int path[N];

void solve() {
//	string sa, sb;
	double sa, sb;
	int a = 0, b = 0;
	int i, j;
	cin>>sa>>sb;
//	if (sa.size() == 1) {
//		a = sa[0];
//		i = 2;	
//	}
//	else {
//		for (i = 2; i < sa.size(); i++) {
//			a = a*10 + sa[i]-'0';
//		}
//	}
//	while (i < sb.size()) {
//		a = a*10;
//		i++;
//	}
//	
//	if (sb.size() == 1) {	
//		b = sb[0];
//		i = 2;
//	} else {
//		for (i = 2; i < sb.size(); i++) {
//			b = b*10 + sb[i]-'0';
//		}
//	}
//	while (i < sa.size()) {
//		b = b*10;
//		i++;
//	}
	a = sa*1e5, b = sb*1e5; 
//	printf("a = %d, b=  %d\n", a, b);
	memset(dis, -1, sizeof(dis));
	queue<int> q;
	q.push(a);
	dis[a] = 0;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
//		printf("u = %d\n", u);
		int v = u/2;
		if (dis[v] == -1) {
			p[v] = u;
			path[v] = 1;
			dis[v] = dis[u]+1;
			q.push(v);
		}
		
		v = u/2 + 0.5*1e5;
		if (dis[v] == -1) {
			p[v] = u;
			path[v] = 2;
			dis[v] = dis[u]+1;
			q.push(v);
		}
	}
	while (b != a) {
//		printf("b = %d\n", b);
		cout<<path[b];
		b = p[b];
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
//	cin>>T;
	while (T--) {
		solve();
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 5128kb

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 5024kb

input:

1 0.75

output:

21

result:

wrong answer wa