| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1365893 | lucasdmy | Tour (BOI25_tou) | C++20 | 19 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n, m;
cin>>n>>m;
vector<pair<int, int>>edge(m);
vector<int>type(m);
for(int k=0;k<m;k++){
cin>>edge[k].first>>edge[k].second;
cin>>type[k];
}
int aux=0;
bool ok;
while(aux<(1<<m)){
vector<int>on;
for(int k=0;k<m;k++){
if((1<<k)&aux){
on.push_back(k);
}
}
aux++;
if(on.size()<2){
continue;
}
do{
ok=1;
for(int k=0;k<on.size();k++){
int mod=on.size();
if(edge[on[k]].second!=edge[on[(k+1)%mod]].first or type[on[k]]==type[on[(k+1)%mod]]){
ok=0;
break;
}
}
if(!ok){
continue;
}
cout<<"YES\n"<<on.size()<<' ';
for(int k=0;k<on.size();k++){
cout<<on[k]+1<<' ';
}
break;
}while(next_permutation(on.begin(), on.end()));
if(ok){
break;
}
}
if(!ok){
cout<<"NO";
}
cout<<endl;
}
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
