結果
| 問題 |
No.2353 Guardian Dogs in Spring
|
| ユーザー |
|
| 提出日時 | 2023-06-16 22:02:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,329 bytes |
| コンパイル時間 | 1,356 ms |
| コンパイル使用メモリ | 125,064 KB |
| 最終ジャッジ日時 | 2025-02-14 05:42:55 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 37 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:41:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
41 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:45:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
45 | scanf("%d%d", &p.first, &p.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 = 1e5 + 10;
int cross(const pair<int, int>& p1, const pair<int, int>& p2)
{
return p1.first * p2.second - p1.second * p2.first;
}
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
vector<pair<pair<int, int>, int>> vp;
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
pair<int, int> p;
scanf("%d%d", &p.first, &p.second);
p.first++;
p.second++;
vp.emplace_back(p, i);
}
using Node = pair<pair<int, int>, int>;
sort(vp.begin(), vp.end(), [](const Node& node1, const Node& node2)->bool
{
return cross(node1.first, node2.first) > 0;
});
printf("%d\n", n / 2);
for (int i = 0; i + 1 < n; i += 2)
{
printf("%d %d\n", vp[i].second, vp[i + 1].second);
}
return 0;
}