# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1099829 |
2024-10-12T05:31:33 Z |
model_code |
Tree (IOI24_tree) |
C++17 |
|
51 ms |
8112 KB |
// incorrect/mruxim-w01-overflow.cpp
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##__n = (int)(n); i < i##__n; ++i)
#define fer(i, a, b) for(int i = (int)(a), i##__b = (int)(b); i < i##__b; ++i)
#define rof(i, b, a) for(int i = (int)(b), i##__a = (int)(a); i-- > i##__a; )
#define sz(x) (int((x).size()))
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
//#define endl '\n'
template<class P, class Q> inline void smin(P &a, Q b) { if (b < a) a = b; }
template<class P, class Q> inline void smax(P &a, Q b) { if (a < b) a = b; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
////////////////////////////////////////////////////////////////////////////////
const int maxn = 300'000 + 100;
int n;
vector<int> p, w;
int cnt[maxn];
int leaves_cnt[maxn];
int leaves_sum;
vector<int> cnts;
vector<int> psum;
void init(vector<int> _p, vector<int> _w) {
p = _p, w = _w;
n = sz(p);
fer(i, 1, n) cnt[p[i]]++;
leaves_sum = 0;
rof(i, n, 0) {
leaves_sum += (cnt[i] == 0 ? w[i] : 0);
leaves_cnt[i] += (cnt[i] == 0 || w[i] == 0 ? 1 : 0);
if(i > 0 && w[p[i]] == 1)
leaves_cnt[p[i]] += leaves_cnt[i];
else if(w[i] == 1)
cnts.pb(leaves_cnt[i]);
}
sort(all(cnts));
psum.assign(sz(cnts) + 1, 0);
partial_sum(all(cnts), psum.begin() + 1);
}
ll query(int l, int r) {
int pos = upper_bound(all(cnts), r / l) - cnts.begin();
return leaves_sum * (ll)l + (psum.back() - psum[pos]) * (ll)l - (sz(psum) - 1 - pos) * r;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
6368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
7620 KB |
Output is correct |
2 |
Correct |
47 ms |
7732 KB |
Output is correct |
3 |
Correct |
48 ms |
7728 KB |
Output is correct |
4 |
Correct |
47 ms |
7872 KB |
Output is correct |
5 |
Correct |
48 ms |
7732 KB |
Output is correct |
6 |
Correct |
46 ms |
7596 KB |
Output is correct |
7 |
Correct |
47 ms |
7732 KB |
Output is correct |
8 |
Correct |
42 ms |
6964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
7620 KB |
Output is correct |
2 |
Correct |
47 ms |
7732 KB |
Output is correct |
3 |
Correct |
48 ms |
7728 KB |
Output is correct |
4 |
Correct |
47 ms |
7872 KB |
Output is correct |
5 |
Correct |
48 ms |
7732 KB |
Output is correct |
6 |
Correct |
46 ms |
7596 KB |
Output is correct |
7 |
Correct |
47 ms |
7732 KB |
Output is correct |
8 |
Correct |
42 ms |
6964 KB |
Output is correct |
9 |
Incorrect |
51 ms |
8112 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
6356 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
26 ms |
6368 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |