Submission #659454

# Submission time Handle Problem Language Result Execution time Memory
659454 2022-11-17T19:44:28 Z Lobo Roads (CEOI20_roads) C++17
15 / 100
31 ms 6572 KB
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

const int maxn = 1e5+10;

int n, x[maxn], y[maxn], ds[maxn], dsz[maxn];

int find(int v) {
    if(v == ds[v]) return v;
    return ds[v] = find(ds[v]);
}

void join(int u, int v) {
    if(dsz[u] < dsz[v]) swap(u,v);
    dsz[u]+= dsz[v];
    ds[v] = u;
}

void solve() {
    cin >> n;
    vector<pair<pair<int,int>,int>> p;
    for(int i = 1; i <= 2*n; i++) {
        ds[i] = i;
        dsz[i] = 1;
        cin >> x[i] >> y[i];
        p.pb(mp(mp(x[i],y[i]),i));
    }
    for(int i = 1; i <= 2*n; i+=2) {
        join(i,i+1);
    }
    sort(all(p));
    for(int i = 0; i+1 < p.size(); i++) {
        int u = p[i].sc;
        int v = p[i+1].sc;
        if(find(u) != find(v)) {
            cout << x[u] << " " << y[u] << " " << x[v] << " " << y[v] << endl;
            join(find(u),find(v));
        }

    }
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    // freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    int tt = 1;
    // cin >> tt;
    while(tt--) {
        solve();
    }

}

Compilation message

roads.cpp: In function 'void solve()':
roads.cpp:42:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i = 0; i+1 < p.size(); i++) {
      |                    ~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Failed 29 ms 6572 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 9 ms 2272 KB Output is correct
5 Correct 18 ms 3784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 9 ms 2124 KB Output is correct
5 Correct 18 ms 3848 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Failed 1 ms 332 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 472 KB Output is correct
4 Correct 9 ms 2124 KB Output is correct
5 Correct 17 ms 3784 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Failed 1 ms 340 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 11 ms 2124 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Failed 1 ms 340 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Failed 31 ms 6496 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
3 Halted 0 ms 0 KB -