Submission
Id | When | Author | Problem | Language | CPU | Memory | Verdict |
---|---|---|---|---|---|---|---|
16965 | 2024-04-23 16:54:30 | ewu_intra24_mock_u_126 | Cheaters | C++ 14 | 1 ms | 3360 kb | Accepted |
Test Cases
CPU | Memory | Verdict | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 ms | 3284 kb | Accepted | ||||||||
2 | 1 ms | 3360 kb | Accepted | ||||||||
Source Code
program.cpp
#include <bits/stdc++.h> using ll = long long; using namespace std; void solve() { int n, c; cin >> n; vector<int> a(n), ix(n + 1); for (int i = 0; i < n; i++) { cin >> a[i]; if (i + 1 == a[i]) { c = a[i]; continue; } ix[a[i]] = i + 1; } while (c) { cout << c << " "; c = ix[c]; } cout << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t = 1; cin >> t; for (int i = 1; i <= t; i++) { // cout << "Case no: " << t << "\n"; solve(); } }