| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 431235 | jamezzz | Long Mansion (JOI17_long_mansion) | C++17 | 481 ms | 42092 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#include <ext/rope>
using namespace __gnu_cxx;
typedef tree<long long, null_type, less<long long>,
rb_tree_tag, tree_order_statistics_node_update> pbds;
//less_equal for identical elements
#define DEBUG
#ifdef DEBUG
#define debug(...) printf(__VA_ARGS__);
#else
#define debug(...)
#endif
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb emplace_back
#define sz(x) (int)x.size()
#define mnto(x,y) x=min(x,(__typeof__(x))y)
#define mxto(x,y) x=max(x,(__typeof__(x))y)
#define INF 1023456789
#define LINF 1023456789123456789
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vll;
mt19937 rng(time(0));
#define maxn 500005
int n,c[maxn],b[maxn],t,q,x,y;
bool have[maxn];
vector<int> a[maxn];
bool pos[5005][5005];
void small(){
for(int i=1;i<=n;++i){
for(int j=1;j<=n;++j)have[j]=false;
for(int j=0;j<b[i];++j)have[a[i][j]]=true;
int l=i,r=i;
while(true){
bool move=false;
if(l>1&&have[c[l]]){
--l;
for(int j=0;j<b[l];++j){
have[a[l][j]]=true;
}
move=true;
}
if(r<n&&have[c[r+1]]){
++r;
for(int j=0;j<b[r];++j){
have[a[r][j]]=true;
}
move=true;
}
if(!move)break;
}
for(int j=l;j<=r;++j)pos[i][j]=true;
}
sf("%d",&q);
for(int i=0;i<q;++i){
sf("%d%d",&x,&y);
if(pos[x][y])pf("YES\n");
else pf("NO\n");
}
}
int main(){
sf("%d",&n);
for(int i=2;i<=n;++i)sf("%d",&c[i]);
for(int i=1;i<=n;++i){
sf("%d",&b[i]);
for(int j=0;j<b[i];++j){
sf("%d",&t);
a[i].pb(t);
}
}
if(n<=5000)small();
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
