Submission #22140

# Submission time Handle Problem Language Result Execution time Memory
22140 2017-04-29T11:40:03 Z 연습대회 팀 네임은 수정할 수 있을까?(#1024, qja0950) None (KRIII5P_3) C++14
2 / 7
163 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 += (ab(2, cnt) - 1); 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 Partially correct 0 ms 2740 KB Output is partially correct
2 Partially correct 0 ms 2740 KB Output is partially correct
3 Partially correct 0 ms 2740 KB Output is partially correct
4 Partially correct 0 ms 2740 KB Output is partially correct
5 Partially correct 0 ms 2740 KB Output is partially correct
6 Partially correct 3 ms 3032 KB Output is partially correct
7 Partially correct 3 ms 3032 KB Output is partially correct
8 Partially correct 0 ms 3032 KB Output is partially correct
9 Partially correct 3 ms 3032 KB Output is partially correct
10 Partially correct 3 ms 3032 KB Output is partially correct
11 Partially correct 53 ms 5472 KB Output is partially correct
12 Partially correct 46 ms 5472 KB Output is partially correct
13 Partially correct 53 ms 5472 KB Output is partially correct
14 Partially correct 39 ms 5472 KB Output is partially correct
15 Partially correct 49 ms 5472 KB Output is partially correct
16 Partially correct 79 ms 4192 KB Output is partially correct
17 Partially correct 76 ms 4192 KB Output is partially correct
18 Partially correct 83 ms 4192 KB Output is partially correct
19 Partially correct 79 ms 4192 KB Output is partially correct
20 Correct 66 ms 4192 KB Output is correct
21 Partially correct 163 ms 5472 KB Output is partially correct
22 Partially correct 129 ms 5472 KB Output is partially correct
23 Partially correct 133 ms 5472 KB Output is partially correct
24 Partially correct 123 ms 5472 KB Output is partially correct
25 Correct 36 ms 5472 KB Output is correct
26 Partially correct 99 ms 5472 KB Output is partially correct
27 Partially correct 113 ms 5472 KB Output is partially correct
28 Partially correct 93 ms 5472 KB Output is partially correct
29 Partially correct 83 ms 5472 KB Output is partially correct
30 Partially correct 76 ms 5472 KB Output is partially correct
31 Partially correct 76 ms 5472 KB Output is partially correct
32 Partially correct 69 ms 5472 KB Output is partially correct
33 Partially correct 63 ms 5472 KB Output is partially correct
34 Partially correct 63 ms 5472 KB Output is partially correct
35 Partially correct 53 ms 5472 KB Output is partially correct
36 Partially correct 139 ms 5472 KB Output is partially correct
37 Partially correct 133 ms 5472 KB Output is partially correct
38 Partially correct 156 ms 5472 KB Output is partially correct
39 Partially correct 139 ms 5472 KB Output is partially correct
40 Partially correct 149 ms 5472 KB Output is partially correct
41 Partially correct 0 ms 2740 KB Output is partially correct
42 Partially correct 0 ms 2740 KB Output is partially correct
43 Partially correct 3 ms 2900 KB Output is partially correct
44 Partially correct 3 ms 2900 KB Output is partially correct
45 Partially correct 43 ms 4192 KB Output is partially correct
46 Partially correct 49 ms 4192 KB Output is partially correct
47 Partially correct 43 ms 4192 KB Output is partially correct
48 Partially correct 73 ms 5472 KB Output is partially correct
49 Partially correct 106 ms 5472 KB Output is partially correct
50 Partially correct 83 ms 5472 KB Output is partially correct