제출 #22140

#제출 시각아이디문제언어결과실행 시간메모리
22140연습대회 팀 네임은 수정할 수 있을까? (#42)구간들 (KRIII5P_3)C++14
2 / 7
163 ms5472 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...