답안 #659477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
659477 2022-11-17T21:07:52 Z Lobo Roads (CEOI20_roads) C++17
0 / 100
9 ms 1616 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];
    }
    for(int i = 1; i <= 2*n; i+=2) {
        if(x[i+1] < x[i]) {
            swap(x[i],x[i+1]);
            swap(y[i],y[i+1]);
        }
        join(i,i+1);
        p.pb(mp(mp(x[i],y[i]),i));
    }
    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:46: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]
   46 |     for(int i = 0; i+1 < p.size(); i++) {
      |                    ~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Failed 1 ms 340 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Failed 9 ms 1616 KB Condition failed: "!Cross(S[*pi], S[*pa])"
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Failed 8 ms 1552 KB Condition failed: "!Cross(S[*pi], S[*pa])"
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Failed 9 ms 1612 KB Condition failed: "!Cross(S[*pi], S[*pa])"
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 0 ms 340 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 0 ms 340 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
2 Halted 0 ms 0 KB -