Submission #942616

# Submission time Handle Problem Language Result Execution time Memory
942616 2024-03-11T01:27:09 Z yeediot Meetings (JOI19_meetings) C++14
0 / 100
47 ms 700 KB
#include "meetings.h"
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(time(0));
int K;
bool cmp(int a,int b){
    return Query(K,a,b)==a;
}
void qq(int a,int b){
    if(a>b)swap(a,b);
    Bridge(a,b);
}
int n;
void go(int k,vector<int>temp){
    if(temp.size()==0)return;
    int k2=rng()%n;
    K=k;
    vector<int>child[n],path;
    for(auto i:temp){
        if(i==k2)continue;
        int p=Query(k,k2,i);
        if(p==i){
            path.push_back(i);
        }
        else{
            child[p].push_back(i);
        }
    }
    sort(path.begin(),path.end(),cmp);
    path.push_back(k2);
    for(int i=0;i<temp.size();i++){
        if(!i){
            qq(k,path[i]);
        }
        else{
            qq(path[i-1],path[i]);
        }
    }
    go(k,child[k]);
    for(auto i:path){
        go(i,child[i]);
    }
}
void Solve(int N){
    n=N;
    int k=rng()%n;
    vector<int>temp;
    for(int i=0;i<n;i++){
        if(i!=k)temp.push_back(i);
    }
    go(k,temp);
}
 /*
 input:
 
 */















 

Compilation message

meetings.cpp: In function 'void go(int, std::vector<int>)':
meetings.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0;i<temp.size();i++){
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 700 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -