QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#56641#3894. Generator Gridt3alaMsMs#WA 2ms3668kbC++911b2022-10-20 21:56:122022-10-20 21:56:16

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-20 21:56:16]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3668kb
  • [2022-10-20 21:56:12]
  • Submitted

answer

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1e5 + 5;
int n, m;
int par[N];
vector<array<int, 3>> v;
int find(int u) {
	return par[u] == u ? u : par[u] = find(par[u]);
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 0;i < m;i++) {
		int c, a;
		cin >> c >> a;
		v.push_back({a, 0, c});
	}
	for(int i = 1;i <= n;i++) {
		par[i] = i;
		int b;
		cin >> b;
		v.push_back({b,i,(i+1)%n + 1});
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	for(auto i : v) {
		int c = i[0];
		int a = i[1];
		int b = i[2];
		if(find(a) != find(b)) {
			ans += c;
			par[find(a)] = find(b);
		}
	}
	cout << ans;
    return 0;
}


详细

Test #1:

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

input:

3 2
1 100
2 200
150 300 150

output:

400

result:

ok single line: '400'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3540kb

input:

3 2
1 100
2 200
300 300 150

output:

450

result:

ok single line: '450'

Test #3:

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

input:

100 1
1 100
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ...

output:

1080

result:

wrong answer 1st lines differ - expected: '1090', found: '1080'