Submission #438954

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4389542021-06-29 01:32:19leinad2Highway Tolls (IOI18_highway)C++17
51 / 100
333 ms11048 KiB
#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int> >adj[90010];
int vis[90010];
void find_pair(int N, vector<int>U, vector<int>V, int A, int B)
{
int M=U.size();
vector<int>w(M);long long X=ask(w);
for(int i=0;i<M;i++)
{
adj[U[i]].push_back({V[i], i});
adj[V[i]].push_back({U[i], i});
}
int s=0;int e=M-1;
while(s<e)
{
int m=s+e>>1;
for(int i=0;i<M;i++)w[i]=0;
for(int i=0;i<=m;i++)w[i]=1;
if(ask(w)>X)e=m;
else s=m+1;
}
int S=U[s], E=V[s];
queue<pair<int, int> >q;
q.push({S, 0});
q.push({E, 1});
vis[S]=vis[E]=1;
vector<pair<int, int> >v1, v2;
v1.push_back({S, -1});
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:18:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   18 |         int m=s+e>>1;
      |               ~^~
highway.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int i=0;i<adj[a].size();i++)
      |                     ~^~~~~~~~~~~~~~
highway.cpp:47:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   47 |         int m=a+b+1>>1;
      |               ~~~^~
highway.cpp:49:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for(int i=m;i<v1.size();i++)w[v1[i].second]=1;
      |                     ~^~~~~~~~~~
highway.cpp:57:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   57 |         int m=a+b+1>>1;
      |               ~~~^~
highway.cpp:59:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         for(int i=m;i<v2.size();i++)w[v2[i].second]=1;
      |                     ~^~~~~~~~~~
#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...