QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#510947#7841. Boat Commuter11131241WA 7ms5656kbC++172.1kb2024-08-09 14:28:482024-08-09 14:28:49

Judging History

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

  • [2024-08-09 14:28:49]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:5656kb
  • [2024-08-09 14:28:48]
  • 提交

answer

#include<bits/stdc++.h>
#include <unordered_map>
#include<cstdint>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MAXN ((int) 2e5)
#define endl '\n'
#define yes "Yes"
#define no "No"
const int maxx = 100;
const int N = 1e5 + 5;
const int M = 5e4 + 10;
typedef long long ll;
typedef double db;
typedef pair<int, int>pii;
typedef pair<long, long>pll;
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int mod = 1e9 + 7;
inline long long read()
{
	long long w = 1;
	long long q = 0;
	char ch = ' ';
	while (ch != '-' && (ch < '0' || ch>'9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9')
		q = q * 10 + ch - '0', ch = getchar();
	return w * q;
}
void exgcd(int a, int p, int& x, int& y)
{
	if (!p) x = 1, y = 0;
	else exgcd(p, a % p, y, x), y -= a / p * x;
}

//bool flag[maxx];线性筛
//int prime[maxx], p;
//void primes(int n)
//{
//	flag[1] = true;
//	for (int i = 2; i <= n; i++)
//	{
//		if (!flag[i])
//			prime[p++] = i;
//		for (int j = 0; prime[j] * i <= n; j++)
//		{
//			flag[prime[j] * i] = true;
//			if (i % prime[j] == 0) break;
//		}
//	}
//}
struct node {
	int st;
	int flag = 1;
	int ed;
	int num;
	int k;
	
}arr[N];

void solve()
{
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 1; i <= k; i++)
	{
		int x, y;
		cin >> x >> y;
		if (arr[y].flag == 1)
			arr[y].st = x, arr[y].flag = 0,arr[y].num++;
		else arr[y].ed = x,arr[y].num++;
	}
	for (int i = 1; i <= m-1; i++)
	{
		if (arr[i].st == arr[i].ed)
		{
			cout << 100 << " ";
			continue;
		}
		else if (arr[i].num == 0)
		{
			cout << 0 << " ";
			continue;
		}
		else if (arr[i].num == 1)
		{
			cout << 100 << " ";
			continue;
		}
		else cout << abs(arr[i].st - arr[i].ed)<<" ";
	}
	if (arr[m].st == arr[m].ed)
	{
		cout << 100;
	}
	else if (arr[m].num == 0)
	{
		cout << 0 ;
		
	}
	else if (arr[m].num == 1)
	{
		cout << 100 ;
		
	}
	else cout << abs(arr[m].st - arr[m].ed);

	
}
int main()
{
	IOS;
	int tcase = 1;
	//cin >> tcase;
	while (tcase--)
		solve();
	return 0;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5580kb

input:

3 3 5
1 1
1 2
1 2
3 1
2 3

output:

2 100 100

result:

ok single line: '2 100 100'

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 5656kb

input:

50 10 100000
16 6
7 1
18 1
39 3
30 3
27 5
27 1
25 8
8 4
30 5
48 10
20 1
25 9
40 1
1 8
15 6
24 5
49 9
46 1
42 8
35 4
47 4
28 6
16 7
46 9
30 9
32 8
8 7
40 5
29 10
48 6
42 2
25 8
16 5
41 6
23 7
40 10
33 9
50 8
13 9
41 3
27 5
38 6
7 3
46 10
26 4
33 5
31 9
27 7
50 10
37 5
9 6
30 2
7 8
27 4
20 9
25 4
47 9...

output:

1 12 37 32 5 3 21 3 18 5

result:

wrong answer 1st lines differ - expected: '94844 94854 93814 91551 95910 91226 92395 94770 92170 93178', found: '1 12 37 32 5 3 21 3 18 5'