답안 #909960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
909960 2024-01-17T16:46:45 Z dragusanu_rares Speedrun (RMI21_speedrun) C++14
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
vector<vector<int>> adj;
/**
int nod_curent;
bool hinturi[100][21];
void setHintLen (int l){
    return;
}
void setHint(int i, int j, bool b){
    hinturi[i][j]=b;
    return;
}
bool getHint(int j){
    return hinturi[nod_curent][j];
}
bool goTo(int x){
    for(int i=0;i<adj[nod_curent].size();i++){
        if(adj[nod_curent][i]==x){
            nod_curent=x;
            return 1;
        }
    }
    return 0;
}
**/



int visited[1005];
int parent[1005];
int nxt[1005];
int n,ult_nod=1;
int hint(int nod){
    int poz=1;
    while(parent[nod]>0){
        setHint(nod, poz, parent[nod]&1);
        parent[nod]>>=1;
        poz++;
    }
    poz=11;
    while(nxt[nod]>0){
        setHint(nod, poz, nxt[nod]&1);
        nxt[nod]>>=1;
        poz++;
    }
}
void dfs(int nod){
    for(int i=0;i<adj[nod].size();i++){
        if(!visited[adj[nod][i]]){
            visited[adj[nod][i]]=1;
            nxt[ult_nod]=adj[nod][i];
            ult_nod=adj[nod][i];
            parent[adj[nod][i]]=nod;
            dfs(adj[nod][i]);
        }
    }
}
void assignHints (int subtask , int N, int a[], int b[]){
    n=N;
    //setHintLen(20);
    adj.resize(n+5);
    for(int i=1;i<n;i++){
        adj[a[i]].push_back(b[i]);
        adj[b[i]].push_back(a[i]);
    }
    ult_nod=0;
    dfs(1);
    nxt[ult_nod]=0;
    for(int i=1;i<=n;i++){
        hint(i);
    }
    return;
}
void speedrun(int subtask , int N, int nod ){
    int nr;
    while(nod!=1){
        nr=0;
        for(int i=1;i<=10;i++){
            nr=nr*2+getHint(i);
        }
        nod=nr;
        goTo(nr);
    }
    for(int i=2;i<N;i++){
        nr=0;
        for(int i=11;i<=20;i++){
            nr=nr*2+getHint(i);
        }
        if(goTo(nr)){
            nod=nr;
        }
        else{
            nr=0;
            for(int i=1;i<=10;i++){
                nr=nr*2+getHint(i);
            }
            nod=nr;
            goTo(nr);
            i--;
        }
    }
}
/**
int main(){
    assignHints(1,5,{-, 1, 2, 3, 3},{-, 2, 3, 4, 5});
    //assignHints (1,5,{-, 1, 2, 3, 3},{-, 2, 3, 4, 5});
    speedrun(1,5,1);
    return 0;
}
**/

Compilation message

speedrun.cpp: In function 'int hint(int)':
speedrun.cpp:48:1: warning: no return statement in function returning non-void [-Wreturn-type]
   48 | }
      | ^
speedrun.cpp: In function 'void dfs(int)':
speedrun.cpp:50:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i=0;i<adj[nod].size();i++){
      |                 ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB You must call setLength before you set anything
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB You must call setLength before you set anything
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB You must call setLength before you set anything
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB You must call setLength before you set anything
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB You must call setLength before you set anything
2 Halted 0 ms 0 KB -