# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
22916 |
2017-04-30T12:53:18 Z |
dotorya |
None (KRIII5P_3) |
C++14 |
|
156 ms |
46568 KB |
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 1034567890123456789ll;
const db PI = acos(-1);
const db ERR = 1E-11;
int bit[300000];
void update(int p, int v) {
for (p++; p <= IT_MAX; p += p & (-p)) bit[p] += v;
}
int getsum(int p) {
int rv = 0;
for (p++; p; p -= p & (-p)) rv += bit[p];
return rv;
}
vector <pair<pll, int>> Vq;
vector <pll> in;
vector <ll> Vx;
ll po2[100050];
int main() {
int N, i;
scanf("%d", &N);
for (i = 1; i <= N; i++) {
int t1, t2;
scanf("%d %d", &t1, &t2);
if (t1 < t2) in.emplace_back(t1, t2);
Vx.push_back(t1);
Vx.push_back(t2);
}
sort(all(Vx));
Vx.erase(unique(all(Vx)), Vx.end());
for (auto &it : in) {
it.first = lower_bound(all(Vx), it.first) - Vx.begin();
it.second = lower_bound(all(Vx), it.second) - Vx.begin();
}
sort(all(in));
ll a1 = 0, a2 = 0;
po2[0] = 1;
for (i = 1; i <= 100030; i++) po2[i] = po2[i - 1] * 2 % MOD;
for (i = 0; i + 1 < Vx.size(); i++) {
Vq.emplace_back(pll(i, i + 1), 1);
Vq.emplace_back(pll(i, i + 1), 2);
if (i) Vq.emplace_back(pll(i - 1, i + 1), 3);
}
sort(all(Vq));
int p = 0;
for (auto it : Vq) {
ll t1 = it.first.first, t2 = it.first.second, t3 = it.second;
while (p < in.size()) {
if (in[p].first > t1) break;
update(in[p++].second, 1);
}
ll v = getsum(Vx.size()) - getsum(t2 - 1);
v = po2[v] - 1;
if (t3 == 1) a1 = (a1 + v * (Vx[t1+1] - Vx[t1])) % MOD;
if (t3 == 2) a2 = (a2 + v) % MOD;
if (t3 == 3) a2 = (a2 + MOD - v) % MOD;
}
return !printf("%lld %lld\n", a1, a2);
}
Compilation message
i.cpp:22:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable:4996)
^
i.cpp:23:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/STACK:336777216")
^
i.cpp: In function 'int main()':
i.cpp:89:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i + 1 < Vx.size(); i++) {
^
i.cpp:99:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (p < in.size()) {
^
i.cpp:69:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &N);
^
i.cpp:72:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &t1, &t2);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3980 KB |
Output is correct |
2 |
Correct |
0 ms |
3980 KB |
Output is correct |
3 |
Correct |
0 ms |
3980 KB |
Output is correct |
4 |
Correct |
0 ms |
3980 KB |
Output is correct |
5 |
Correct |
0 ms |
3980 KB |
Output is correct |
6 |
Correct |
3 ms |
4660 KB |
Output is correct |
7 |
Correct |
3 ms |
4660 KB |
Output is correct |
8 |
Correct |
3 ms |
4660 KB |
Output is correct |
9 |
Correct |
6 ms |
4660 KB |
Output is correct |
10 |
Correct |
6 ms |
4660 KB |
Output is correct |
11 |
Correct |
69 ms |
9272 KB |
Output is correct |
12 |
Correct |
73 ms |
9272 KB |
Output is correct |
13 |
Correct |
76 ms |
9272 KB |
Output is correct |
14 |
Correct |
63 ms |
9272 KB |
Output is correct |
15 |
Correct |
66 ms |
9272 KB |
Output is correct |
16 |
Correct |
129 ms |
45540 KB |
Output is correct |
17 |
Correct |
116 ms |
45544 KB |
Output is correct |
18 |
Correct |
113 ms |
45544 KB |
Output is correct |
19 |
Correct |
126 ms |
45544 KB |
Output is correct |
20 |
Correct |
63 ms |
8676 KB |
Output is correct |
21 |
Correct |
143 ms |
46568 KB |
Output is correct |
22 |
Correct |
143 ms |
46568 KB |
Output is correct |
23 |
Correct |
139 ms |
46568 KB |
Output is correct |
24 |
Correct |
156 ms |
46568 KB |
Output is correct |
25 |
Correct |
63 ms |
9272 KB |
Output is correct |
26 |
Correct |
133 ms |
28136 KB |
Output is correct |
27 |
Correct |
116 ms |
18920 KB |
Output is correct |
28 |
Correct |
109 ms |
18920 KB |
Output is correct |
29 |
Correct |
109 ms |
14312 KB |
Output is correct |
30 |
Correct |
103 ms |
14312 KB |
Output is correct |
31 |
Correct |
93 ms |
11236 KB |
Output is correct |
32 |
Correct |
86 ms |
9696 KB |
Output is correct |
33 |
Correct |
89 ms |
9272 KB |
Output is correct |
34 |
Correct |
76 ms |
9272 KB |
Output is correct |
35 |
Correct |
83 ms |
9272 KB |
Output is correct |
36 |
Correct |
156 ms |
46568 KB |
Output is correct |
37 |
Correct |
136 ms |
46568 KB |
Output is correct |
38 |
Correct |
156 ms |
46568 KB |
Output is correct |
39 |
Correct |
146 ms |
46568 KB |
Output is correct |
40 |
Correct |
143 ms |
46568 KB |
Output is correct |
41 |
Correct |
0 ms |
4288 KB |
Output is correct |
42 |
Correct |
0 ms |
4288 KB |
Output is correct |
43 |
Correct |
0 ms |
4852 KB |
Output is correct |
44 |
Correct |
3 ms |
4852 KB |
Output is correct |
45 |
Correct |
49 ms |
16104 KB |
Output is correct |
46 |
Correct |
43 ms |
16104 KB |
Output is correct |
47 |
Correct |
49 ms |
16104 KB |
Output is correct |
48 |
Correct |
93 ms |
28136 KB |
Output is correct |
49 |
Correct |
96 ms |
28136 KB |
Output is correct |
50 |
Correct |
99 ms |
28136 KB |
Output is correct |