Submission #1351241

#TimeUsernameProblemLanguageResultExecution timeMemory
1351241top1svtinStranded Far From Home (BOI22_island)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

#define kien long long
#define FOR(i, a, b) for (int i = a;i <= b; i++)
#define FORD(i, a, b) for (int i = a;i >= b; i--)
#define task "a"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)

using namespace std;
const int mxn = 2e5 + 5;
kien n, m, a[mxn], sum[mxn];

int find_set (int u) {
    return par[u] == u ? u : par[u] = find_set(par[u]);
}

void union_set (int u, int v) {
    u = find_set(u); v = find_set(v);
    if (u == v) return;
    sum[u] += sum[v];
    par[v] = u;
}

int get (int u) {
    u = find_set(u); return sum[u];
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (fopen(task".inp", "r")) {
        fin(task); fou(task);
    }
    cin >> n >> m;
    FOR (i, 1, n) cin >> a[i], pp[a[i]].pb(i), ver[a[i]].pb(i), sum[i] = a[i], ans[i] = 1;
    FOR (i, 1, m) {
        int u, v;
        cin >> u >> v;
        dp[u].pb(v); dp[v].pb(u);
    }

    for (auto i : pp) {
        for (auto u : ver[i.first]) {
            for (auto v : dp[u]) {
                /// ta có thể rút gọn a[u] <= a[v] vì u luôn thuộc ver[i.first] tức là u luôn == i.first
                if (a[u] <= a[v]) union_set(u, v);
            }
        }

        for (auto x : i.second) {
            kien tong = get(x);
            if (tong >= i.first) {
                pp[tong].pb(x);
            }
            else if (tong != n) {
                ans[x] = 0;
            }
        }
    }

    FOR (i, 1, n) cout << ans[i] << " ";
}

Compilation message (stderr)

island.cpp: In function 'int find_set(int)':
island.cpp:15:12: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   15 |     return par[u] == u ? u : par[u] = find_set(par[u]);
      |            ^~~
      |            __pstl::execution::v1::par
In file included from /usr/include/c++/13/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/13/algorithm:73,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from island.cpp:1:
/usr/include/c++/13/pstl/execution_defs.h:111:45: note: '__pstl::execution::v1::par' declared here
  111 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
island.cpp: In function 'void union_set(int, int)':
island.cpp:22:5: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   22 |     par[v] = u;
      |     ^~~
      |     __pstl::execution::v1::par
/usr/include/c++/13/pstl/execution_defs.h:111:45: note: '__pstl::execution::v1::par' declared here
  111 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
island.cpp: At global scope:
island.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main() {
      | ^~~~
island.cpp: In function 'int main()':
island.cpp:36:32: error: 'pp' was not declared in this scope
   36 |     FOR (i, 1, n) cin >> a[i], pp[a[i]].pb(i), ver[a[i]].pb(i), sum[i] = a[i], ans[i] = 1;
      |                                ^~
island.cpp:36:48: error: 'ver' was not declared in this scope
   36 |     FOR (i, 1, n) cin >> a[i], pp[a[i]].pb(i), ver[a[i]].pb(i), sum[i] = a[i], ans[i] = 1;
      |                                                ^~~
island.cpp:36:80: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |     FOR (i, 1, n) cin >> a[i], pp[a[i]].pb(i), ver[a[i]].pb(i), sum[i] = a[i], ans[i] = 1;
      |                                                                                ^~~
      |                                                                                abs
island.cpp:40:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   40 |         dp[u].pb(v); dp[v].pb(u);
      |         ^~
      |         dup
island.cpp:43:19: error: 'pp' was not declared in this scope
   43 |     for (auto i : pp) {
      |                   ^~
island.cpp:44:23: error: 'ver' was not declared in this scope
   44 |         for (auto u : ver[i.first]) {
      |                       ^~~
island.cpp:45:27: error: 'dp' was not declared in this scope; did you mean 'dup'?
   45 |             for (auto v : dp[u]) {
      |                           ^~
      |                           dup
island.cpp:57:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   57 |                 ans[x] = 0;
      |                 ^~~
      |                 abs
island.cpp:62:27: error: 'ans' was not declared in this scope; did you mean 'abs'?
   62 |     FOR (i, 1, n) cout << ans[i] << " ";
      |                           ^~~
      |                           abs
island.cpp:7:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
island.cpp:33:9: note: in expansion of macro 'fin'
   33 |         fin(task); fou(task);
      |         ^~~
island.cpp:8:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
island.cpp:33:20: note: in expansion of macro 'fou'
   33 |         fin(task); fou(task);
      |                    ^~~