結果

問題 No.2596 Christmas Eve (Heuristic ver.)
ユーザー daiota
提出日時 2023-12-24 06:48:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,592 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 180,316 KB
実行使用メモリ 6,676 KB
スコア 2,057,244
最終ジャッジ日時 2023-12-24 06:48:34
合計ジャッジ時間 13,327 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 108 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#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,c,e;
	vector<P> b,d,f;

	for(i=1;i<=6;i++){
		if(i==1){
			for(j=1;j<=N;j++){
				int x;
				cin >> x;
				a.push_back(P(x,j));
			}
		}

		if(i==2){
			for(j=1;j<=N;j++){
				int x;
				cin >> x;
				b.push_back(P(x,j));
			}
		}

		if(i==3){
			for(j=1;j<=2*N;j++){
				int x;
				cin >> x;
				c.push_back(P(x,j));
			}
		}

		if(i==4){
			for(j=1;j<=2*N;j++){
				int x;
				cin >> x;
				d.push_back(P(x,j));
			}
		}

		if(i==5){
			for(j=1;j<=N;j++){
				int x;
				cin >> x;
				e.push_back(P(x,j));
			}
		}

		if(i==6){
			for(j=1;j<=N;j++){
				int x;
				cin >> x;
				f.push_back(P(x,j));
			}
	}

	}

	sort(a.begin(),a.end());
	sort(c.begin(),c.end());
	sort(e.begin(),e.end());


	vector<ll> u,v,w,x;

	bool g=false;
	for(i=0;i<K;i++){
		for(j=0;j<N;j++){
			if(a[j].first==-1) continue;
			vector<int> t;
			for(k=0;k<2*N;k++){
				if(c[k].first==-1) continue;


				if(e[i].first<a[j].first && a[j].first<c[k].first){
					t.push_back(c[k].second);
					c[k].first=-1;

					if((int)t.size()==2){
						g=true;
						a[j].first=-1;
						x.push_back(e[i].second);
						u.push_back(a[j].second);
						v.push_back(t[0]);
						w.push_back(t[1]);
						break;
					}

				}
			}
			if(g) break;
		}
	}


	for(i=0;i<K;i++){
		cout << u[i] << ' ' << v[i] << ' ' << w[i] << ' ' << x[i] << '\n';
	}




	return 0;
}
0