結果
| 問題 |
No.2355 Unhappy Back Dance
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-16 22:50:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,147 ms / 6,000 ms |
| コード長 | 1,724 bytes |
| コンパイル時間 | 1,617 ms |
| コンパイル使用メモリ | 134,312 KB |
| 最終ジャッジ日時 | 2025-02-14 21:15:25 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:81:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::iterator_traits<int*>::difference_type’ {aka ‘long int’} [-Wformat=]
81 | printf("%d\n", count(flag, flag + n + 1, 1));
| ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| int std::iterator_traits<int*>::difference_type {aka long int}
| %ld
main.cpp:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:51:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
51 | for (int i = 1; i <= n; i++) scanf("%lld%lld", &vp[i].first, &vp[i].second);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e3 + 10;
int flag[N];
pair<LL, LL> vp[N];
map<pair<LL, LL>, vector<int>> mc;
pair<LL, LL> check(pair<LL, LL>& p1, pair<LL, LL>& p2)
{
LL a = p2.first - p1.first;
LL b = p2.second - p1.second;
LL g = gcd(abs(a), abs(b));
a /= g;
b /= g;
if (a < 0) a = -a, b = -b;
if (a == 0) b = abs(b);
return { a,b };
}
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%lld%lld", &vp[i].first, &vp[i].second);
for (int i = 1; i <= n; i++)
{
mc.clear();
for (int j = 1; j <= n; j++)
{
if (i == j) continue;
mc[check(vp[i], vp[j])].push_back(j);
}
for (auto& [x, v] : mc)
{
if (v.size() == 1) continue;
if (v.size() > 2)
{
for (auto& y : v)
flag[y] = 1;
continue;
}
vector<pair<pair<LL, LL>, int>> key;
for (int j = 0; j < v.size(); j++)
{
key.emplace_back(vp[v[j]], v[j]);
}
key.emplace_back(vp[i], i);
sort(key.begin(), key.end());
flag[key.front().second] = 1;
flag[key.back().second] = 1;
}
}
printf("%d\n", count(flag, flag + n + 1, 1));
return 0;
}