Submission #264866

# Submission time Handle Problem Language Result Execution time Memory
264866 2020-08-14T10:39:46 Z RuDi24 Highway Tolls (IOI18_highway) C++14
0 / 100
26 ms 1736 KB
#include "highway.h"
#include <iostream>
#include <queue>
#include <map>
using namespace std;


void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
	int M = U.size();
	map <int,vector<int>> gr;
	for(int i = 0;i < M;i++){
		gr[U[i]].push_back(V[i]);
		gr[V[i]].push_back(U[i]);	
	}
	queue <int> qu;
	vector<int> dis(N);
	vector<int> vis(N);
	qu.push(0);
	int dist = 0;
	while(!qu.empty()) {
		int sz = qu.size();

		while(sz--){
		int t = qu.front();
		qu.pop();
		for(int i = 0;i < gr[t].size();i++) if(!vis[gr[t][i]]) {
			qu.push(gr[t][i]);
			vis[gr[t][i]] = 1;
			}
		dis[t] = dist;
		}
		dist++;
	}
	vector<int> w(M,1);

	int b = ask(w);
	for(int i = 0;i < M;i++) w[i] = 0;
	int a = ask(w);
	for(int i = 0;i < N;i++){
		if(dis[i]*A == a && dis[i]*B == b){
			answer(0,i);
			return ;
		}
	}
}

Compilation message

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:26:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int i = 0;i < gr[t].size();i++) if(!vis[gr[t][i]]) {
      |                 ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1724 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1664 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1736 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -