이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 500000000LL
#define EPS 0.00000001
#define pi 3.14159
ll mod=1000000007LL;
template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}
template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}
void exploreCave(int N)
{
int def[N]; REP(i,0,N) {def[i]=-1;} //how the ith swith should be in order for its door to be unlocked
int pos[N]; REP(i,0,N) {pos[i]=-1;} //switch index corresponding to door i
int door[N]; REP(i,0,N) {door[i]=-1;} //door correspondent to switch i
int query[N]; REP(i,0,N) {query[i]=0;} //default query
ll val;
REP(ind,0,N)
{
val = tryCombination(query);
if(val<=ind && val!=-1) {REP(i,0,N) {if(def[i]==-1) {query[i]=1-query[i];}}}
ll lo=0LL; ll hi=N-1;
while(lo<hi)
{
ll mid = (lo+hi)/2LL;
REP(i,lo,mid+1) {if(def[i]==-1) {query[i]=1-query[i];}}
ll oldlo=lo; ll oldmid=mid;
val = tryCombination(query);
if(val<=ind && val!=-1) {hi=mid;} //door ind is located in switches [lo,mid]
else {lo=mid+1;}
REP(i,oldlo,oldmid+1) {if(def[i]==-1) {query[i]=1-query[i];}}
}
pos[ind]=lo; door[lo]=ind; def[lo]=query[lo];
}
answer(def,door);
return;
}
컴파일 시 표준 에러 (stderr) 메시지
cave.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
6 | #pragma GCC optimization ("O3")
|
cave.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
7 | #pragma GCC optimization ("unroll-loops")
|
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:51:6: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
51 | int pos[N]; REP(i,0,N) {pos[i]=-1;} //switch index corresponding to door i
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |