Submission #2296595


Source Code Expand

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

namespace NOIP2018 {

template <typename T> inline void vocanese(T& lin_toto) {
    T kkksc03 = 1;
    lin_toto = 0;
    char zcysky;
    for(zcysky = getchar(); !isdigit(zcysky) && zcysky != '-'; zcysky = getchar());
    if (zcysky == '-') { kkksc03 = -1; zcysky = getchar(); }
    for(; isdigit(zcysky); zcysky = getchar()) lin_toto = lin_toto * 10 + (zcysky ^ 48);
    lin_toto *= kkksc03;
    return;
}

struct node {
	int begin, end, val;
};

vector<node> lty;
int father<:20:>;

inline bool cmp(const node& a, const node& b) {
	return a.val < b.val;
}

inline int find(int x) {
	if (father<:x:> == x)
		return x;
	return father<:x:> = find(father<:x:>);
}

inline void bin(int f1, int f2) {
	if (f1 != f2)
		father<:f2:> = f1;
	return;
}

int main() {
	int n;
	vocanese(n);
	for(int i = 1; i <= n; i++)
		father<:i:> = i;
	for(int i = 1; i < n; i++) {
		for(int j = i + 1; j <= n; j++) {
			int tmp;
			vocanese(tmp);
			lty.push_back((node){ i, j, tmp });
		}
	}
	sort(lty.begin(), lty.end(), cmp);
	int ans = 0;
	int tot = 0;
	for(vector<node>::iterator it = lty.begin(); it != lty.end(); it++) {
		if (father<:it->begin:> != father<:it->end:>) {
			int r1 = find(it->begin);
			int r2 = find(it->end);
			if (r1 != r2) {
				bin(r1, r2);
				tot++;
				ans += it->val;
			}
		}
	}
	printf("%d %d\n", tot, ans);
	return 0;
}

}

int main() { return NOIP2018::main(); }

Submission Info

Submission Time
Task A - 特別作戦
User luogu_bot1
Language C++ (GCC 5.4.1)
Score 0
Code Size 1494 Byte
Status WA
Exec Time 2 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
WA × 24
Set Name Test Cases
All 00-sample, 01-maximum, 02-minimum, 03-flat, 50-random-00, 50-random-01, 50-random-02, 50-random-03, 50-random-04, 50-random-05, 50-random-06, 50-random-07, 50-random-08, 50-random-09, 50-random-10, 50-random-11, 50-random-12, 50-random-13, 50-random-14, 50-random-15, 50-random-16, 50-random-17, 50-random-18, 50-random-19
Case Name Status Exec Time Memory
00-sample WA 1 ms 256 KB
01-maximum WA 1 ms 256 KB
02-minimum WA 1 ms 256 KB
03-flat WA 1 ms 256 KB
50-random-00 WA 1 ms 256 KB
50-random-01 WA 1 ms 256 KB
50-random-02 WA 1 ms 256 KB
50-random-03 WA 1 ms 256 KB
50-random-04 WA 1 ms 256 KB
50-random-05 WA 1 ms 256 KB
50-random-06 WA 1 ms 256 KB
50-random-07 WA 1 ms 256 KB
50-random-08 WA 1 ms 256 KB
50-random-09 WA 1 ms 256 KB
50-random-10 WA 1 ms 256 KB
50-random-11 WA 1 ms 256 KB
50-random-12 WA 1 ms 256 KB
50-random-13 WA 2 ms 256 KB
50-random-14 WA 1 ms 256 KB
50-random-15 WA 1 ms 256 KB
50-random-16 WA 1 ms 256 KB
50-random-17 WA 1 ms 256 KB
50-random-18 WA 1 ms 256 KB
50-random-19 WA 1 ms 256 KB