Submission #286106

#TimeUsernameProblemLanguageResultExecution timeMemory
286106mohammadHighway Tolls (IOI18_highway)C++14
0 / 100
26 ms4608 KiB
#include "highway.h" #include<bits/stdc++.h> using namespace std; #define endl "\n" // #define int long long typedef long long ll ; const ll ooo = 1e14 ; const ll oo = 2e9 ; const double PI = acos(-1) ; const ll M = 1e9 + 7 ; const int N = 10000010 ; vector<ll> g[100010] , cost; int a , b , p[100010]; map<pair<int,int> , int>mp; void dis(int i){ cost[i] = 0 ; priority_queue<pair<ll,ll>> q; q.push({0 , i}); while(q.size()){ int src = q.top().second , c = -q.top().first; q.pop(); if(cost[src] < c) continue ; for(auto x : g[src]) if(cost[x] > c + a){ p[x] = src; cost[x] = c + a; q.push({-cost[x] , x}); } } } void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { int M = U.size(); a = A;b = B; for(int i = 0 ; i < M ; ++i) g[U[i]].push_back(V[i]) , mp[{U[i] , V[i]}] = i , mp[{V[i] , U[i]}] = i; cost = vector<ll>(N , ooo); dis(0); vector<int> w(M , 0); ll toll = ask(w); vector<int> ans; for(int i = 1 ; i < N; ++i) if(cost[i] == toll) ans.push_back(mp[{i , p[i]}]); while(ans.size() - 1){ for(int i = 0 ; i < ans.size() / 2 ; ++i) w[ans[i]] = 1; ll tll = ask(w); for(int i = 0 ; i < ans.size() / 2 ; ++i) w[ans[i]] = 0; if(toll == tll){ vector<int> ans1 ; for(int i = ans.size() / 2 ; i < ans.size() ; ++i) ans1.push_back(ans[i]) ; ans = ans1; }else{ vector<int> ans1 ; for(int i = 0 ; i < ans.size() / 2 ; ++i) ans1.push_back(ans[i]) ; ans = ans1; } } int i = ans[0]; ll y = (p[U[i]] == V[i] ? U[i] : V[i]); answer(0, y ); }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:48:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for(int i = 0 ; i < ans.size() / 2 ; ++i) w[ans[i]] = 1;
      |                   ~~^~~~~~~~~~~~~~~~
highway.cpp:50:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for(int i = 0 ; i < ans.size() / 2 ; ++i) w[ans[i]] = 0;
      |                   ~~^~~~~~~~~~~~~~~~
highway.cpp:53:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |    for(int i = ans.size() / 2 ; i < ans.size() ; ++i)
      |                                 ~~^~~~~~~~~~~~
highway.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |    for(int i = 0 ; i < ans.size() / 2 ; ++i)
      |                    ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...