Submission #659453

# Submission time Handle Problem Language Result Execution time Memory
659453 2022-11-17T19:42:38 Z Lobo Roads (CEOI20_roads) C++17
0 / 100
1 ms 340 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].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 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -