Submission #262135

#TimeUsernameProblemLanguageResultExecution timeMemory
262135dooweyMeetings (JOI19_meetings)C++14
29 / 100
3061 ms9824 KiB
#include "meetings.h"
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int n;

const int MAXN = 2020;
int par[MAXN];

map<pii, int> res;
int get(int u, int v){
    if(res.count(mp(u,v))) return res[mp(u,v)];
    int c = Query(0, u, v);
    res[mp(u,v)]=res[mp(v,u)]=c;
    return c;
}

bool comp(int u, int v){
    if(get(u,v) == u) return true;
    else return false;
}

bool use[MAXN];
bool ban[MAXN];

void Solve(int N) {
    n = N;
    vector<int> ord;
    for(int i = 1; i < n ; i ++ ){
        ord.push_back(i);
        par[i] = -1;
    }
    random_shuffle(ord.begin(), ord.end());
    int fir;
    int step = 0;
    for(auto nd : ord){
        if(par[nd] != -1) continue;
        int res;
        for(int j = 0 ; j < n; j ++ ){
            use[j]=false;
            ban[j]=false;
        }
        for(int j = 1; j < n; j ++ ){
            if(j == nd) continue;
            res = get(j, nd);
            use[res]=true;
        }
        step ++ ;
        use[nd]=true;
        use[0]=true;
        fir = 0;
        for(int j = 1; j < n; j ++ ){
            if(!use[j]) continue;
            if(par[j] != -1){
                if(use[par[j]]){
                    ban[par[j]]=true;
                }
            }
        }
        vector<int> ss;
        for(int j = 1; j < n; j ++ ){
            if(use[j] && par[j] != -1 && ban[j] == false){
                fir = j;
            }
            else if(use[j] && !ban[j]){
                ss.push_back(j);
            }
        }
        sort(ss.begin(), ss.end(), comp);
        par[ss[0]] = fir;
        for(int i = 1; i < ss.size(); i ++ )
            par[ss[i]] = ss[i - 1];
    }
    int l, r;
    for(int i = 1; i < n; i ++ ){
        l = par[i];
        r = i;
        if(l > r)
            swap(l, r);
        Bridge(l, r);
    }
}

Compilation message (stderr)

meetings.cpp: In function 'void Solve(int)':
meetings.cpp:79:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |         for(int i = 1; i < ss.size(); i ++ )
      |                        ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...