This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#include<bits/stdc++.h>
#include "icc.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef vector<vector<int>>vvi;
typedef vector<ll>vl;
typedef vector<vl> vvl;
typedef pair<int,int>pi;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
typedef vector<ld> vld;
typedef pair<ld,ld> pld;
typedef vector<pi> vpi;
#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define outfl(x){cout << x << endl;return;}
#define GLHF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define print(x){for(auto ait:x) cout << ait << " "; cout << "\n";}
#define pb push_back
#define umap unordered_map
int query(vi a,vi b){
int* A=new int[a.size()],*B=new int[b.size()];
for(int i=0; i<a.size(); i++)
A[i]=a[i];
for(int i=0; i<b.size(); i++)
B[i]=b[i];
return query(a.size(),b.size(),A,B);
}
vi par;
void init(int n){
par.resize(n+1);
iota(all(par),0);
}
int get(int x){
return par[x]=(x==par[x]?x:get(par[x]));
}
void unite(int u,int v){
par[get(u)]=get(v);
}
void run(int n){
vpi E;
for(int i=1; i<=n; i++)
for(int j=i+1; j<=n; j++)
E.pb({i,j});
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
shuffle(all(E),rng);
init(n);
for(auto[u,v]:E){
if(get(u)==get(v))continue;
if(!query({u},{v}))continue;
unite(u,v);
setRoad(u,v);
}
}
/*
4
1 3
1 4
2 4
*/
Compilation message (stderr)
icc.cpp: In function 'int query(vi, vi)':
icc.cpp:42:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for(int i=0; i<a.size(); i++)
| ~^~~~~~~~~
icc.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i=0; i<b.size(); i++)
| ~^~~~~~~~~
# | 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... |