Submission #42864529


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	vector<vector<array<int,2>>>G(n);
	rep(i,0,m){
		int x,y,c;
		cin >> x >> y >> c;
		x--,y--;
		G[x].push_back({y,c});
		G[y].push_back({x,c});
	}
	priority_queue<array<int,2>>q;//xが感染済みのまだ使ってない辺の(c,y)が短い順に出てくる
	vector<int>ans(n,-1);
	int k;
	cin >> k;
	rep(i,0,k){
		int x;
		cin >> x;
		x--;
		ans[x]=0;
		for(auto[y,c]:G[x])q.push({-c,y});
	}

	int d;
	cin >> d;
	vector<bool>checked(n);//新規感染者としてチェック済み(使い回す)
	rep(day,1,d+1){
		int power;
		cin >> power;
		priority_queue<array<int,2>>qq;//今日新たに感染した人が感染力の強い順に出てくる(c,x)
		//昨日までの感染者から直接感染する人
		while(q.size()&&-q.top()[0]<=power){
			auto[c,y]=q.top();q.pop();
			c=-c;
			if(ans[y]==-1){
				ans[y]=day;
				qq.push({power-c,y});
			}
		}
		//今日新たに感染した人からさらに感染する人
		while(qq.size()){
			auto[power,x]=qq.top();qq.pop();
			if(checked[x])continue;
			checked[x]=true;
			for(auto[y,c]:G[x])if(ans[y]==-1||ans[y]==day){
				if(c<=power){
					ans[y]=day;
					qq.push({power-c,y});
				}else{
					q.push({-c,y});
				}
			}
		}
	}
	for(auto v:ans)cout << v << ' ';cout << endl;
}

Submission Info

Submission Time
Task F - Virus 2
User kyopro_friends
Language C++ (GCC 9.2.1)
Score 425
Code Size 1422 Byte
Status AC
Exec Time 525 ms
Memory 23564 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:59:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
   59 |  for(auto v:ans)cout << v << ' ';cout << endl;
      |  ^~~
./Main.cpp:59:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
   59 |  for(auto v:ans)cout << v << ' ';cout << endl;
      |                                  ^~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 44
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 14 ms 3516 KiB
example_01.txt AC 3 ms 3484 KiB
example_02.txt AC 2 ms 3512 KiB
hand_00.txt AC 328 ms 22784 KiB
hand_01.txt AC 399 ms 20784 KiB
hand_02.txt AC 313 ms 23292 KiB
hand_03.txt AC 323 ms 23136 KiB
hand_04.txt AC 111 ms 11420 KiB
hand_05.txt AC 515 ms 22920 KiB
hand_06.txt AC 455 ms 20920 KiB
hand_07.txt AC 231 ms 22856 KiB
hand_08.txt AC 97 ms 3520 KiB
hand_09.txt AC 413 ms 18416 KiB
hand_10.txt AC 357 ms 18440 KiB
random_00.txt AC 451 ms 23296 KiB
random_01.txt AC 510 ms 23564 KiB
random_02.txt AC 525 ms 23308 KiB
random_03.txt AC 417 ms 23124 KiB
random_04.txt AC 430 ms 23372 KiB
random_05.txt AC 416 ms 23364 KiB
random_06.txt AC 335 ms 21836 KiB
random_07.txt AC 318 ms 21768 KiB
random_08.txt AC 389 ms 23204 KiB
random_09.txt AC 390 ms 15000 KiB
random_10.txt AC 405 ms 17620 KiB
random_11.txt AC 396 ms 18224 KiB
random_12.txt AC 280 ms 16704 KiB
random_13.txt AC 303 ms 17644 KiB
random_14.txt AC 274 ms 17804 KiB
random_15.txt AC 307 ms 16860 KiB
random_16.txt AC 302 ms 16520 KiB
random_17.txt AC 292 ms 16856 KiB
random_18.txt AC 330 ms 16564 KiB
random_19.txt AC 332 ms 17704 KiB
random_20.txt AC 264 ms 12160 KiB
random_21.txt AC 208 ms 13940 KiB
random_22.txt AC 189 ms 10820 KiB
random_23.txt AC 223 ms 13064 KiB
random_24.txt AC 231 ms 16224 KiB
random_25.txt AC 174 ms 13096 KiB
random_26.txt AC 186 ms 10988 KiB
random_27.txt AC 399 ms 21132 KiB
random_28.txt AC 315 ms 20960 KiB
random_29.txt AC 476 ms 22064 KiB