Task: | Company Queries II |
Sender: | HFalke |
Submission time: | 2024-10-23 19:36:03 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | TIME LIMIT EXCEEDED | -- | details |
#7 | ACCEPTED | 0.08 s | details |
#8 | WRONG ANSWER | 0.11 s | details |
#9 | TIME LIMIT EXCEEDED | -- | details |
#10 | TIME LIMIT EXCEEDED | -- | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | TIME LIMIT EXCEEDED | -- | details |
Code
#include <bits/stdc++.h>using namespace std;//Definitions for quicker writing#define REP(i,a,b) for (int i = a; i < b; i++)#define PB push_back#define MP make_pair#define F first#define S second//Typedefs for quicker writingtypedef long long ll;typedef vector<int> vi;typedef vector<long long> vl;typedef pair<int,int> pi;typedef pair<long long, long long> pl;//Max valuesconst long long lmx = LLONG_MAX;const int imx = INT_MAX;int main() {//IO optimizationios::sync_with_stdio(0);cin.tie(0);//Input definitionint n;int q;//Read Incin >> n >> q;int boss[n];int level[n];boss[0] = 1;level[0] = 0;REP(i,1,n){cin >> boss[i];level[i] = level[boss[i]-1] + 1;}pi queries[q];REP(i,0,q){cin >> queries[i].first;cin >> queries[i].second;}//Main partint ans[q];int emp1, emp2;int lvl1, lvl2;REP(i,0,q){emp1 = queries[i].first;lvl1 = level[emp1-1];emp2 = queries[i].second;lvl2 = level[emp2-1];if(lvl1 < lvl2){REP(j,0,lvl2-lvl1){emp1 = boss[emp1-1];}}if(lvl2 < lvl1){REP(j,0,lvl1-lvl2){emp2 = boss[emp2-1];}}while(emp1 != emp2){emp1 = boss[emp1-1];emp2 = boss[emp2-1];}ans[i] = emp1;}//Write outREP(i,0,q) cout << ans[i] << "\n";//Returnreturn 0;}
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
10 10 1 2 3 4 5 6 7 8 9 6 9 8 10 10 3 ... |
correct output |
---|
6 8 3 1 8 ... |
user output |
---|
1 1 1 1 1 ... |
Test 2
Verdict: ACCEPTED
input |
---|
10 10 1 1 1 1 1 1 1 1 1 1 7 3 4 4 1 ... |
correct output |
---|
1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... |
Test 3
Verdict: ACCEPTED
input |
---|
10 10 1 1 1 1 2 3 4 4 1 1 8 2 7 8 3 ... |
correct output |
---|
1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... |
Test 4
Verdict: WRONG ANSWER
input |
---|
10 10 1 1 3 1 2 2 5 3 9 7 2 7 6 3 9 ... |
correct output |
---|
2 2 3 1 1 ... |
user output |
---|
1 2 1 1 1 ... |
Test 5
Verdict: WRONG ANSWER
input |
---|
10 10 1 2 3 2 5 3 2 2 4 6 1 1 3 1 9 ... |
correct output |
---|
1 1 1 2 2 ... |
user output |
---|
1 1 1 1 2 ... |
Test 6
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
74862 8750 16237 72298 58111 ... |
user output |
---|
(empty) |
Test 7
Verdict: ACCEPTED
input |
---|
200000 200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 8
Verdict: WRONG ANSWER
input |
---|
200000 200000 1 2 1 2 3 2 1 6 3 1 10 12 13 4... |
correct output |
---|
1 2 2 2 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 9
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
2796 633 633 151 2690 ... |
user output |
---|
(empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
365 73 103 365 216 ... |
user output |
---|
(empty) |
Test 11
Verdict: ACCEPTED
input |
---|
2 4 1 1 1 1 2 2 1 ... |
correct output |
---|
1 1 1 2 |
user output |
---|
1 1 1 2 |
Test 12
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 1 1 2 3 4 5 6 7 8 9 10 11 12 1... |
correct output |
---|
27468 6353 27468 6353 6353 ... |
user output |
---|
(empty) |