Submission #335141

# Submission time Handle Problem Language Result Execution time Memory
335141 2020-12-11T08:34:23 Z nicholask Street Lamps (APIO19_street_lamps) C++14
0 / 100
13 ms 3820 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	tuple <int,int,int> g[m];
	for (int i=0; i<m; i++) cin>>get<0>(g[i])>>get<1>(g[i])>>get<2>(g[i]);
	int q;
	cin>>q;
	while (q--){
		int t,x,y;
		cin>>t>>x>>y;
		if (t==1) get<2>(g[x-1])=y;
		else {
			vector <int> v[n+1];
			for (int i=0; i<m; i++){
				if (get<2>(g[i])<y) continue;
				v[get<0>(g[i])].push_back(get<1>(g[i]));
				v[get<1>(g[i])].push_back(get<0>(g[i]));
			}
			bool visited[n+1]={};
			queue <int> q;
			q.push(x);
			visited[x]=1;
			while (!q.empty()){
				int f=q.front();
				q.pop();
				for (auto&i:v[f]){
					if (visited[i]) continue;
					q.push(i);
					visited[i]=1;
				}
			}
			int cnt=0;
			for (int i=1; i<=n; i++){
				if (visited[i]) cnt++;
			}
			cout<<cnt<<endl;
		}
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 3820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -