# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
764621 |
2023-06-23T16:36:36 Z |
Ahmed57 |
Boat (APIO16_boat) |
C++17 |
|
1889 ms |
99160 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
long long z = 0;
long long bit[1000001];
long long mod = 1000000007;
void add(long long e,long long v){
while(e<=z){
bit[e]+=v;
bit[e]%=mod;
e+=(e&-e);
}
}
long long sum(long long e){
long long res = 0;
while(e>=1){
res+=bit[e];
res%=mod;
e-=(e&-e);
}
return res;
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n;
cin>>n;
map<long long,long long> comp,sav;
vector<pair<long long,long long>> v;
vector<long long> ans;
for(int i = 0;i<n;i++){
long long x,y;
cin>>x>>y;
v.push_back({x,y});
for(int i = x-350;i<=x+350;i++){
ans.push_back(i);
}
for(int i = y-350;i<=y+350;i++){
ans.push_back(i);
}
}
sort(ans.begin(),ans.end());
vector<pair<long long,long long>> all[n];
for(int i = 0;i<v.size();i++){
long long st = v[i].first;
while(st<=v[i].second){
int it = lower_bound(ans.begin(),ans.end(),st+1)-ans.begin();
all[i].push_back({st,ans[it]-1});
comp[st]++;comp[ans[it]-1]++;
st = ans[it];
}
}
for(auto i:comp){
sav[i.first] = ++z;
}
long long fin = 0;
for(int i = n-1;i>=0;i--){
for(auto j:all[i]){
long long val = (((sum(z)-sum(sav[j.second])+1)%mod)+mod)%mod;
long long sz = (val*((j.second-j.first+1)%mod))%mod;
fin+=sz;fin%=mod;
add(sav[j.first],sz);
}
}
cout<<fin<<endl;
}
Compilation message
boat.cpp: In function 'int main()':
boat.cpp:43:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for(int i = 0;i<v.size();i++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
8648 KB |
Output is correct |
2 |
Correct |
27 ms |
8648 KB |
Output is correct |
3 |
Correct |
26 ms |
8648 KB |
Output is correct |
4 |
Correct |
28 ms |
8648 KB |
Output is correct |
5 |
Correct |
27 ms |
8592 KB |
Output is correct |
6 |
Correct |
23 ms |
8648 KB |
Output is correct |
7 |
Correct |
23 ms |
8648 KB |
Output is correct |
8 |
Correct |
23 ms |
8648 KB |
Output is correct |
9 |
Correct |
25 ms |
8648 KB |
Output is correct |
10 |
Correct |
23 ms |
8648 KB |
Output is correct |
11 |
Correct |
23 ms |
8648 KB |
Output is correct |
12 |
Correct |
23 ms |
8648 KB |
Output is correct |
13 |
Correct |
25 ms |
8688 KB |
Output is correct |
14 |
Correct |
22 ms |
8656 KB |
Output is correct |
15 |
Correct |
23 ms |
8648 KB |
Output is correct |
16 |
Correct |
27 ms |
8648 KB |
Output is correct |
17 |
Correct |
27 ms |
8648 KB |
Output is correct |
18 |
Correct |
33 ms |
8592 KB |
Output is correct |
19 |
Correct |
29 ms |
8648 KB |
Output is correct |
20 |
Correct |
27 ms |
8648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
8648 KB |
Output is correct |
2 |
Correct |
27 ms |
8648 KB |
Output is correct |
3 |
Correct |
26 ms |
8648 KB |
Output is correct |
4 |
Correct |
28 ms |
8648 KB |
Output is correct |
5 |
Correct |
27 ms |
8592 KB |
Output is correct |
6 |
Correct |
23 ms |
8648 KB |
Output is correct |
7 |
Correct |
23 ms |
8648 KB |
Output is correct |
8 |
Correct |
23 ms |
8648 KB |
Output is correct |
9 |
Correct |
25 ms |
8648 KB |
Output is correct |
10 |
Correct |
23 ms |
8648 KB |
Output is correct |
11 |
Correct |
23 ms |
8648 KB |
Output is correct |
12 |
Correct |
23 ms |
8648 KB |
Output is correct |
13 |
Correct |
25 ms |
8688 KB |
Output is correct |
14 |
Correct |
22 ms |
8656 KB |
Output is correct |
15 |
Correct |
23 ms |
8648 KB |
Output is correct |
16 |
Correct |
27 ms |
8648 KB |
Output is correct |
17 |
Correct |
27 ms |
8648 KB |
Output is correct |
18 |
Correct |
33 ms |
8592 KB |
Output is correct |
19 |
Correct |
29 ms |
8648 KB |
Output is correct |
20 |
Correct |
27 ms |
8648 KB |
Output is correct |
21 |
Correct |
288 ms |
22468 KB |
Output is correct |
22 |
Correct |
293 ms |
22160 KB |
Output is correct |
23 |
Correct |
277 ms |
21572 KB |
Output is correct |
24 |
Correct |
304 ms |
22708 KB |
Output is correct |
25 |
Correct |
299 ms |
22792 KB |
Output is correct |
26 |
Correct |
317 ms |
22364 KB |
Output is correct |
27 |
Correct |
329 ms |
22232 KB |
Output is correct |
28 |
Correct |
347 ms |
22348 KB |
Output is correct |
29 |
Correct |
339 ms |
22444 KB |
Output is correct |
30 |
Correct |
242 ms |
53168 KB |
Output is correct |
31 |
Correct |
232 ms |
52980 KB |
Output is correct |
32 |
Correct |
238 ms |
53572 KB |
Output is correct |
33 |
Correct |
278 ms |
53604 KB |
Output is correct |
34 |
Correct |
241 ms |
53444 KB |
Output is correct |
35 |
Correct |
226 ms |
52680 KB |
Output is correct |
36 |
Correct |
231 ms |
53068 KB |
Output is correct |
37 |
Correct |
248 ms |
54888 KB |
Output is correct |
38 |
Correct |
234 ms |
53228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1889 ms |
99160 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
8648 KB |
Output is correct |
2 |
Correct |
27 ms |
8648 KB |
Output is correct |
3 |
Correct |
26 ms |
8648 KB |
Output is correct |
4 |
Correct |
28 ms |
8648 KB |
Output is correct |
5 |
Correct |
27 ms |
8592 KB |
Output is correct |
6 |
Correct |
23 ms |
8648 KB |
Output is correct |
7 |
Correct |
23 ms |
8648 KB |
Output is correct |
8 |
Correct |
23 ms |
8648 KB |
Output is correct |
9 |
Correct |
25 ms |
8648 KB |
Output is correct |
10 |
Correct |
23 ms |
8648 KB |
Output is correct |
11 |
Correct |
23 ms |
8648 KB |
Output is correct |
12 |
Correct |
23 ms |
8648 KB |
Output is correct |
13 |
Correct |
25 ms |
8688 KB |
Output is correct |
14 |
Correct |
22 ms |
8656 KB |
Output is correct |
15 |
Correct |
23 ms |
8648 KB |
Output is correct |
16 |
Correct |
27 ms |
8648 KB |
Output is correct |
17 |
Correct |
27 ms |
8648 KB |
Output is correct |
18 |
Correct |
33 ms |
8592 KB |
Output is correct |
19 |
Correct |
29 ms |
8648 KB |
Output is correct |
20 |
Correct |
27 ms |
8648 KB |
Output is correct |
21 |
Correct |
288 ms |
22468 KB |
Output is correct |
22 |
Correct |
293 ms |
22160 KB |
Output is correct |
23 |
Correct |
277 ms |
21572 KB |
Output is correct |
24 |
Correct |
304 ms |
22708 KB |
Output is correct |
25 |
Correct |
299 ms |
22792 KB |
Output is correct |
26 |
Correct |
317 ms |
22364 KB |
Output is correct |
27 |
Correct |
329 ms |
22232 KB |
Output is correct |
28 |
Correct |
347 ms |
22348 KB |
Output is correct |
29 |
Correct |
339 ms |
22444 KB |
Output is correct |
30 |
Correct |
242 ms |
53168 KB |
Output is correct |
31 |
Correct |
232 ms |
52980 KB |
Output is correct |
32 |
Correct |
238 ms |
53572 KB |
Output is correct |
33 |
Correct |
278 ms |
53604 KB |
Output is correct |
34 |
Correct |
241 ms |
53444 KB |
Output is correct |
35 |
Correct |
226 ms |
52680 KB |
Output is correct |
36 |
Correct |
231 ms |
53068 KB |
Output is correct |
37 |
Correct |
248 ms |
54888 KB |
Output is correct |
38 |
Correct |
234 ms |
53228 KB |
Output is correct |
39 |
Incorrect |
1889 ms |
99160 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |