Submission #856780

# Submission time Handle Problem Language Result Execution time Memory
856780 2023-10-04T14:27:35 Z iulia_morariu Speedrun (RMI21_speedrun) C++17
21 / 100
101 ms 1864 KB
#include <speedrun.h>
#include <bits/stdc++.h>

using namespace std;

void assignHints (int subtask , int N, int A[], int B[]){
    if(subtask == 1){
        setHintLen( N );

        for(int i = 1; i < N; i++){
            setHint( A[i], B[i], 1);
            setHint( B[i], A[i], 1);
        }
    }else{
        setHintLen(20);
        int vf[N + 1];
        for(int i = 1; i <= N; i++) vf[i] = 0;
        for(int i = 1; i < N; i++){
            vf[ A[i] ]++;
            vf[ B[i] ]++;
        }

        int nod = 0;
        for(int i = 1; i <= N; i++){
            if(vf[i] == N - 1) nod = i;
        }

        for(int i = 1; i < N; i++){
            for(int j = 0; j < 20; j++){
                bool set = 0;
                if( (nod & (1 << j)) ) set = 1;
                setHint(i, j + 1, set );
            }
        }
    }
}

int vis[1001];
void dfs(int nd, int n){
    vis[nd] = 1;
    //cout << "Suntem la " << nd << endl;
    for(int i = 1; i <= n; i++){
        if( vis[i] || getHint(i) == 0 ) continue;
        //cout << "  -- > i = " << i << " getHint = " << getHint(i) << endl;
        goTo(i);
        vis[i] = 1;
        dfs(i, n);
        goTo(nd);
    }
}

void speedrun(int subtask , int N, int start ){
    if(subtask == 1){
        for(int i = 0; i <= N; i++) vis[i] = 0;
        vis[start] = 1;
        stack<int> s;
        s.push(start);

        dfs(start, N);
    }else{

        int nd = 0;
        for(int j = 0; j <= 20; j++){
            nd += getHint(j + 1) * (1 << j);
        }

        if(nd != start){
            goTo( nd );
        }

        for(int i = 1; i <= N; i++){
            if(i == nd || i == start) continue;
            goTo(i);
            goTo(nd);
        }

    }
}
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1864 KB Output is correct
2 Correct 24 ms 1844 KB Output is correct
3 Correct 22 ms 1552 KB Output is correct
4 Correct 24 ms 1320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 824 KB Invalid bit index for getHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 828 KB Invalid bit index for getHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 840 KB Invalid bit index for getHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 828 KB Invalid bit index for getHint
2 Halted 0 ms 0 KB -