QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#261618#4423. AMPPZ in the times of diseaseoogerboogerWA 1998ms6304kbC++143.1kb2023-11-23 03:28:202023-11-23 03:28:21

Judging History

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

  • [2023-11-23 03:28:21]
  • 评测
  • 测评结果:WA
  • 用时:1998ms
  • 内存:6304kb
  • [2023-11-23 03:28:20]
  • 提交

answer

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define INF 1000000000
#define INFl 1000000000000000000
#define all(x) x.begin(), x.end()
#define sajz(x) (int)x.size()
#define pb push_back
#define se second
#define fi first
#define yes puts("YES")
#define no puts("NO")
#define erase_duplicates(x) {sort(all(x));(x).resize(distance((x).begin(), unique(all(x))));}
using namespace std;
//using namespace __gnu_pbds;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int ll

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef multiset<int> msi;
typedef long double ld;
//typedef cc_hash_table<int, int, hash<int>> ht;

void test_case() {
	int n, k;
	cin >> n >> k;

	vi x(n), y(n), grupa(n);

	for (int i = 0; i < n; i ++) {
		cin >> x[i] >> y[i];
	}

	grupa[0] = 1;
	vi mini(n);

	for (int i = 0; i < n; i ++) {
		mini[i] = llabs(x[i]-x[0])+llabs(y[i]-y[0]);
	}

	vi Kapitan;
	Kapitan.pb(0);

	for (int g = 2; g <= k; g ++) {
		int best = -1, ile = 0;
		for (int i = 0; i < n; i ++) {
			if (grupa[i]) continue;
			if (ile < mini[i]) {
				ile = mini[i];
				best = i;
			}
		}

		assert(best != -1);
		grupa[best] = g;

		for (int i = 0; i < n; i ++) {
			mini[i] = min(mini[i], llabs(x[i]-x[best])+llabs(y[i]-y[best]));
		}
		Kapitan.pb(best);
	}

	for (int i = 0; i < n; i ++) {
		if (!grupa[i]) {
			int best = -1, ile = INFl;
			for (auto K : Kapitan) {
				int odl = llabs(x[K]-x[i]) + llabs(y[K]-y[i]);
				if (odl < ile) {
					ile = odl;
					best = K;
				}
			}
			assert(best != -1);
			grupa[i] = grupa[best];
		}
	}

	for (int i = 0; i < n; i ++) cout << grupa[i] << ' ';
	cout << '\n';
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	int t=1;
	cin >> t;
	for (int i = 1; i <= t; i ++) {
		test_case();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1998ms
memory: 6304kb

input:

100
100000 20
270505 510725
245104 76414
131477 992924
781607 895592
562469 622976
564354 637966
980036 112090
522903 687218
113871 977855
6615 123673
13847 347618
657794 165707
420561 183995
11367 136391
507836 694877
985069 105115
774110 486921
14319 338715
774937 118145
981468 99089
803866 491315...

output:

1 9 5 3 19 19 2 8 5 4 11 17 6 4 8 2 7 11 10 2 7 17 15 3 13 1 6 16 15 19 9 17 14 13 16 3 10 6 3 14 14 11 9 1 19 15 1 20 7 20 15 20 17 15 15 18 4 1 4 15 15 10 18 11 3 6 10 16 13 10 14 17 16 13 4 17 10 7 18 12 3 2 5 7 5 11 6 13 20 7 9 19 19 15 15 3 7 13 2 15 7 1 4 1 4 15 4 6 10 7 13 14 15 13 8 20 19 15...

result:

wrong answer wrong solution (test case 12)