Submission #158978

# Submission time Handle Problem Language Result Execution time Memory
158978 2019-10-19T17:50:00 Z combi1k1 Meetings (JOI19_meetings) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "meetings.h"

using namespace std;

#define X   first
#define Y   second

typedef pair<int,int>   ii;

void calc(vector<int> Ver,int P)    {
    int n = Ver.size();
    if (n == 1) {
        Bridge(Ver[0],P);
        return;
    }
    if (n == 0) return;

    vector<ii>  Remain;
    vector<int> toRoot; toRoot.push_back(x);

    int x = Ver[rand() % n];

    for(int a : Ver)    if (a != x) {
        int u = Query(P,a,x);
        if (u == a)
            toRoot.push_back(u);
        else
            Remain.push_back({u,a});
    }

    sort(Remain.begin(),Remain.end());
    sort(toRoot.begin(),toRoot.end(),[&](int x,int y)   {
        return  Query(P,x,y) == x;
    });

    for(int x : toRoot)
        Bridge(x,P),
        P = x;

    int l = 0;
    int r = 0;

    for(; l < Remain.size() ;)  {
        vector<int> vec;
        for(; r < Remain.size() && Remain[r].X == Remain[l].X ; ++r);
            vec.push_back(Remain[r].Y);
        calc(vec, Remain[l].X);
        l = r;
    }
}

void Solve(int n)   {
    srand(time(NULL));
    vector<int> Ver(n - 1);

    iota(Ver.begin(),Ver.end(),1);

    calc(Ver,0);
}

Compilation message

meetings.cpp: In function 'void calc(std::vector<int>, int)':
meetings.cpp:20:42: error: 'x' was not declared in this scope
     vector<int> toRoot; toRoot.push_back(x);
                                          ^
meetings.cpp:44:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(; l < Remain.size() ;)  {
           ~~^~~~~~~~~~~~~~~
meetings.cpp:46:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(; r < Remain.size() && Remain[r].X == Remain[l].X ; ++r);
               ~~^~~~~~~~~~~~~~~
meetings.cpp:46:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for(; r < Remain.size() && Remain[r].X == Remain[l].X ; ++r);
         ^~~
meetings.cpp:47:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
             vec.push_back(Remain[r].Y);
             ^~~