Submission #348467

#TimeUsernameProblemLanguageResultExecution timeMemory
348467beksultan04Highway Tolls (IOI18_highway)C++14
0 / 100
37 ms7916 KiB
#include "highway.h" #ifndef EVAL #include "grader.cpp" #endif // EVAL #include <bits/stdc++.h> using namespace std; #define lol long long #define pii pair<int,int> #define OK puts("OK"); #define NO puts("NO"); #define YES puts("YES"); #define fr first #define sc second #define ret return #define scanl(a) scanf("%lld",&a); #define scanll(a,b) scanf("%lld %lld",&a, &b); #define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define scan1(a) scanf("%d",&a); #define scan2(a,b) scanf("%d %d",&a, &b); #define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c); #define all(s) s.begin(),s.end() #define allr(s) s.rbegin()Ñ,s.rend() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); #define eps 1e-12 const int NN = 3e5+12,INF=1e9+7; bool vis[NN],may[100001]; vector <int> g[NN]; void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { int n = U.size(); vector<int> w(n); int i,j; for (i = 0; i < n; ++i){ g[U[i]].pb(V[i]); g[V[i]].pb(U[i]); w[i] = 0; } long long ans = ask(w),l=-1,r=0; for (i=0;i<n;++i){ w[i] = 1; int x = ask(w); if (x > ans){ ans = x; r=U[i]; may[U[i]]=1; may[V[i]]=1; if (l == -1)l = U[i]; } else { w[i] = 0; } } bool f=1; vis[l]=1; vis[r]=1; while (f){ f=0; for (int to : g[l]){ if (vis[to] == 0 && may[to] == 1){ l = to; vis[l]= 1; break; } } for (int to : g[r]){ if (vis[to] == 0 && may[to] == 1){ r = to; vis[r]= 1; break; } } } answer(l, r); }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:33:11: warning: unused variable 'j' [-Wunused-variable]
   33 |     int i,j;
      |           ^
#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...