# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
604446 | 2022-07-25T06:37:51 Z | krit3379 | Event Hopping (BOI22_events) | C++14 | 178 ms | 22468 KB |
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define N 100005 struct A{ int s,e,id; bool operator<(const A& o)const{ if(e!=o.e)return e>o.e; return s<o.s; } }; int s[N],e[N],dep[N],nxt[20][N],mi; vector<int> g[N]; vector<A> edge; void dfs(int s){ for(auto x:g[s]){ dep[x]=dep[s]+1; dfs(x); } } int main(){ int n,q,i,j,a,b; scanf("%d %d",&n,&q); for(i=1;i<=n;i++){ scanf("%d %d",&s[i],&e[i]); edge.push_back({s[i],e[i],i}); } sort(edge.begin(),edge.end()); mi=1e9; for(auto [s,e,id]:edge){ if(mi<=e)nxt[0][id]=i; if(s<mi)mi=s,i=id; } for(i=1;i<=n;i++)g[nxt[0][i]].push_back(i); dfs(0); for(i=1;i<20;i++)for(j=1;j<=n;j++)nxt[i][j]=nxt[i-1][nxt[i-1][j]]; while(q--){ scanf("%d %d",&a,&b); if(dep[a]<dep[b])printf("impossible\n"); else{ int dif=dep[a]-dep[b]; for(i=0;i<20;i++)if(dif&(1<<i))a=nxt[i][a]; if(a==b)printf("%d\n",dif); else printf("impossible\n"); } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 106 ms | 19220 KB | Output is correct |
2 | Correct | 131 ms | 22328 KB | Output is correct |
3 | Correct | 178 ms | 22176 KB | Output is correct |
4 | Correct | 70 ms | 17332 KB | Output is correct |
5 | Correct | 136 ms | 21280 KB | Output is correct |
6 | Incorrect | 134 ms | 22468 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |