Submission #26902319
Source Code Expand
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
int n, q, x, y, z;
cin >> n >> q;
int a[n + 1] = {}, b[n + 1] = {};
for(int i = 0; i < q; i++){
cin >> x;
if(x == 1){
cin >> y >> z;
b[y] = z;
a[z] = y;
}
else if(x == 2){
cin >> y >> z;
b[y] = a[z] = 0;
}
else{
vector<int> v;
cin >> y;
while(a[y] > 0) y = a[y];
v.push_back(y);
while(b[y] > 0){
v.push_back(b[y]);
y = b[y];
}
cout << v.size();
for(int i = 0; i < v.size(); i++) cout << " " << v[i];
cout << endl;
}
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Play Train |
| User | Ysdr |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 837 Byte |
| Status | AC |
| Exec Time | 314 ms |
| Memory | 7704 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:31:30: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
31 | for(int i = 0; i < v.size(); i++) cout << " " << v[i];
| ~~^~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 154 ms | 7704 KiB |
| 001.txt | AC | 147 ms | 7104 KiB |
| 002.txt | AC | 198 ms | 7140 KiB |
| 003.txt | AC | 196 ms | 7288 KiB |
| 004.txt | AC | 150 ms | 7484 KiB |
| 005.txt | AC | 70 ms | 4580 KiB |
| 006.txt | AC | 73 ms | 4696 KiB |
| 007.txt | AC | 70 ms | 3628 KiB |
| 008.txt | AC | 60 ms | 3420 KiB |
| 009.txt | AC | 63 ms | 3636 KiB |
| 010.txt | AC | 63 ms | 3420 KiB |
| 011.txt | AC | 60 ms | 3392 KiB |
| 012.txt | AC | 62 ms | 3472 KiB |
| 013.txt | AC | 77 ms | 3760 KiB |
| 014.txt | AC | 75 ms | 3912 KiB |
| 015.txt | AC | 78 ms | 3832 KiB |
| 016.txt | AC | 78 ms | 4012 KiB |
| 017.txt | AC | 80 ms | 4448 KiB |
| 018.txt | AC | 79 ms | 4172 KiB |
| 019.txt | AC | 78 ms | 4420 KiB |
| 020.txt | AC | 77 ms | 4412 KiB |
| 021.txt | AC | 77 ms | 4320 KiB |
| 022.txt | AC | 273 ms | 7552 KiB |
| 023.txt | AC | 314 ms | 7640 KiB |
| example0.txt | AC | 6 ms | 3532 KiB |