답안 #617502

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
617502 2022-08-01T11:50:42 Z happypotato 분수 공원 (IOI21_parks) C++17
0 / 100
1 ms 312 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
const int mxN = 2e5 + 1;
const int dx[mxN] = {0, 1, 0, -1}, dy[mxN] = {1, 0, -1, 0};
bool vis[mxN];
pair<pii, int> pts[mxN];
map<pii, int> allpts;
int n;
bool CheckConnected() {
    queue<pii> q;
    set<pii> track;
    q.push(pts[1].ff);
    track.insert(pts[1].ff);
    while (!q.empty()) {
        pii cur = q.front();
        q.pop();
        for (int k = 0; k < 4; k++) {
            int nx = cur.ff + dx[k] * 2;
            int ny = cur.ss + dy[k] * 2;
            if (allpts.find({nx, ny}) != allpts.end() && track.find({nx, ny}) == track.end()) {
                q.push({nx, ny});
                track.insert({nx, ny});
            }
        }
    }
    return (track.size() == n);
}
void st12() {
    vector<pii> edge;
    vis[1] = true;
    for (int i = 1; i <= n; i++) {
        if (allpts.find({pts[i].ff.ff, pts[i].ff.ss + 2}) != allpts.end()) {
            int v = allpts[{pts[i].ff.ff, pts[i].ff.ss + 2}];
            if (!vis[v]) {
                edge.pb({pts[i].ss, v});
                vis[v] = true;
            }
        }
        if (pts[i].ff.ff == 4 && allpts.find({2, pts[i].ff.ss}) != allpts.end()) {
            int v = allpts[{2, pts[i].ff.ss}];
            if (!vis[v]) {
                edge.pb({pts[i].ss, v});
                vis[v] = true;
            }
        }
    }
    int m = edge.size();
    vector<int> u(m), v(m), a(m), b(m);
    for (int i = 0; i < m; i++) {
        u[i] = edge[i].ff;
        v[i] = edge[i].ss;
        if (pts[u[i]].ff.ff == pts[v[i]].ff.ff) {
            a[i] = (pts[u[i]].ff.ff == 2 ? 1 : 5);
            b[i] = ((pts[u[i]].ff.ss + pts[v[i]].ff.ss) >> 1);
        } else {
            a[i] = 3;
            b[i] = pts[u[i]].ff.ss - 1;
        }
    }
    build(u, v, a, b);
    return;
}
void st3() {
    
}
int construct_roads(vector<int> ox, vector<int> oy) {
    n = ox.size();
    int minx = 1e9;
    for (int i = 1; i <= n; i++) {
        pts[i] = {{ox[i - 1], oy[i - 1]}, i};
        allpts[pts[i].ff] = i;
        minx = min(minx, pts[i].ff.ff);
    }
    sort(pts + 1, pts + n + 1);
    if (!CheckConnected()) return 0;
    if (minx == 2 || minx == 4) st12();
    else if (minx == 6) st3();
    return 1;
}

Compilation message

parks.cpp: In function 'bool CheckConnected()':
parks.cpp:32:26: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     return (track.size() == n);
      |             ~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 312 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 312 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 312 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 312 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 312 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 312 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -