답안 #500859

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500859 2022-01-01T13:29:40 Z keta_tsimakuridze Speedrun (RMI21_speedrun) C++14
21 / 100
44 ms 832 KB
#include "speedrun.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 1005;
int n ;
vector<int> V[N];
/*
#include <iostream>
#include <map>
#include <set>
using namespace std;

static map<int, map<int, bool> > mp;
static int length = -1;
static int queries = 0;
static bool length_set = false;
static int current_node = 0;
static set<int> viz;
static map<int, set<int> > neighbours;

void setHintLen(int l) {
    if (length_set) {
        cerr << "Cannot call setHintLen twice" << endl;
        exit(0);
    }
    length = l;
    length_set = true;
}

void setHint(int i, int j, bool b) {
    if (!length_set) {
        cerr << "Must call setHintLen before setHint" << endl;
        exit(0);
    }
    mp[i][j] = b;
}

int getLength() { return length; }

bool getHint(int j) { cout << "asked" <<" "<< j << endl; return mp[current_node][j]; }

bool goTo(int x) {
    if (neighbours[current_node].find(x) == neighbours[current_node].end()) {
        ++queries;
        return false;
    } else {
        viz.insert(current_node = x);
        return true;
    }
} */
void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
	setHintLen(N);
	for(int i = 1; i < N; i++) {
		setHint(A[i], B[i], 1);
		setHint(B[i], A[i], 1);
	}
}
void dfs(int u, int par = -1) { 
	for(int i = 1; i <= n; i++) {
		if(getHint(i)) V[u].push_back(i);
	}
	for(int i = 0; i < V[u].size(); i++) {
		if(V[u][i] == par) continue;
		goTo(V[u][i]);
		dfs(V[u][i], u);
	}
	if(par != - 1)goTo(par);
}
void speedrun(int subtask, int N, int start) { /* your solution here */
	
	n = N;dfs(start);
}
/*
int main() {
    int N;
    cin >> N;

    int a[N], b[N];
    for (int i = 1; i < N; ++i) {
        cin >> a[i] >> b[i];
        neighbours[a[i]].insert(b[i]);
        neighbours[b[i]].insert(a[i]);
    }

    assignHints(1, N, a, b);

    if (!length_set) {
        cerr << "Must call setHintLen at least once" << endl;
        exit(0);
    }

    cin >> current_node;
    viz.insert(current_node);

    speedrun(1, N, current_node);

    if (viz.size() < N) {
        cerr << "Haven't seen all nodes" << endl;
        exit(0);
    }

    cerr << "OK; " << queries << " incorrect goto's" << endl;
    return 0;
} */

Compilation message

speedrun.cpp: In function 'void dfs(int, int)':
speedrun.cpp:62:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |  for(int i = 0; i < V[u].size(); i++) {
      |                 ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 756 KB Output is correct
2 Correct 41 ms 788 KB Output is correct
3 Correct 41 ms 748 KB Output is correct
4 Correct 37 ms 832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 328 KB The length is too large
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 328 KB The length is too large
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 328 KB The length is too large
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB The length is too large
2 Halted 0 ms 0 KB -