Submission #2206075


Source Code Expand

#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
using Line = tuple<int, int, int>;
const ll MOD = 998244353ll;

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

ll mod_pow(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

Line getNormalizedLine(int x1, int y1, int x2, int y2) {
  int a = y2 - y1;
  int b = x1 - x2;
  int c = (-a * x1) + (-b * y1);
  int g = gcd(abs(a), abs(b));
  a /= g;
  b /= g;
  c /= g;
  if (a < 0) {
    a = -a;
    b = -b;
    c = -c;
  }
  if (a == 0 && b < 0) {
    b = -b;
    c = -c;
  }
  return Line(a, b, c);
}

int main() {
  int N;
  while (cin >> N) {
    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++) {
      cin >> x[i] >> y[i];
    }
    map<Line, set<int>> linePoints;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        Line line = getNormalizedLine(x[i], y[i], x[j], y[j]);
        linePoints[line].insert(i);
        linePoints[line].insert(j);
      }
    }
    ll ans = mod_pow(2, N);
    ans = (ans - 1 + MOD) % MOD;
    ans = (ans - N + MOD) % MOD;
    for (auto& entry : linePoints) {
      int k = entry.second.size();
      ll ng = (mod_pow(2, k) - k - 1 + MOD) % MOD;
      ans = (ans - ng + MOD) % MOD;
    }
    cout << ans << endl;
  }
  return 0;
}

Submission Info

Submission Time
Task E - ConvexScore
User kroton
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1600 Byte
Status AC
Exec Time 15 ms
Memory 4224 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 36
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt
Case Name Status Exec Time Memory
0_000.txt AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 1 ms 256 KB
1_004.txt AC 1 ms 256 KB
1_005.txt AC 6 ms 1792 KB
1_006.txt AC 1 ms 256 KB
1_007.txt AC 7 ms 1664 KB
1_008.txt AC 5 ms 1280 KB
1_009.txt AC 6 ms 1664 KB
1_010.txt AC 3 ms 768 KB
1_011.txt AC 7 ms 2176 KB
1_012.txt AC 8 ms 2560 KB
1_013.txt AC 5 ms 1664 KB
1_014.txt AC 1 ms 256 KB
1_015.txt AC 2 ms 256 KB
1_016.txt AC 2 ms 256 KB
1_017.txt AC 15 ms 4224 KB
1_018.txt AC 15 ms 4224 KB
1_019.txt AC 10 ms 2304 KB
1_020.txt AC 10 ms 2304 KB
1_021.txt AC 11 ms 2688 KB
1_022.txt AC 12 ms 3200 KB
1_023.txt AC 13 ms 3840 KB
1_024.txt AC 13 ms 3840 KB
1_025.txt AC 11 ms 3456 KB
1_026.txt AC 12 ms 3456 KB
1_027.txt AC 3 ms 256 KB
1_028.txt AC 3 ms 256 KB
1_029.txt AC 12 ms 3456 KB
1_030.txt AC 14 ms 4224 KB
1_031.txt AC 14 ms 4224 KB
1_032.txt AC 14 ms 4096 KB
1_033.txt AC 14 ms 4224 KB
1_034.txt AC 14 ms 4224 KB
1_035.txt AC 10 ms 2432 KB