답안 #1059430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059430 2024-08-15T00:13:03 Z Trent 분수 공원 (IOI21_parks) C++17
컴파일 오류
0 ms 0 KB
#include "parks.h"
#include "bits/stdc++.h"
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef set<int> si;
struct pii{int a, b;};
bool operator <(pii a, pii b) {return a.a < b.a || a.a == b.a && a.b < b.b;}
const int MD = 2e5 + 10;

int dir[4][2] = {{2, 0}, {0, -2}, {-2, 0}, {0, 2}};
vvi chk = {{-1, 1, 1, 1, 0, 2}, {1, 1, 1, -1, 2, 0}, {1, -1, -1, -1, 0, -2}, {-1, -1, -1, 1, -2, 0}};
bool conn(int n, vi& u, vi& v) {
    vvi adj(n);
    forR(i, u.size()) {
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }
    vb vis(n);
    vi dfs = {0};
    while(!dfs.empty()) {
        int cur = dfs.back(); dfs.pop_back();
        if(!vis[cur]) {
            vis[cur] = true;
            for(int i : adj[cur]) if(!vis[i]) {
                dfs.push_back(i);
            }
        }
    }
    forR(i, n) if(!vis[i]) return false;
    return true;
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
    int n = x.size();
    map<pii, int> ci;
    set<pii> bnch;
    forR(i, n) ci[{x[i], y[i]}] = i;
    vi u, v, a, b;

    for(auto [pos, id] : ci) {
        forR(i, 4) {
            int nx=pos.a+dir[i][0], ny=pos.b+dir[i][1];
            if(ci.count({nx, ny})) {
                u.push_back(id);
                v.push_back(ci[{nx, ny}]);
                a.push_back(0);
                b.push_back(0);
            }
        }
    }
    if(!conn(n, u, v)) return 0;
    int m = u.size();
    vb done(m);
    forR(i, m) if(!done[i]){
        int xc=x[v[i]] - x[u[i]], yc=y[v[i]]-y[u[i]];
        vector<pii> ch;
        if(xc == 0) {
            ch.push_back({x[u[i]] + 1, y[u[i]] + yc / 2});
            ch.push_back({x[u[i]] - 1, y[u[i]] + yc/2});
        } else {
            assert(yc == 0);
            ch.push_back({x[u[i]] + xc / 2, y[u[i]] + 1});
            ch.push_back({x[u[i]] + xc / 2, y[u[i]] - 1});
        }
        forR(j, 2) {
            si vis;
            vi dfs = {i};
            a[i] = ch[j].a, b[i] = ch[j].b;
            vis.insert(i);
            while(!dfs.empty()) {
                int cur = dfs.back(); dfs.pop_back();
                for(auto [ac1, bc1, ac2, bc2, nac, nbc] : chk) {

                }
            }
        }
    }
}

Compilation message

parks.cpp: In function 'bool operator<(pii, pii)':
parks.cpp:12:63: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   12 | bool operator <(pii a, pii b) {return a.a < b.a || a.a == b.a && a.b < b.b;}
      |                                                    ~~~~~~~~~~~^~~~~~~~~~~~
parks.cpp: In function 'bool conn(int, vi&, vi&)':
parks.cpp:4:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define forR(i, x) for(int i = 0; i < (x); ++i)
      |                                     ^
parks.cpp:19:5: note: in expansion of macro 'forR'
   19 |     forR(i, u.size()) {
      |     ^~~~
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:76:26: error: 6 names provided for structured binding
   76 |                 for(auto [ac1, bc1, ac2, bc2, nac, nbc] : chk) {
      |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parks.cpp:76:26: note: while 'std::vector<int>' decomposes into 1 element
parks.cpp:75:21: warning: unused variable 'cur' [-Wunused-variable]
   75 |                 int cur = dfs.back(); dfs.pop_back();
      |                     ^~~
parks.cpp:39:19: warning: control reaches end of non-void function [-Wreturn-type]
   39 |     map<pii, int> ci;
      |                   ^~