This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
#ifndef __SIZEOF_INT128__
#define __SIZEOF_INT128__
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "highway.h"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template <typename T> using oset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i, p, k) for(int i(p); i < (k); ++i)
#define per(i, p, k) for(int i(p); i > (k); --i)
#define sz(x) (int)(x).size()
#define sc static_cast
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128_t lll;
//#define int ll
template <typename T = int> using par = std::pair <T, T>;
#define fi first
#define se second
#define test int _number_of_tests(in()); while(_number_of_tests--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb emplace_back
struct Timer {
string name{""};
time_point<high_resolution_clock> end, start{high_resolution_clock::now()};
duration<float, std::milli> dur;
Timer() = default;
Timer(string nm): name(nm) {}
~Timer() {
end = high_resolution_clock::now(); dur= end - start;
cout << "@" << name << "> " << dur.count() << " ms" << '\n';
}
};
template <typename T = int> inline T in()
{
static T x;
std::cin >> x;
return x;
}
std::string yn(bool b)
{
if(b) return "YES\n";
else return "NO\n";
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par);
template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek)
{
for(const auto& i : wek)out << i << ' ';
return out;
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par)
{
out << '{'<<par.first<<", "<<par.second<<"}";
return out;
}
#define show(x) cerr << #x << " = " << x << '\n';
constexpr int maxn = 90003;
vector <pair<int, int>> graf[maxn];
bool byl[maxn];
void find_pair(int n, vector <int> ka, vector <int> kb, int a, int b)
{
int m(sz(ka));
rep(i, 0, m){
graf[ka[i]].pb(kb[i], i);
graf[kb[i]].pb(ka[i], i);
}
ll d(ask(vector<int>(m, 0))/a);
int p(0), k(m), s;
vector <int> sk(m);
while(k > p){
s = (p+k+1)/2;
rep(i, 0, m)sk[i] = i >= s;
if(ask(sk) > d*a)p = s;
else k = s-1;
}
vector <pair <int, int>> kr[2]{{{p, ka[p]}}, {{p, kb[p]}}};
queue <pair <int, bool>> kul;
kul.push({ka[p], 0});
kul.push({kb[p], 1});
byl[ka[p]] = byl[kb[p]] = 1;
while(kul.size()){
auto [w, b] = kul.front(); kul.pop();
for(auto [i, j]: graf[w])if(!byl[i]){
byl[i] = 1;
kr[b].pb(j, i);
kul.push({i, b});
}
}
int t[2];
rep(b, 0, 2){
int p(0), k(sz(kr[b])-1), s;
while(k > p){
s = (p+k+1)/2;
rep(i, 0, m)sk[i] = 1;
rep(i, 0, sz(kr[!b]))sk[kr[!b][i].first] = 0;
rep(i, 0, s)sk[kr[b][i].first] = 0;
if(ask(sk) == d*a)k = s-1;
else p = s;
}
t[b] = kr[b][p].second;
}
answer(t[0], t[1]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |