답안 #22074

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22074 2017-04-29T07:12:01 Z 아재 goto 써요?(#1011, baactree) 구간들 (KRIII5P_3) C++14
2 / 7
106 ms 5180 KB
// =====================================================================================
// 
//       Filename:  i.cpp
//        Created:  2017년 04월 29일 15시 53분 37초
//       Compiler:  g++ -O2 -std=c++14
//         Author:  baactree ,  [email protected]
//        Company:  Chonnam National University
// 
// =====================================================================================

#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int> > event;
const int mod=1000000007;
typedef long long ll;
ll _pow(ll a, ll b){
	if(b==0)
		return 1;
	ll temp=_pow(a, b/2);
	temp=(temp*temp)%mod;
	if(b&1)
		return (temp*a)%mod;
	return temp;
}
int main(){
	scanf("%d", &n);
	for(int i=0;i<n;i++){
		int a, b;
		scanf("%d%d", &a, &b);
		if(a>=b)
			continue;
		event.push_back({a, 0});
		event.push_back({b, 1});
	}
	sort(event.begin(), event.end());
	int cnt=0;
	ll len=0;
	ll ans=0;
	int pre=0;
	for(int i=0;i<event.size();i++){
		int x=event[i].first;
		int m=event[i].second;
		len+=(long long)(x-pre)*(_pow(2, cnt)-1+mod);
		len%=mod;
		if(!m){
			ans+=_pow(2, cnt);
			ans%=mod;
			cnt++;
		}
		else{
			cnt--;
		}
		pre=x;
	}
	printf("%lld %lld\n", len, ans);
	return 0;
}

Compilation message

i.cpp: In function 'int main()':
i.cpp:41:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<event.size();i++){
               ^
i.cpp:27:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
i.cpp:30:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);
                        ^
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 2024 KB Output is partially correct
2 Partially correct 0 ms 2024 KB Output is partially correct
3 Partially correct 0 ms 2024 KB Output is partially correct
4 Partially correct 0 ms 2024 KB Output is partially correct
5 Partially correct 0 ms 2024 KB Output is partially correct
6 Partially correct 9 ms 2492 KB Output is partially correct
7 Partially correct 6 ms 2492 KB Output is partially correct
8 Partially correct 3 ms 2492 KB Output is partially correct
9 Partially correct 6 ms 2492 KB Output is partially correct
10 Partially correct 6 ms 2492 KB Output is partially correct
11 Partially correct 79 ms 5180 KB Output is partially correct
12 Partially correct 83 ms 5180 KB Output is partially correct
13 Partially correct 96 ms 5180 KB Output is partially correct
14 Partially correct 93 ms 5180 KB Output is partially correct
15 Partially correct 89 ms 5180 KB Output is partially correct
16 Partially correct 56 ms 3644 KB Output is partially correct
17 Partially correct 63 ms 3644 KB Output is partially correct
18 Correct 59 ms 3644 KB Output is correct
19 Partially correct 63 ms 3644 KB Output is partially correct
20 Partially correct 53 ms 3644 KB Output is partially correct
21 Partially correct 89 ms 5180 KB Output is partially correct
22 Partially correct 93 ms 5180 KB Output is partially correct
23 Partially correct 99 ms 5180 KB Output is partially correct
24 Partially correct 93 ms 5180 KB Output is partially correct
25 Partially correct 73 ms 5180 KB Output is partially correct
26 Partially correct 96 ms 5180 KB Output is partially correct
27 Partially correct 89 ms 5180 KB Output is partially correct
28 Partially correct 96 ms 5180 KB Output is partially correct
29 Partially correct 103 ms 5180 KB Output is partially correct
30 Partially correct 89 ms 5180 KB Output is partially correct
31 Partially correct 96 ms 5180 KB Output is partially correct
32 Partially correct 96 ms 5180 KB Output is partially correct
33 Partially correct 86 ms 5180 KB Output is partially correct
34 Partially correct 86 ms 5180 KB Output is partially correct
35 Partially correct 89 ms 5180 KB Output is partially correct
36 Partially correct 106 ms 5180 KB Output is partially correct
37 Partially correct 83 ms 5180 KB Output is partially correct
38 Partially correct 106 ms 5180 KB Output is partially correct
39 Partially correct 99 ms 5180 KB Output is partially correct
40 Partially correct 76 ms 5180 KB Output is partially correct
41 Correct 0 ms 2024 KB Output is correct
42 Correct 0 ms 2024 KB Output is correct
43 Correct 3 ms 2164 KB Output is correct
44 Correct 0 ms 2164 KB Output is correct
45 Correct 36 ms 3644 KB Output is correct
46 Correct 33 ms 3644 KB Output is correct
47 Correct 39 ms 3644 KB Output is correct
48 Partially correct 79 ms 5180 KB Output is partially correct
49 Correct 79 ms 5180 KB Output is correct
50 Correct 79 ms 5180 KB Output is correct