Submission #1082884

#TimeUsernameProblemLanguageResultExecution timeMemory
1082884djs100201September (APIO24_september)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> // #include "september.h" #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using P = pair<ll, ll>; using PP = pair<ll, P>; const ll n_ = 1e5 + 10, inf = (ll)2e9 * (ll)1e9 + 7, mod = 998244353; ll n, m, tc = 1, a, b, c, d, sum, x, y, z, base, ans, k; ll par[n_], idx[n_][6]; ll find(ll x) { if (par[x] < 0) return x; return par[x] = find(par[x]); } void merge(ll x, ll y) { x = find(x), y = find(y); if (x == y) return; par[x] = y; } bool cmp(ll x, ll y) { return idx[x][a] < idx[y][a]; } int solve(int N, int M, vector<int> F, vector<vector<int>> S) { n = N - 1, m = M; memset(par, -1, sizeof(par)); vector<ll> T; for (int j = 0; j < m; j++) for (int i = 0; i < n; i++) idx[S[j][i]][j] = i; for (int i = 1; i <= n; i++) T.push_back(i); for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) { a = i, b = j; sort(all(T), cmp); stack<ll> st; for (auto nxt : T) { while (st.size() && idx[st.top()][b] > idx[nxt][b]) { merge(st.top(), nxt); st.pop(); } st.push(nxt); } } for (int i = 1; i <= n; i++) { x = F[i]; if (x) { for (int j = 0; j < m; j++) { if (idx[x][j] < idx[i][j]) merge(x, i); } } } ll ret = 0; for (int i = 1; i <= n; i++) { if (find(i) == i) ret++; } return ret; } int main() { cout << solve(3, 1, {-1, 0, 0}, {{1, 2}}) << endl; cout << solve(5, 2, {-1, 0, 0, 1, 1}, {{1, 2, 3, 4}, {4, 1, 2, 3}}) << endl; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccxy37N3.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctUIt06.o:september.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status