# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1009177 | ivopav | Special graph (IZhO13_specialg) | C++17 | 1063 ms | 2256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> slje={};
for (int i=0;i<n;i++){
int unos;
cin >> unos;
slje.push_back(unos-1);
}
int q;
cin >> q;
vector<int> zad(n,-1);
for (int i=0;i<q;i++){
int typ;
cin >> typ;
if (typ==1){
int unos;
cin >> unos;
slje[--unos]=-1;
}
else {
int unos;
int unos2;
cin >> unos >> unos2;
int rje=0;
--unos;
--unos2;
while (unos!=unos2){
if (zad[unos]==i || slje[unos]==-1){
rje=-1;
break;
}
zad[unos]=i;
rje++;
unos=slje[unos];
}
cout << rje << " \n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |