Submission #659481

# Submission time Handle Problem Language Result Execution time Memory
659481 2022-11-17T21:25:34 Z Lobo Roads (CEOI20_roads) C++17
15 / 100
23 ms 4808 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<dbl,dbl>,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(mp(x[i+1],y[i+1]) < mp(x[i],y[i])) {
            swap(x[i],x[i+1]);
            swap(y[i],y[i+1]);
        }
        dbl d = sqrt((y[i+1]-y[i])*(y[i+1]-y[i])+(x[i+1]-x[i])*(x[i+1]-x[i]));
        join(i,i+1);
        p.pb(mp(mp(x[i],y[i]),i));
        if(y[i+1] > y[i]) p.pb(mp(mp(x[i],y[i]+d),i+1));
        else p.pb(mp(mp(x[i],y[i]-d),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:49:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long double, long double>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i = 0; i+1 < p.size(); i++) {
      |                    ~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Failed 1 ms 340 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
2 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 2 ms 596 KB Output is correct
4 Correct 11 ms 2636 KB Output is correct
5 Correct 21 ms 4776 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 596 KB Output is correct
4 Correct 11 ms 2636 KB Output is correct
5 Correct 22 ms 4808 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Failed 1 ms 340 KB Condition failed: "!Cross(S[*pi], S[*pa])"
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 596 KB Output is correct
4 Correct 12 ms 2636 KB Output is correct
5 Correct 23 ms 4808 KB Output is correct
6 Failed 0 ms 340 KB Condition failed: "!Cross(S[*pi], S[*pa])"
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 0 ms 340 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 0 ms 340 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
2 Halted 0 ms 0 KB -