Submission #22141

#TimeUsernameProblemLanguageResultExecution timeMemory
22141연습대회 팀 네임은 수정할 수 있을까? (#42)구간들 (KRIII5P_3)C++14
7 / 7
149 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 += 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 (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...