結果
問題 | No.2355 Unhappy Back Dance |
ユーザー |
|
提出日時 | 2023-06-16 22:28:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,472 ms / 6,000 ms |
コード長 | 629 bytes |
コンパイル時間 | 2,060 ms |
コンパイル使用メモリ | 197,100 KB |
最終ジャッジ日時 | 2025-02-14 06:27:08 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;ll gcd(ll a, ll b) {return (a ? gcd(b % a, a) : b);}int main () {int N;cin >> N;ll X[2020], Y[2020];for (int i = 0; i < N; i ++) cin >> X[i] >> Y[i];int ans = 0;using P = pair<ll, ll>;P A[2020];for (int i = 0; i < N; i ++) {for (int j = 1; j < N; j ++) {int k = (i + j) % N;ll dx = X[k] - X[i], dy = Y[k] - Y[i];ll g = gcd(abs(dx), abs(dy));A[j - 1] = P{dx / g, dy / g};}sort(A, A + (N - 1));for (int j = 0; j < N - 2; j ++) {if (A[j] == A[j + 1]) {ans ++;break;}}}cout << ans << endl;}