結果
| 問題 |
No.5007 Steiner Space Travel
|
| コンテスト | |
| ユーザー |
ococonomy1
|
| 提出日時 | 2023-04-26 23:51:18 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 987 ms / 1,000 ms |
| コード長 | 2,891 bytes |
| コンパイル時間 | 1,211 ms |
| コンパイル使用メモリ | 111,332 KB |
| 実行使用メモリ | 4,372 KB |
| スコア | 4,367,651 |
| 最終ジャッジ日時 | 2023-04-26 23:51:56 |
| 合計ジャッジ時間 | 34,605 ms |
|
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
using namespace std;
using lg = long long;
#define TEST clog << "TEST" << endl
#define IINF 2147483647
#define LLINF 9223372036854775807LL
#define AMARI 998244353
#define TEMOTO ((sizeof(long double) == 16) ? false : true)
#define TIME_LIMIT 950 * (TEMOTO ? 1 : 1000)
#define el '\n'
#define El '\n'
//疑似乱数(XorShift)
unsigned long xor128(void) {
static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
unsigned long t = (x xor (x << 11));
x = y; y = z; z = w;
return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
int wakusei_num, station_num;
class planet {
public:
int x;
int y;
int num;
};
bool hikaku_rad(planet a, planet b) {
return (atan2(a.y - 500, a.x - 500) < atan2(b.y - 500, b.x - 500));
}
int planet_distance(planet const& a, planet const& b) {
int ans = (a.x - b.x) * (a.x - b.x);
ans += (a.y - b.y) * (a.y - b.y);
return ans;
}
class station {
public:
int x;
int y;
int num;
};
vector<planet> wakusei(100);
//a番目とa+1番目をswapすることを考える
int kinbou_hyouka(int a) {
//(a-1,a)と(a+1,a+2)を引く
if (a <= 0 || a + 2 >= 100)return IINF;
int ans = -1 * planet_distance(wakusei[a - 1], wakusei[a]);
ans -= planet_distance(wakusei[a + 1], wakusei[a + 2]);
//(a-1,a+1)と(a,a+2)を足す
ans += planet_distance(wakusei[a - 1], wakusei[a + 1]);
ans += planet_distance(wakusei[a], wakusei[a + 2]);
return ans;
}
#define MULTI_TEST_CASE false
void solve(void) {
cin >> wakusei_num >> station_num;
for (int i = 0; i < wakusei_num; i++) {
cin >> wakusei[i].x >> wakusei[i].y;
wakusei[i].num = i;
}
clock_t start = clock();
for (int i = 0; i < station_num; i++) {
cout << "0 0" << El;
}
cout << wakusei_num + 1 << el;
sort(wakusei.begin(), wakusei.end(), hikaku_rad);
while (clock() - start <= TIME_LIMIT) {
int rand_num = xor128() % 100;
if (kinbou_hyouka(rand_num) < 0) {
swap(wakusei[rand_num], wakusei[rand_num + 1]);
}
}
for (int i = 0; i < wakusei_num; i++) {
if (!wakusei[i].num) {
for (int j = i; j <= i + wakusei_num; j++) {
cout << "1 " << wakusei[j % wakusei_num].num + 1 << el;
}
break;
}
}
return;
}
void calc(void) {
return;
}
int main(void) {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t = 1;
if (MULTI_TEST_CASE)cin >> t;
while (t--) {
solve();
}
calc();
return 0;
}
ococonomy1