# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
172830 | mhy908 | Memory 2 (JOI16_memory2) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Memory2_lib.h"
#include <bits/stdc++.h>
#include <time.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL llinf=9000000000000000000;
const int inf=2000000000;
vector<int> myvec;
vector<pii> ans;
void Solve(int T, int N)
{
srand((unsigned int)time(NULL));
for(int i=0; i<N*2; i++)myvec.pb(i);
while(1){
if(myvec.size()==2){
Answer(myvec[0], myvec[1], Flip(myvec[0], myvec[1]));
return;
}
ans.clear();
int rnd=rand()%myvec.size();
for(int i=0; i<myvec.size();i++){
if(i!=rnd)ans.pb(mp(Flip(myvec[i], myvec[rnd]), myvec[i]));
}
sort(ans.begin(),ans.end());
vector<int> temp;
for(int i=0, j; i<ans.size(); i=j){
vector<int> now;
for(j=i; j<ans.size()&&ans[i].F==ans[j].F; j++)now.pb(ans[j].S);
if(now.size()==2)Answer(now[0], now[1], ans[i].F);
else{
now.pb(myvec[tnd]);
temp=now;
}
}
myvec=temp;
}
}