結果
問題 |
No.5016 Worst Mayor
|
ユーザー |
![]() |
提出日時 | 2023-04-29 15:11:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,151 bytes |
コンパイル時間 | 2,002 ms |
コンパイル使用メモリ | 179,220 KB |
実行使用メモリ | 37,108 KB |
スコア | 0 |
最終ジャッジ日時 | 2023-04-29 15:12:18 |
合計ジャッジ時間 | 8,492 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 49 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; using ll = long long; using inv = vector<int>; using stv = vector<string>; using pint = pair<int,int>; #define FOR(i,l,r) for(int i=(l); i<(r); i++) #define rep(i,r) for(int i=0; i<(r); i++) #define repl(i,r) for(long long i=0; i<(r); i++) #define FORl(i,l,r) for(long long i=(l); i<(r); i++) #define INFL ((1LL<<62)-(1LL<<31)) #define pb(x) push_back(x) #define CIN(x) cin >> x template<class T> size_t HashCombine(const size_t seed,const T &v){ return seed^(std::hash<T>()(v)+0x9e3779b9+(seed<<6)+(seed>>2)); } template<class T> struct std::hash<std::vector<T>>{ size_t operator()(const std::vector<T> &keyval) const noexcept { size_t s=0; for (auto&& v: keyval) s=HashCombine(s,v); return s; } }; int main(){ int N,T; cin >> N >> T; vector<pint> S(N); vector<pint> G(N); rep(i,N){ int a,b,c,d; cin >> a >> b >> c >> d; S[i] = make_pair(a,b); G[i] = make_pair(c,d); } int pi = 0; unordered_map<vector<int>, bool> R; int CD = 100; rep(day,T){ ll u,v; cin >> u >> v; if(u == -1LL && v == -1LL) return 0; double cost = (double)1e7/(double)sqrt(v); if(day <= CD-1) cout << 2 << endl; else if((double)u <= cost){ cout << 3 << endl; }else{ bool ok = false; while(!ok){ vector<int> A{S[pi].first,S[pi].second,S[pi].first,S[pi].second}; if(S[pi].first < G[pi].first){ A[2]++; if(R[A]){ S[pi].first++; continue; } else{ cout << 1 << " " << S[pi].first << " " << S[pi].second << " " << S[pi].first+1 << " " << S[pi].second << endl; S[pi].first++; R[A] = true; ok = true; } }else if(S[pi].first > G[pi].first){ A[2]--; if(R[A]){ S[pi].first--; continue; } else{ cout << 1 << " " << S[pi].first << " " << S[pi].second << " " << S[pi].first-1 << " " << S[pi].second << endl; S[pi].first--; R[A] = true; ok = true; } }else if(S[pi].second < G[pi].second){ A[3]++; if(R[A]){ S[pi].second++; continue; } else{ cout << 1 << " " << S[pi].first << " " << S[pi].second << " " << S[pi].first << " " << S[pi].second +1 << endl; S[pi].second++; R[A] = true; ok = true; } }else if(S[pi].second > G[pi].second){ A[3]--; if(R[A]){ S[pi].second--; continue; } else{ cout << 1 << " " << S[pi].first << " " << S[pi].second << " " << S[pi].first << " " << S[pi].second -1 << endl; S[pi].second--; R[A] = true; ok = true; } } } if(S[pi].first == G[pi].first && S[pi].second == G[pi].second){ pi++; } } } return 0; }