Submission #403377

# Submission time Handle Problem Language Result Execution time Memory
403377 2021-05-13T06:08:52 Z JerryLiu06 Plahte (COCI17_plahte) C++17
0 / 160
277 ms 31620 KB
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using db = long double;
using str = string;
 
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
 
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
 
#define mp make_pair
#define f first
#define s second

#define sz(x) (int)(x).size()
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define sor(x) sort(all(x))
#define ft front()
#define bk back()
#define pb push_back
#define pf push_front
 
#define lb lower_bound
#define ub upper_bound
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a)
#define EACH(a, x) for (auto& a : x)

const int MOD = 1e9 + 7;
const int MX = 8e4 + 10;
const ll INF = 1e18;

using pp = pair<pi, int>;

int N, M; vector<pp> E; int B[MX], D[MX], Y[MX], C[MX]; // Bottom, Top

int par[MX]; set<pp> active; unordered_set<int> col[MX]; vi child[MX]; int ans[MX];

int getPar(int Y) {
    auto IT = active.lb({{Y, -MOD}, -MOD});

    if (IT == active.end()) return -1;

    if ((*IT).f.s == -1) return par[(*IT).s]; return (*IT).s;
}
void DFS(int X) {
    EACH(Y, child[X]) {
        DFS(Y); if (sz(col[X]) < sz(col[Y])) swap(col[X], col[Y]);

        EACH(C, col[Y]) col[X].insert(C); col[Y].clear();
    }
    ans[X] = sz(col[X]);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);

    cin >> N >> M; F0R(i, N) {
        int A, C; cin >> A >> B[i] >> C >> D[i];

        E.pb({{A, -1}, i}); E.pb({{C, 1}, i}); 
    }
    F0R(i, M) { int X; cin >> X >> Y[i] >> C[i]; E.pb({{X, 0}, i}); }

    sort(all(E)); EACH(P, E) {
        
        if (P.f.s == -1) { par[P.s] = getPar(D[P.s]);
            active.insert({{B[P.s], -1}, P.s}); active.insert({{D[P.s], 1}, P.s});
        }
        else if (P.f.s == 0) { int par = getPar(Y[P.s]); if (par != -1) col[getPar(Y[P.s])].insert(C[P.s]); }

        else { active.erase({{B[P.s], -1}, P.s}); active.erase({{D[P.s], 1}, P.s}); }
    }
    F0R(i, N) if (par[i] != -1) child[par[i]].pb(i);

    F0R(i, N) if (par[i] == -1) DFS(i); F0R(i, N) cout << ans[i] << "\n";
}

Compilation message

plahte.cpp: In function 'int getPar(int)':
plahte.cpp:59:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   59 |     if ((*IT).f.s == -1) return par[(*IT).s]; return (*IT).s;
      |     ^~
plahte.cpp:59:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   59 |     if ((*IT).f.s == -1) return par[(*IT).s]; return (*IT).s;
      |                                               ^~~~~~
plahte.cpp: In function 'void DFS(int)':
plahte.cpp:42:20: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   42 | #define EACH(a, x) for (auto& a : x)
      |                    ^~~
plahte.cpp:65:9: note: in expansion of macro 'EACH'
   65 |         EACH(C, col[Y]) col[X].insert(C); col[Y].clear();
      |         ^~~~
plahte.cpp:65:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   65 |         EACH(C, col[Y]) col[X].insert(C); col[Y].clear();
      |                                           ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 12196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 15244 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 144 ms 22700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 253 ms 31620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 277 ms 29476 KB Output isn't correct
2 Halted 0 ms 0 KB -