# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
69421 | TadijaSebez | Long Mansion (JOI17_long_mansion) | C++11 | 269 ms | 192200 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=200050;
int pos[N],lo[N],hi[N],c[N],l[N],r[N];
vector<int> a[N];
bool on(int l, int r, int x){ return l<=x && r>=x;}
bool can(int l, int r, int x){ return (lo[x] && on(l,r,lo[x])) || (hi[x] && on(l,r,hi[x]));}
int main()
{
int n,q,i,j,x,y;
scanf("%i",&n);
for(i=1;i<n;i++) scanf("%i",&c[i]);
for(i=1;i<=n;i++)
{
scanf("%i",&x);
a[i].resize(x);
for(j=0;j<x;j++) scanf("%i",&a[i][j]);
}
for(i=1;i<=n;i++) pos[i]=0;
for(i=n;i>1;i--)
{
for(j=0;j<a[i].size();j++) pos[a[i][j]]=i;
hi[i-1]=pos[c[i-1]];
}
for(i=1;i<=n;i++) pos[i]=0;
for(i=1;i<n;i++)
{
Compilation message (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... |