제출 #1017168

#제출 시각아이디문제언어결과실행 시간메모리
1017168mindiyak통행료 (IOI18_highway)C++14
0 / 100
237 ms262144 KiB
#include "highway.h" #include <bits/stdc++.h> #include <string> #include <iostream> #include <cmath> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pi; typedef pair<int, int> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<vector<int>> vvi; typedef vector<ld> vd; typedef vector<long> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; typedef vector<vector<pi>> vvpi; #define FOR(i, a, b) for (int i = a; i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define trav(a, x) for (auto &a : x) #define uid(a, b) uniform_int_distribution<int>(a, b)(rng) #define len(x) (int)(x).size() #define mp make_pair #define pb push_back #define F first #define nl endl #define S second #define lb lower_bound #define ub upper_bound #define aint(x) x.begin(), x.end() #define raint(x) x.rbegin(), x.rend() #define ins insert const int MOD = 1000000007; int N,M; vi arr; vi con; vvpi paths; ll fill_with(int a,int b){ vi quest(M,0); if(a>=0 && b < M){ FOR(i,a,b+1){ quest[con[i]]=1; } } ll val = ask(quest); // for(int i:quest)cout << i << " "; // cout << " - " << val << endl; return val; } void dfs(int pos,int prev){ arr.pb(pos); for(auto a:paths[pos]){ if(a.F == prev)continue; con.pb(a.S); dfs(a.F,pos); } } void find_pair(int n, std::vector<int> U, std::vector<int> V, int A, int B) { N = n;M = N-1; paths = vvpi(N,vpi()); FOR(i,0,M){ paths[U[i]].pb({V[i],i}); paths[V[i]].pb({U[i],i}); } int head = -1; FOR(i,0,N){ if(paths[i].size() == 1){ head = i; break; } } dfs(head,-1); // for(int i:arr)cout << i << " "; // cout << endl; // for(int i:con)cout << i << " "; // cout << endl; ll none = fill_with(-1,-1); int l=0,r=M-1; while(l<r){ int mid = (l+r)/2; ll count = fill_with(0,mid) - none; if(count > 0){ r = mid; }else{ l = mid+1; } } int start = arr[l]; l=0;r=M-1; while(l<r){ int mid = (l+r)/2; ll count = fill_with(mid,M-1) - none; if(count > 0){ l = mid; }else{ r = mid-1; } } int end = arr[l+1]; answer(start,end); }
#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...