QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#879764#8804. Treasure Huntzhassyn#0 0ms9964kbC++201.1kb2025-02-02 13:31:072025-02-02 13:31:09

Judging History

This is the latest submission verdict.

  • [2025-02-02 13:31:09]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 9964kb
  • [2025-02-02 13:31:07]
  • Submitted

answer

#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 2 * 1e5 + 10, M = 4096 + 10, inf = 1e18;
const ll mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll um(ll a, ll b){
	return (1LL * a * b) % mod;
}
ll subr(ll a, ll b){
	return ((1LL * a - b) % mod + mod) % mod;
}
ll a[N], p[N], sz[N], mx[N], n;
ll get(ll x){
	if(x == p[x]) return x;
	return p[x] = get(p[x]);
}
void addthem(ll a, ll b){
	a = get(a);
	b = get(b);
	if(a != b){
		if(sz[b] > sz[a]) swap(a, b);
		sz[a] += sz[b];
		mx[a] = max(mx[a], mx[b]);
		p[b] = a;
	}
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll m;
  cin >> n >> m;
  for(ll i = 1; i <= n; i++){
  	cin >> a[i];
  	mx[i] = a[i];
  	sz[i] = 1;
  	p[i] = i;
  }
  for(ll i = 0, a, b, c; i < m; i++){
  	cin >> a >> b >> c;
  	if(c == 0) addthem(a, b);
  }
  for(ll i = 1; i <= n; i++){
  	cout << mx[get(i)] << endl;
  }
  return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 9964kb

input:

3000 3000
735362183 321648408 84435611 638030501 876390252 836223236 65247387 527734646 80970666 766403495 110657364 283475781 693285991 945447633 641155308 132890294 969038868 372617561 823982498 896717651 845481436 111374342 404588333 709818617 665021093 770870148 892408756 925221803 884526087 620...

output:

735362183
321648408
84435611
638030501
876390252
836223236
65247387
527734646
80970666
766403495
110657364
283475781
693285991
945447633
641155308
132890294
969038868
372617561
823982498
896717651
845481436
111374342
404588333
709818617
665021093
770870148
892408756
925221803
884526087
620849020
413...

result:

wrong answer 2nd lines differ - expected: '713607491', found: '321648408'

Subtask #2:

score: 0
Runtime Error

Test #14:

score: 0
Runtime Error

input:

1000000 1000000
735362183 321648408 84435611 638030501 876390252 836223236 65247387 527734646 80970666 766403495 110657364 283475781 693285991 945447633 641155308 132890294 969038868 372617561 823982498 896717651 845481436 111374342 404588333 709818617 665021093 770870148 892408756 925221803 8845260...

output:


result:


Subtask #3:

score: 0
Runtime Error

Test #30:

score: 0
Runtime Error

input:

1000000 999999
735362183 321648408 84435611 638030501 876390252 836223236 65247387 527734646 80970666 766403495 110657364 283475781 693285991 945447633 641155308 132890294 969038868 372617561 823982498 896717651 845481436 111374342 404588333 709818617 665021093 770870148 892408756 925221803 88452608...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%