Submission #22141

# Submission time Handle Problem Language Result Execution time Memory
22141 2017-04-29T11:42:39 Z 연습대회 팀 네임은 수정할 수 있을까?(#1024, qja0950) None (KRIII5P_3) C++14
7 / 7
149 ms 5472 KB
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <string.h>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<int, int> pi;

const int MAX_N = 1e5 + 100, MOD = 1e9 + 7;

int ab(int a, int b) {
	int res = 1, val = a;
	while(b) {
		if(b%2) res = 1ll * res * val % MOD;
		val = 1ll * val * val % MOD;
		b/=2;
	}
	return res;
}
int N, Cnt[MAX_N * 2], RCnt[MAX_N * 2];
int main() {
	vector<pi> Is;
	vector<int> cor;
	scanf("%d", &N);
	for(int i=0; i<N; i++) {
		int x, y; scanf("%d%d", &x, &y);
		if(x >= y) continue;
		Is.emplace_back(x, y);
		cor.push_back(x); cor.push_back(y);
	}
	N = Is.size(); cor.push_back(-1); cor.push_back(1e9 + 10);
	sort(cor.begin(), cor.end()); cor.erase(unique(cor.begin(), cor.end()), cor.end());
	for(pi &e : Is) {
		int &x = e.first, &y = e.second;
		x = lower_bound(cor.begin(), cor.end(), x) - cor.begin();
		y = lower_bound(cor.begin(), cor.end(), y) - cor.begin() - 1;
		Cnt[x]++; Cnt[y+1]--;
		RCnt[y]++; RCnt[y+1]--;
	}
	int cnt = 0, rcnt = 0;
	int len = 0, ans = 0;
	for(int l=0; l<cor.size(); l++) {
		cnt += Cnt[l];
		rcnt += RCnt[l];
		len += 1ll * (ab(2, cnt) - 1) * (cor[l+1] - cor[l]) % MOD; len %= MOD;
		ans += 1ll * (ab(2, rcnt) - 1) * ab(2, cnt-rcnt) % MOD; ans %= MOD;
	}
	printf("%d %d\n", len, ans);
	return 0;
}

Compilation message

i.cpp: In function 'int main()':
i.cpp:50:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int l=0; l<cor.size(); l++) {
                ^
i.cpp:32:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
i.cpp:34:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x, y; scanf("%d%d", &x, &y);
                                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2740 KB Output is correct
2 Correct 0 ms 2740 KB Output is correct
3 Correct 0 ms 2740 KB Output is correct
4 Correct 0 ms 2740 KB Output is correct
5 Correct 0 ms 2740 KB Output is correct
6 Correct 3 ms 3032 KB Output is correct
7 Correct 3 ms 3032 KB Output is correct
8 Correct 3 ms 3032 KB Output is correct
9 Correct 3 ms 3032 KB Output is correct
10 Correct 3 ms 3032 KB Output is correct
11 Correct 46 ms 5472 KB Output is correct
12 Correct 49 ms 5472 KB Output is correct
13 Correct 53 ms 5472 KB Output is correct
14 Correct 63 ms 5472 KB Output is correct
15 Correct 49 ms 5472 KB Output is correct
16 Correct 93 ms 4192 KB Output is correct
17 Correct 103 ms 4192 KB Output is correct
18 Correct 83 ms 4192 KB Output is correct
19 Correct 83 ms 4192 KB Output is correct
20 Correct 63 ms 4192 KB Output is correct
21 Correct 136 ms 5472 KB Output is correct
22 Correct 149 ms 5472 KB Output is correct
23 Correct 126 ms 5472 KB Output is correct
24 Correct 133 ms 5472 KB Output is correct
25 Correct 36 ms 5472 KB Output is correct
26 Correct 99 ms 5472 KB Output is correct
27 Correct 103 ms 5472 KB Output is correct
28 Correct 106 ms 5472 KB Output is correct
29 Correct 86 ms 5472 KB Output is correct
30 Correct 89 ms 5472 KB Output is correct
31 Correct 89 ms 5472 KB Output is correct
32 Correct 99 ms 5472 KB Output is correct
33 Correct 69 ms 5472 KB Output is correct
34 Correct 66 ms 5472 KB Output is correct
35 Correct 63 ms 5472 KB Output is correct
36 Correct 149 ms 5472 KB Output is correct
37 Correct 139 ms 5472 KB Output is correct
38 Correct 146 ms 5472 KB Output is correct
39 Correct 146 ms 5472 KB Output is correct
40 Correct 133 ms 5472 KB Output is correct
41 Correct 0 ms 2740 KB Output is correct
42 Correct 0 ms 2740 KB Output is correct
43 Correct 3 ms 2900 KB Output is correct
44 Correct 3 ms 2900 KB Output is correct
45 Correct 39 ms 4192 KB Output is correct
46 Correct 46 ms 4192 KB Output is correct
47 Correct 43 ms 4192 KB Output is correct
48 Correct 86 ms 5472 KB Output is correct
49 Correct 89 ms 5472 KB Output is correct
50 Correct 79 ms 5472 KB Output is correct