//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#include "meetings.h"
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forn(x,y) for(int x = 1 ; x <= (int)y ; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef complex<int> point;
const int nmax = 100005;
const ll linf = 1e18;
const ll mod = 998244353;
const int inf = INT_MAX;
vec < pii > eds;
int find_center(vec <int> &asd){
if(asd.size() <= 2)return asd[0];
vec<int> cnt(asd.size());
int tries = asd.size();
while(tries --){
int m = asd.size();
int a, b, c;
a = asd[rand()%m];
b = asd[rand()%m];
while(b == a) b = asd[rand()%m];
c = asd[rand()%m];
while(c == b || c == a)c = asd[rand()%m];
// a,b,c - random din asd
cnt[Query(a,b,c)] ++;
}
int mx = 0;
for(int i = 0; i < cnt.size() ; i++){
if(cnt[mx] < cnt[i])mx = i;
}
return asd[mx];
}
void solves(vec <int> &tb){
if(tb.size() == 1)return ;
int A = find_center(tb);
int B = tb[0];
if(B == A)B = tb[1];
for(int i : tb){
if(i != A && i != B && Query(A,B,i) == i) B = i;
}
eds.pb({A,B});
vec < int > left;
vec < int > right;
for(int i : tb){
if(i != A && i != B){
if(Query(A,B,i) == A){
left.pb(i);
}else{
right.pb(i);
}
}
}
left.pb(A);
right.pb(B);
solves(left);
solves(right);
}
void Solve(int n){
vec < int > asd;
for(int i= 0; i <n ; i++)asd.pb(i);
solves(asd);
for(pii ed : eds){
Bridge(ed.fr,ed.sc);
}
}
/*
int main(){
fast;
}
*/
Compilation message
meetings.cpp: In function 'int find_center(std::vector<int>&)':
meetings.cpp:49:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < cnt.size() ; i++){
~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
323 ms |
888 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |