結果
問題 | No.5016 Worst Mayor |
ユーザー | assy1028 |
提出日時 | 2023-04-29 15:09:37 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 5,166 bytes |
コンパイル時間 | 1,697 ms |
コンパイル使用メモリ | 130,308 KB |
実行使用メモリ | 37,340 KB |
スコア | 0 |
最終ジャッジ日時 | 2023-04-29 15:10:50 |
合計ジャッジ時間 | 60,887 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | TLE | - |
testcase_02 | TLE | - |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
ソースコード
#include <algorithm> #include <iostream> #include <cstdio> #include <map> #include <numeric> #include <cmath> #include <set> #include <sstream> #include <string> #include <vector> #include <queue> #include <stack> #include <complex> #include <string.h> #include <unordered_set> #include <unordered_map> #include <bitset> #include <iomanip> #include <sys/time.h> #include <tuple> #include <random> using namespace std; #define endl '\n' #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end()) typedef long long ll; typedef long double ld; typedef pair<int, int> P; typedef complex<double> comp; typedef vector< vector<ld> > matrix; struct pairhash { public: template<typename T, typename U> size_t operator()(const pair<T, U> &x) const { size_t seed = hash<T>()(x.first); return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2); } }; const int INF = 1e9 + 9; //const ll INF = 1e18 + 9; const ll MOD = 1e9 + 7; //const ll MOD = 998244353; const double EPS = 1e-8; const double PI = acos(-1); unsigned long xor128(void) { static unsigned long x=123456789,y=362436069,z=521288629,w=88675123; unsigned long t; t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) ); } // [0, k) int rand(int k) { return xor128() % k; } // [a, b) int rand(int a, int b) { return a + xor128() % (b - a); } int n, t; int a[3010], b[3010], c[3010], d[3010]; const int MAX_Y = 14; const int MAX_X = 14; double route_count[15][15][15][15]; bool built[15][15][15][15]; struct road { double count; int x, y, z, w; }; bool operator< (const road& r1, const road& r2) { return r1.count < r2.count; } vector<road> high_way; void build(const road& r) { high_way.push_back(r); built[r.x][r.y][r.z][r.w] = true; cout << "1 " << r.x+1 << " " << r.y+1 << " " << r.z+1 << " " << r.w+1 << endl; cout.flush(); } void get_coop() { cout << "2" << endl; cout.flush(); } void get_money() { cout << "3" << endl; cout.flush(); } bool in_area(const int idx, const road& r) { const int minY = min(a[idx], c[idx]); const int maxY = max(a[idx], c[idx]); const int minX = min(b[idx], d[idx]); const int maxX = max(b[idx], d[idx]); return minY <= r.x && r.x <= maxY && minY <= r.z && r.z <= maxY && minX <= r.y && r.y <= maxX && minX <= r.w && r.w <= maxX; } void add_weight(const int minY, const int maxY, const int minX, const int maxX, const double weight) { for (int y = minY; y <= maxY; y++) { for (int x = minX; x <= maxX; x++) { if (y < maxY) route_count[y][x][y+1][x] += weight; if (x < maxX) route_count[y][x][y][x+1] += weight; } } } void calc_weight(const int idx) { int cnt = 0; vector<road> h; for (const auto& r : high_way) { if (in_area(idx, r)) { cnt++; h.push_back(r); } } const double weight = cnt == 0 ? 1.0 : 1.0 / cnt; const int minY = min(a[idx], c[idx]); const int maxY = max(a[idx], c[idx]); const int minX = min(b[idx], d[idx]); const int maxX = max(b[idx], d[idx]); if (cnt == 0) { add_weight(minY, maxY, minX, maxX, weight); } else if ((a[idx] - c[idx]) * (b[idx] - d[idx]) > 0){ for (const auto& r : h) { add_weight(minY, r.x, minX, r.y, weight); add_weight(r.z, maxY, r.w, maxX, weight); } } else { for (const auto& r : h) { add_weight(r.z, maxY, minX, r.y, weight); add_weight(minY, r.x, r.w, maxX, weight); } } } road get_candidate() { memset(route_count, 0, sizeof(route_count)); for (int i = 0; i < n; i++) { calc_weight(i); } double max_count = 0; road ret; for (int y = 0; y < MAX_Y; y++) { for (int x = 0; x < MAX_X; x++) { if (y < MAX_Y-1 && !built[y][x][y+1][x] && route_count[y][x][y+1][x] > max_count) { ret = road{route_count[y][x][y+1][x], y, x, y+1, x}; max_count = route_count[y][x][y+1][x]; } if (x < MAX_X-1 && !built[y][x][y][x+1] && route_count[y][x][y][x+1] > max_count) { ret = road{route_count[y][x][y][x+1], y, x, y, x+1}; max_count = route_count[y][x][y][x+1]; } } } return ret; } void solve() { int u, v; for (int iter = 0; iter < t; iter++) { cin >> u >> v; const int cost = 1e7 / sqrt(v); const auto& r = get_candidate(); const int gain = r.count * (t-iter) * 60 * pow(0.995, iter); //cerr << "??? " << u << " " << v << " " << cost << " " << gain << endl; if (u < cost || gain < cost) { get_coop(); } else { build(r); } } } void input() { cin >> n >> t; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i] >> c[i] >> d[i]; a[i]--; b[i]--; c[i]--; d[i]--; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); input(); solve(); }