답안 #921617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921617 2024-02-04T08:11:47 Z 1075508020060209tc Meetings (JOI19_meetings) C++14
0 / 100
38 ms 664 KB
#pragma GCC optimize("O3")
#include "meetings.h"
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define X first
#define Y second
#define SZ(x) (int)(x).size()

unsigned seed=12345;
long long rnd(){
seed=seed^(seed<<7);
seed=seed^(seed>>4);
seed=seed^(seed>>3);
return seed;
}


map<vector<int>,int>mp;
int n;
int query(int a,int b,int c){
vector<int>vc={a,b,c};
sort(vc.begin(),vc.end());
if(mp[vc]){return mp[vc];}
mp[vc]=Query(vc[0],vc[1],vc[2])+1;
return mp[vc];
}
set<pair<int,int>>ans;

int finmid(vector<int>&vc){
int a=rnd()%vc.size();
int b=rnd()%vc.size();
if(b==a){b++;b%=vc.size();}
int c=rnd()%vc.size();
if(c==a){
    c++;c%=vc.size();
}
if(c==b){
    c++;c%=vc.size();
}
return query(vc[0],vc[1],vc[2]);
}

void slv(vector<int>vc){
if(vc.size()==1){return;}
if(vc.size()==2){
    ans.insert({min(vc[0],vc[1]),max(vc[0],vc[1])});
    return;
}
int md=finmid(vc);
vector<int>vca;
vector<int>vcb;
int v=vc[0];
if(v==md){v=vc[1];}
vca.push_back(v);
vcb.push_back(md);
for(int i=0;i<vc.size();i++){
    if(vc[i]==v||vc[i]==md){continue;}
    int vv=query(md,v,vc[i]);
    if(vv==md){
        vcb.push_back(vc[i]);
    }else{
        v=vv;
        vca.push_back(vc[i]);
    }
}
ans.insert({min(md,v),max(md,v)});
slv(vca);
slv(vcb);
}


void Solve(int N){
n=N;
vector<int>vc;
for(int i=1;i<=n;i++){
    vc.push_back(i);
}
slv(vc);
for(auto it=ans.begin();it!=ans.end();it++){
    Bridge((*it).first-1, (*it).second-1);
}
}

Compilation message

meetings.cpp: In function 'void slv(std::vector<int>)':
meetings.cpp:57:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 | for(int i=0;i<vc.size();i++){
      |             ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 596 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 596 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 596 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 664 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -