이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Memory2_lib.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
mt19937 rng(time(0));
void Solve(vector<int> pos)
{
if(pos.size()==2)
{
Answer(pos[0],pos[1],Flip(pos[0],pos[1]));
return;
}
int x=rng()%pos.size();
vector<pair<int,int>> ans;
for(int i=0;i<pos.size();i++) if(i!=x)
{
ans.pb({Flip(pos[i],pos[x]),pos[i]});
}
sort(ans.begin(),ans.end());
vector<int> work;
for(int i=0,j;i<ans.size();i=j)
{
vector<int> now;
for(j=i;j<ans.size() && ans[i].first==ans[j].first;j++) now.pb(ans[j].second);
if(now.size()==2)
{
Answer(now[0],now[1],ans[i].first);
}
else
{
work=now;
work.pb(pos[x]);
}
}
Solve(work);
}
void Solve(int T, int N)
{
vector<int> work;
for(int i=0;i<N*2;i++) work.pb(i);
Solve(work);
}
컴파일 시 표준 에러 (stderr) 메시지
memory2.cpp: In function 'void Solve(std::vector<int>)':
memory2.cpp:15:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<pos.size();i++) if(i!=x)
~^~~~~~~~~~~
memory2.cpp:21:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0,j;i<ans.size();i=j)
~^~~~~~~~~~~
memory2.cpp:24:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(j=i;j<ans.size() && ans[i].first==ans[j].first;j++) now.pb(ans[j].second);
~^~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |