Submission #42865158


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});
	}

	vector<int>ans(n,-1);
	vector<int>dist(n,2e9);//感染者からの距離
	vector<int>nnn;//今日の新規感染者
	int k;
	cin >> k;
	rep(i,0,k){
		int x;
		cin >> x;
		x--;
		ans[x]=0;
		nnn.push_back(x);
	}

	//日をまたぐたびに、「昨日の新規感染者」の感染者からの距離を0にする
	//pqの昨日の中身は残しておいて、今日は昨日の続きからやる
	//各辺は高々2度しかチェックされない(初めてvに来たとき、dist[v]←0されたとき)
	priority_queue<array<int,2>>q;
	int d;
	cin >> d;
	rep(day,1,d+1){
		int power;
		cin >> power;
		for(auto x:nnn){
			dist[x]=0;
			q.push({-dist[x],x});
		}
		nnn.clear();
		while(q.size()){
			auto[ddd,x]=q.top();
			if(dist[x]>power)break;
			q.pop();
			ddd=-ddd;
			if(ddd>dist[x])continue;
			if(ans[x]==-1){
				ans[x]=day;
				nnn.push_back(x);
			}
			for(auto[y,c]:G[x])if(dist[y]>dist[x]+c){
				dist[y]=dist[x]+c;
				q.push({-dist[y],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 1359 Byte
Status AC
Exec Time 595 ms
Memory 26144 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:60:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
   60 |  for(auto v:ans)cout << v << ' ';cout << endl;
      |  ^~~
./Main.cpp:60:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
   60 |  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 18 ms 3380 KiB
example_01.txt AC 2 ms 3508 KiB
example_02.txt AC 1 ms 3376 KiB
hand_00.txt AC 336 ms 24520 KiB
hand_01.txt AC 424 ms 21904 KiB
hand_02.txt AC 323 ms 24124 KiB
hand_03.txt AC 336 ms 24260 KiB
hand_04.txt AC 116 ms 12588 KiB
hand_05.txt AC 523 ms 26144 KiB
hand_06.txt AC 524 ms 24652 KiB
hand_07.txt AC 257 ms 24468 KiB
hand_08.txt AC 100 ms 3560 KiB
hand_09.txt AC 432 ms 18048 KiB
hand_10.txt AC 395 ms 20584 KiB
random_00.txt AC 498 ms 25364 KiB
random_01.txt AC 593 ms 25552 KiB
random_02.txt AC 595 ms 25396 KiB
random_03.txt AC 480 ms 25284 KiB
random_04.txt AC 488 ms 25332 KiB
random_05.txt AC 464 ms 25408 KiB
random_06.txt AC 329 ms 22836 KiB
random_07.txt AC 306 ms 23012 KiB
random_08.txt AC 399 ms 25020 KiB
random_09.txt AC 346 ms 13196 KiB
random_10.txt AC 342 ms 13064 KiB
random_11.txt AC 337 ms 12920 KiB
random_12.txt AC 241 ms 13260 KiB
random_13.txt AC 243 ms 13072 KiB
random_14.txt AC 213 ms 13056 KiB
random_15.txt AC 254 ms 13460 KiB
random_16.txt AC 258 ms 13156 KiB
random_17.txt AC 258 ms 13492 KiB
random_18.txt AC 264 ms 11648 KiB
random_19.txt AC 264 ms 11928 KiB
random_20.txt AC 222 ms 7992 KiB
random_21.txt AC 129 ms 9900 KiB
random_22.txt AC 132 ms 7724 KiB
random_23.txt AC 152 ms 9372 KiB
random_24.txt AC 185 ms 11096 KiB
random_25.txt AC 167 ms 9316 KiB
random_26.txt AC 143 ms 7880 KiB
random_27.txt AC 394 ms 22500 KiB
random_28.txt AC 311 ms 22308 KiB
random_29.txt AC 501 ms 23372 KiB