Submission #764866

# Submission time Handle Problem Language Result Execution time Memory
764866 2023-06-24T06:05:05 Z vjudge1 Speedrun (RMI21_speedrun) C++17
Compilation error
0 ms 0 KB
#include "speedrun.h"
using namespace std;
const int MAXN=1e3+5;
vector<vector<int> > g(MAXN);
void assignHints(int subtask, int N, int A[], int B[]) {
	for(int i=1; i<=N; i++) {
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
	}
	if(subtask==3) {
		for(int i=1; i<=N; i++)g[i].clear();
		setHintLen(20);
		vector<int> us(N+1, 0), pr(N+1, 0);
		queue<int> q;
		q.push(1);
		us[1]=1;
		while(!q.empty()) {
			int v=q.front();
			q.pop();
			for(int j=1; j<=10; j++) {
				setHint(v, j, (pr[v] & (1<<(j-1) ) ? 1 : 0) );
			}
			int cnt=0;
			for(auto to : g[v]) {
				if(!us[to]) {
					pr[to]=v;
					q.push(to);
					cnt++;
					if(cnt==2) {
						for(int j=11; j<=20; j++) {
							setHint(v, j, (to&(1<<(j-11)) ? 1 : 0));
						}
					}else {
						for(int j=1; j<=10; j++) {
							setHint(v, j, (to & (1<<(j-1) ) ? 1 : 0) );
						}
					}
					us[to]=1;
				}
			}
		}
	}
}
int Us[MAXN];
void dfs(int v, int p) {
	Us[v]=1;
	int x=0, y=0;
	for(int j=1; j<=10; j++) {
		if(getHint(j))x+=(1<<(j-1));
	}
	for(int j=11; j<=20; j++) {
		if(getHint(j))y+=(1<<(j-11));
	}
	if(x>0 && !Us[x]) {
		bool ok=goTo(x);
		if(ok)dfs(x, v);
		else {
			cout << "ne\n";
			exit(0);
		}
	}
	if(y>0 && !Us[y]) {
		bool ok=goTo(y);
		if(ok)dfs(y, v);
		else {
			cout << "ne\n";
			exit(0);
		}
	}
	if(p!=v)goTo(p);
}
void speedrun(int subtask, int N, int start) {
	if(subtask==3) {
		for(int i=1; i<=N; i++)Us[i]=0;
		int l=getLength();
		dfs(start, start);
	}
}

Compilation message

speedrun.cpp:4:1: error: 'vector' does not name a type
    4 | vector<vector<int> > g(MAXN);
      | ^~~~~~
speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:7:3: error: 'g' was not declared in this scope
    7 |   g[A[i]].push_back(B[i]);
      |   ^
speedrun.cpp:11:26: error: 'g' was not declared in this scope
   11 |   for(int i=1; i<=N; i++)g[i].clear();
      |                          ^
speedrun.cpp:13:3: error: 'vector' was not declared in this scope
   13 |   vector<int> us(N+1, 0), pr(N+1, 0);
      |   ^~~~~~
speedrun.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include "speedrun.h"
  +++ |+#include <vector>
    2 | using namespace std;
speedrun.cpp:13:10: error: expected primary-expression before 'int'
   13 |   vector<int> us(N+1, 0), pr(N+1, 0);
      |          ^~~
speedrun.cpp:14:3: error: 'queue' was not declared in this scope
   14 |   queue<int> q;
      |   ^~~~~
speedrun.cpp:2:1: note: 'std::queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
    1 | #include "speedrun.h"
  +++ |+#include <queue>
    2 | using namespace std;
speedrun.cpp:14:9: error: expected primary-expression before 'int'
   14 |   queue<int> q;
      |         ^~~
speedrun.cpp:15:3: error: 'q' was not declared in this scope
   15 |   q.push(1);
      |   ^
speedrun.cpp:16:3: error: 'us' was not declared in this scope
   16 |   us[1]=1;
      |   ^~
speedrun.cpp:21:20: error: 'pr' was not declared in this scope
   21 |     setHint(v, j, (pr[v] & (1<<(j-1) ) ? 1 : 0) );
      |                    ^~
speedrun.cpp:24:18: error: 'g' was not declared in this scope
   24 |    for(auto to : g[v]) {
      |                  ^
speedrun.cpp:26:6: error: 'pr' was not declared in this scope
   26 |      pr[to]=v;
      |      ^~
speedrun.cpp: In function 'void dfs(int, int)':
speedrun.cpp:58:4: error: 'cout' was not declared in this scope
   58 |    cout << "ne\n";
      |    ^~~~
speedrun.cpp:2:1: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    1 | #include "speedrun.h"
  +++ |+#include <iostream>
    2 | using namespace std;
speedrun.cpp:59:4: error: 'exit' was not declared in this scope
   59 |    exit(0);
      |    ^~~~
speedrun.cpp:66:4: error: 'cout' was not declared in this scope
   66 |    cout << "ne\n";
      |    ^~~~
speedrun.cpp:66:4: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
speedrun.cpp:67:4: error: 'exit' was not declared in this scope
   67 |    exit(0);
      |    ^~~~
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:75:7: warning: unused variable 'l' [-Wunused-variable]
   75 |   int l=getLength();
      |       ^