제출 #69134

#제출 시각아이디문제언어결과실행 시간메모리
69134Just_Solve_The_ProblemPort Facility (JOI17_port_facility)C++11
0 / 100
4 ms248 KiB
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define OK puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");

const int N = (int)1e6 + 7;
const int inf = (int)1e9 + 7;
int mod = (int)1e9 + 7;

pii ar[N];
int pr[N];
int ans;
int div2;

int mult(int a, int b) {
  return (a * 1LL * b) % mod;
}

int binpow(int a, int n) {
  int res = 1;
  while (n > 0) {
    if (n & 1)
      res = mult(res, a);
    a = mult(a, a);
    n >>= 1;
  }
  return res;
}

int getpar(int a) {
  if (pr[a] == a) return a;
  return pr[a] = getpar(pr[a]);
}

void connect(int a, int b) {
  a = getpar(a);
  b = getpar(b);
  if (a != b) {
    pr[a] = b;
  }
}

main() {
  int n;
  scanf("%d", &n);
  iota(pr, pr + n, 0);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &ar[i].fr, &ar[i].sc);
  }
  sort(ar, ar + n);
  div2 = binpow(2, mod - 2);
  int ans = binpow(2, n);
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    set < int > s;
    for (int j = 0; j < i; j++) {
      if (ar[j].sc < ar[i].sc && ar[j].sc > ar[i].fr) {
        s.insert(getpar(j));
      } else {
        connect(i, j);
      }
    }
    cnt = s.size();
//    cout << cnt << endl;
    if (cnt > 1) {
      ans = 0;
    } else if (cnt > 0) {
      ans = mult(ans, div2);
    }
  }
  cout << ans;
}

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

port_facility.cpp:55:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
port_facility.cpp: In function 'int main()':
port_facility.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
port_facility.cpp:60:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &ar[i].fr, &ar[i].sc);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...