結果
問題 | No.2596 Christmas Eve (Heuristic ver.) |
ユーザー | daiota |
提出日時 | 2023-12-24 09:12:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 1,224 ms |
コード長 | 1,737 bytes |
コンパイル時間 | 1,704 ms |
コンパイル使用メモリ | 178,396 KB |
実行使用メモリ | 6,676 KB |
スコア | 2,381,452 |
最終ジャッジ日時 | 2023-12-24 09:12:39 |
合計ジャッジ時間 | 11,790 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 125 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; #define REP(i,n) for(int i=0;i<int(n);i++) int main(void){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int i,j,k; int N,K; cin >> N >> K; vector<P> a(N+1),c(2*N+1),e(N+1); vector<int> b(N+1),d(2*N+1),f(N+1); for(i=1;i<=6;i++){ if(i==1){ for(j=1;j<=N;j++){ int x; cin >> x; a[j].first=x; a[j].second=j; } } if(i==2){ for(j=1;j<=N;j++){ int x; cin >> x; b[j]=x; } } if(i==3){ for(j=1;j<=2*N;j++){ int x; cin >> x; c[j].first=x; c[j].second=j; } } if(i==4){ for(j=1;j<=2*N;j++){ int x; cin >> x; d[j]=x; } } if(i==5){ for(j=1;j<=N;j++){ int x; cin >> x; e[j].first=x; e[j].second=j; } } if(i==6){ for(j=1;j<=N;j++){ int x; cin >> x; f[j]=x; } } } sort(a.begin(),a.end()); sort(c.begin(),c.end()); sort(e.begin(),e.end()); int r=0; vector<P> aa=a,cc=c,ee=e; vector<int> u,v,w,x; for(i=1;i<=N;i++){ bool f=false; for(j=1;j<=N;j++){ if(aa[j].first==-1) continue; vector<int> t; for(k=1;k<=2*N;k++){ if(cc[k].first==-1) continue; if(ee[i].first<aa[j].first && aa[j].first<cc[k].first){ t.push_back(cc[k].second); cc[k].first=-1; if((int)t.size()==2){ r++; f=true; aa[j].first=-1; ee[i].first=-1; u.push_back(aa[j].second); x.push_back(ee[i].second); v.push_back(t[0]); w.push_back(t[1]); break; } } } if(f) break; } if(r==K) break; } for(int l=0;l<K;l++){ cout << u[l] << ' ' << v[l] << ' ' << w[l] << ' ' << x[l] << '\n'; } return 0; }