답안 #945034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
945034 2024-03-13T10:11:20 Z dsyz Lost Array (NOI19_lostarray) C++17
100 / 100
34 ms 10496 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll N,M;
	cin>>N>>M;
	vector<pair<ll,ll> > v[N];
	vector<pair<pair<ll,ll>,ll> > A;
	for(ll i = 0;i < M;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		a -= 1;
		b -= 1;
		v[a].push_back(make_pair(b,c));
		v[b].push_back(make_pair(a,c));
		A.push_back(make_pair(make_pair(a,b),c));
	}
	ll arr[N];
	for(ll i = 0;i < N;i++){
		arr[i] = 1;		
	}
	for(ll i = 0;i < N;i++){
		ll maximum = -1;
		for(auto u : v[i]){
			if(maximum == -1 || u.second > maximum){
				maximum = u.second;
			}						
		}
		if(maximum != -1){
			arr[i] = maximum;
		}
	}
	for(ll i = 0;i < M;i++){
		if(arr[A[i].first.first] <= A[i].second){
			arr[A[i].first.first] = A[i].second;						
		}else if(arr[A[i].first.second] <= A[i].second){
			arr[A[i].first.second] = A[i].second;			
		} 				
	}
	for(ll i = 0;i < N;i++){
		cout<<arr[i]<<" ";
	}
	cout<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 1116 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 6 ms 3164 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 5 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 1116 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 6 ms 3164 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 5 ms 2652 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 456 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2324 KB Output is correct
2 Correct 10 ms 4172 KB Output is correct
3 Correct 8 ms 3444 KB Output is correct
4 Correct 5 ms 2252 KB Output is correct
5 Correct 1 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 1116 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 6 ms 3164 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 5 ms 2652 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 456 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 4 ms 2324 KB Output is correct
17 Correct 10 ms 4172 KB Output is correct
18 Correct 8 ms 3444 KB Output is correct
19 Correct 5 ms 2252 KB Output is correct
20 Correct 1 ms 764 KB Output is correct
21 Correct 16 ms 5140 KB Output is correct
22 Correct 17 ms 5900 KB Output is correct
23 Correct 20 ms 8052 KB Output is correct
24 Correct 23 ms 7184 KB Output is correct
25 Correct 34 ms 10496 KB Output is correct