Submission #933622

#TimeUsernameProblemLanguageResultExecution timeMemory
933622vjudge1Speedrun (RMI21_speedrun)C++17
21 / 100
26 ms2760 KiB
#include <bits/stdc++.h> #include "speedrun.h" #define endl '\n' #define mp make_pair #define f first #define s second #define pb push_back #define all(x) x.begin(),x.end() #define fore(i,l,r) for(int i = l; i < r;i++) #define forex(i,r,l) for(int i = r; i>= l;i--) #define fo(i,n) fore(i,0,n) #define ffo(i,n) forex(i,n-1,0) #define lsb(x) x&(-x) using namespace std; using ii = pair<int,int>;using ll = long long; using ull = unsigned long long; using vi = vector<int>; // const int maxN = 30; // int hintlen,mistart;vi res; // int number[maxN]; // void setHintLen(int sz){ // hintlen=sz; // } // void setHint(int a, int b, bool cl, bool donde=0){if(donde==0)return; // if(number[a]&1<<b == cl)return; // assert(donde==1); // number[a]^=1<<b; // } // int getLength(){return hintlen;} // bool getHint(int j ){ // // cout << mistart << " " << j << endl; cout.flush(); // return (number[mistart]&(1<<j) ? 1 : 0 ); // } // bool goTo(int j){ // if(number[mistart]&(1<<j) == 0)return false; // res.pb(j); // mistart=j; // return true; // } void assignHints(int subtask, int N , int A[], int B[]){ if(subtask>=2)setHintLen(20); else setHintLen(N); vi cont(N+2, 0),graph[N+2]; fore(i,1,N){graph[A[i]].pb(B[i]); graph[B[i]].pb(A[i]); if(subtask == 1){ setHint(A[i], B[i], 1); setHint(B[i], A[i], 1); }else if(subtask == 2){ cont[A[i]]++;cont[B[i]]++; } } if(subtask==2){ if(N==1)return; fore(i,1,N+1){ if(cont[i]>1){ setHint(i, 1, 1); setHint(i, 2, 1); }else{// no es el centro setHint(i, 1, 1); } } }else if (subtask == 3){ fore(i,1,N){bool ini = 1; for(int v : graph[i]){ fo(j,10){ int k = j+(!ini ? 10 : 0 ); setHint(i, k, (v&(1<<k) ? 1 : 0)); } ini = 0; } } } } vector<vector<int>> graph; vector<bool> precalc, vis;int szn; void dfs(int nodo, int donde = 0){ if(!precalc[nodo]){ precalc[nodo] = 1; fore(i,1,szn+1){ if(getHint(i)){ graph[nodo].pb(i); } } } for(int v : graph[nodo]){ if(!vis[v]){ vis[v]=1; goTo(v);dfs(v, nodo); } } if(donde == 0)return ; goTo(donde); } void speedrun(int subtask, int N, int start){if(N==1)return; vis.resize(N+2,0);precalc.resize(N+2,0);szn=N; graph.resize(N+2);getLength(); if(subtask == 2){ int num = 0; fore(i,1,N+1){ if(getHint(i))num++; } if(num>=2){ fore(i,1,N+1){if(i==start)continue; goTo(i);if(i==N || start == N and i == N-1)return; goTo(start); } }else{ int p = 0; fore(i,1,N+1)if(i!=start and goTo(i)){p=i;break;} fore(i,1,N+1){if(i==p || i==start) continue; goTo(i);if(i==N || (p == N and i == N-1))return; goTo(p); } } return; }else if(subtask == 3 ){ return; } vis[start] = 1; dfs(start); }

Compilation message (stderr)

speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:103:47: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  103 |                 goTo(i);if(i==N || start == N and i == N-1)return;
      |                                    ~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...