# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
347674 |
2021-01-13T10:16:26 Z |
saral |
Meteors (POI11_met) |
C++14 |
|
4109 ms |
34976 KB |
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
const int N = 300100;
int t, n, m;
vector<int>states[N], pos, v;
lli tour[N*6], ness[N], OFF, sol[N], a, Q;
pair<pair<lli, lli>, lli> q[N];
void update (int l, int r, int x, int y, int node, lli value) {
if (x <= l && r <= y) {
tour[node]+=value;
return;
}
if (r < x || l > y) return;
int mid = (l+r)/2;
update (l, mid, x, y, node*2, value);
update (mid+1, r, x, y, node*2+1, value);
return;
}
lli get (int x) {
lli rez=0;
x = x+OFF-1;
rez += tour[x];
x/=2;
while (x) {
rez+=tour[x];
x/=2;
}
return rez;
}
void f (int l, int r, vector<int> pos) {
/*cout << l << " " << r << endl;
for(int i = 0; i < pos.size(); i++){
cout << pos[i] << " ";
}
cout<< endl;
system("pause");*/
int lb, rb;
lli val;
if (l==r) {
for (int i = 0; i < pos.size(); i++) {
sol[pos[i]]=l;
}
return;
}
int mid = (l+r)/2;
vector<int>left;
vector<int>right;
for (int i = l; i <= mid; i++) {
lb = q[i].first.first, rb = q[i].first.second, val = q[i].second;
if (lb <= rb) {
update (1, OFF, lb, rb, 1, val);
}
else {
update (1, OFF, lb, m, 1, val);
update (1, OFF, 1, rb, 1, val);
}
}
for (int i = 0; i < pos.size(); i++) {
lli zbr = 0;
for (int j = 0; j < states[pos[i]].size(); j++) {
zbr += get (states[pos[i]][j]);
}
if (zbr >= ness[pos[i]]) {
left.push_back(pos[i]);
}
else right.push_back(pos[i]);
//cout << pos[i] << " " << zbr << endl;
}
//cout << endl;
f (mid+1, r, right);
for (int i = l; i <= mid; i++) {
lb = q[i].first.first, rb = q[i].first.second, val = q[i].second;
if (lb <= rb) {
update (1, OFF, lb, rb, 1, -val);
}
else {
update (1, OFF, lb, m, 1, -val);
update (1, OFF, 1, rb, 1, -val);
}
}
f (l, mid, left);
return;
}
void solve () {
cin >> n >> m;
for (int i = 1; i <= m; i++) {
cin >> a;
states[a].push_back(i);
}
OFF=1;
while (OFF < m) OFF*=2;
for (int i = 1; i <= n; i++) cin >> ness[i];
cin >> Q;
for (int i = 1; i <= Q; i++) cin >> q[i].first.first >> q[i].first.second >> q[i].second;
for (int i = 1; i <= n; i++) v.push_back(i);
f (1, Q+1, v);
for (int i = 1; i <= n; i++) {
if (sol[i] > Q) cout << "NIE\n";
else cout << sol[i] << "\n";
}
return;
}
int main () {
solve();
return 0;
}
Compilation message
met.cpp: In function 'void f(int, int, std::vector<int>)':
met.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for (int i = 0; i < pos.size(); i++) {
| ~~^~~~~~~~~~~~
met.cpp:67:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for (int i = 0; i < pos.size(); i++) {
| ~~^~~~~~~~~~~~
met.cpp:69:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for (int j = 0; j < states[pos[i]].size(); j++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7404 KB |
Output is correct |
2 |
Correct |
10 ms |
7532 KB |
Output is correct |
3 |
Correct |
11 ms |
7404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7532 KB |
Output is correct |
2 |
Correct |
10 ms |
7532 KB |
Output is correct |
3 |
Correct |
12 ms |
7532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
313 ms |
10440 KB |
Output is correct |
2 |
Correct |
473 ms |
13656 KB |
Output is correct |
3 |
Correct |
472 ms |
10548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
397 ms |
10264 KB |
Output is correct |
2 |
Correct |
408 ms |
10220 KB |
Output is correct |
3 |
Correct |
435 ms |
12488 KB |
Output is correct |
4 |
Correct |
72 ms |
10128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
171 ms |
10092 KB |
Output is correct |
2 |
Correct |
293 ms |
12780 KB |
Output is correct |
3 |
Correct |
188 ms |
8556 KB |
Output is correct |
4 |
Correct |
350 ms |
10836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
390 ms |
9836 KB |
Output is correct |
2 |
Correct |
378 ms |
10304 KB |
Output is correct |
3 |
Correct |
331 ms |
9964 KB |
Output is correct |
4 |
Correct |
400 ms |
11756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4109 ms |
34976 KB |
Output is correct |
2 |
Incorrect |
2041 ms |
22460 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3943 ms |
31328 KB |
Output is correct |
2 |
Incorrect |
1250 ms |
22508 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |