Submission #857720

# Submission time Handle Problem Language Result Execution time Memory
857720 2023-10-06T16:44:37 Z Vanio Speedrun (RMI21_speedrun) C++17
29 / 100
50 ms 1924 KB
#include<bits/stdc++.h>
#include "speedrun.h"
using namespace std;

void assignHints(int subtask, int n, int a[], int b[]){
    if(subtask==1){
        int i;
        setHintLen(n);
        for(i=1;i<n;i++){
            setHint(a[i],b[i],1);
            setHint(b[i],a[i],1);
        }
    }
    if(subtask==2){
        int c;
        if(a[2]==a[1] || a[2]==b[1]) c=a[2];
        else c=b[2];

        int l=1,h[20];
        while(c>0){
            h[l]=c%2;
            c/=2;
            l++;
        }
        setHintLen(l-1);
        int i,j;
        for(i=1;i<=n;i++){
            if(i==c) continue;
            for(j=1;j<l;j++) setHint(i,j,h[j]);
        }

    }
}

int n;
bool f[1001];

void rec(int k, int p){
    int i;
    f[k]=1;
    for(i=1;i<=n;i++){
        if(getHint(i) && !f[i]){
            goTo(i);
            rec(i,k);
        }
    }
    if(p==0) return;
    goTo(p);
}

void speedrun(int subtask, int N, int start){
    n=N;

    if(subtask==1) rec(start,0);

    if(subtask==2){
        int i,F=0,c=0,t=1;
        int l = getLength();
        for(i=1;i<=l;i++) if(getHint(i)==1){F=1; break;}
        if(F){
            for(i=1;i<l;i++) t*=2;
            for(i=l;i>=1;i--){
                c+=getHint(i)*t;
                t/=2;
            }
            goTo(c);
        }
        else c=start;
        for(i=1;i<=n;i++){
            if(i==c) continue;
            goTo(i);
            goTo(c);
        }
    }
}

# Verdict Execution time Memory Grader output
1 Correct 23 ms 1552 KB Output is correct
2 Correct 22 ms 1808 KB Output is correct
3 Correct 23 ms 1628 KB Output is correct
4 Correct 20 ms 1924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 1332 KB Output is correct
2 Correct 46 ms 1196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB setHintLen was never called
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB setHintLen was never called
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB setHintLen was never called
2 Halted 0 ms 0 KB -