Submission #473444

# Submission time Handle Problem Language Result Execution time Memory
473444 2021-09-15T14:19:38 Z OttoTheDino Fish (IOI08_fish) C++17
0 / 100
313 ms 28156 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,e)                  for (ll i = s; i <= e; ++i)
#define pb                          push_back
#define fi                          first
#define se                          second
#define all(a)                      a.begin(), a.end()
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;

const ll mx = 5e5+5;

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

    ll f, k, m; cin >> f >> k >> m;
    vii bois;
    rep (i,0,f-1) {
        ll l, tp; cin >> l >> tp;
        bois.pb({l, tp});
    }

    sort(all(bois));
    ll id = 0, cnt[mx] = {}, num[mx], ans = 0, been[mx] = {};
    set<ll> st;

    for (ii boi : bois) {
        ll l = boi.fi, tp = boi.se, g = !been[tp];
        while (l >= 2*bois[id].fi) {
            if (--num[cnt[bois[id].se]]==0) st.erase(cnt[bois[id].se]);
            if (num[++cnt[bois[id].se]]++==0) st.insert(cnt[bois[id].se]);
            if (bois[id].se==tp) g++;
            id++;
        }
        ll res = 1;
        for (ll el : st) res = res*el*num[el]%m;
        ans = (ans+res*g)%m;
        been[tp] = 1;
    }

    cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11980 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11980 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 11980 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11968 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 11980 KB Output is correct
2 Incorrect 8 ms 12016 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 11980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 12040 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 12192 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 150 ms 17988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12052 KB Output is correct
2 Incorrect 9 ms 12316 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 202 ms 24088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 198 ms 26104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 207 ms 24244 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 304 ms 25428 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 313 ms 27388 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 176 ms 24648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 206 ms 26392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 232 ms 24384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 241 ms 28156 KB Output isn't correct
2 Halted 0 ms 0 KB -