QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#875591#2745. Mechanical DollAlimkhanCompile Error//C++231.8kb2025-01-29 23:40:382025-01-29 23:40:38

Judging History

This is the latest submission verdict.

  • [2025-01-29 23:40:38]
  • Judged
  • [2025-01-29 23:40:38]
  • Submitted

answer

#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second

const int maxn = 1e6 + 10;

int n, m, s, pw, l, id, a[maxn], cnt;
vector <int> X, Y;
vector <int> c;
vector <int> A1;
unoredered_map <int, int> lf, rg, used;
vector <pair <int, int> > d;

inline void get(int v, int tl, int tr) {
	int tm = (tl + tr) / 2;
	if (tm <= l) {
		lf[v] = -1;
	}
	if (tm + 1 == tr) {
		rg[v] = a[tr];
		// cnt++;
	} else {
		s--;
		rg[v] = s;
		get(s, tm + 1, tr);
	}
	if (tl == tm && lf[v] == 0) {
		lf[v] = a[tl];
		// cnt++;
	} else {
		if (lf[v] == 0) {
			s--;
			lf[v] = s;
			get(s, tl, tm);
		}
	}
	// cout << v << " " << lf[v] << " " << rg[v] << '\n';
}

inline void dfs(int v) {
	used[v]++;
	if (v == 0) return;
	if (cnt >= A1.size()) return;
	if (used[v] % 2 == 1) {
		if (lf[v] == m + 1) {
			lf[v] = A1[cnt];
			cnt++;
			if (lf[v] == 0) return;
			dfs(-1);
		} else {
			dfs(lf[v]);
		}
	} else {
		if (rg[v] == m + 1) {
			rg[v] = A1[cnt];
			cnt++;
			if (rg[v] == 0) return;
			dfs(-1);
		
		} else {
			dfs(rg[v]);
		}
	}
}

void create_circuit(int M, std::vector<int> A) {
	A.push_back(0);	
	c = {A[0]};
	A.erase(A.begin());
	// a = A;
	A1 = A;
	n = A.size();
	m = M;
	pw = 2;
	while(pw < n) {
		pw *= 2;
	}
	fill(a + 1, a + pw + 1, m + 1);
	while(l + n < pw) {
		l++;
		a[l] = -1;
	}
	s = -1;
	get(-1, 1, pw);
	dfs(-1);
	for (int i = 1; i <= M; i++) {
		c.push_back(-1);
	}
	// c.push_back(-1);
	for (int i = -1; i >= s; i--) {
		X.push_back(lf[i]);
		Y.push_back(rg[i]);
		// cout << i << " " << lf[i] << " " << rg[i] << '\n';
	}
	// for (int i = 0; i < c.size(); i++) {
	// 	cout << c[i] << " ";
	// }
	// cout << '\n';
	answer(c, X, Y);
}

詳細信息

answer.code:16:1: error: ‘unoredered_map’ does not name a type
   16 | unoredered_map <int, int> lf, rg, used;
      | ^~~~~~~~~~~~~~
answer.code: In function ‘void get(int, int, int)’:
answer.code:22:17: error: ‘lf’ was not declared in this scope; did you mean ‘l’?
   22 |                 lf[v] = -1;
      |                 ^~
      |                 l
answer.code:25:17: error: ‘rg’ was not declared in this scope
   25 |                 rg[v] = a[tr];
      |                 ^~
answer.code:29:17: error: ‘rg’ was not declared in this scope
   29 |                 rg[v] = s;
      |                 ^~
answer.code:32:25: error: ‘lf’ was not declared in this scope; did you mean ‘l’?
   32 |         if (tl == tm && lf[v] == 0) {
      |                         ^~
      |                         l
answer.code: In function ‘void dfs(int)’:
answer.code:46:9: error: ‘used’ was not declared in this scope
   46 |         used[v]++;
      |         ^~~~
answer.code:50:21: error: ‘lf’ was not declared in this scope; did you mean ‘l’?
   50 |                 if (lf[v] == m + 1) {
      |                     ^~
      |                     l
answer.code:59:21: error: ‘rg’ was not declared in this scope
   59 |                 if (rg[v] == m + 1) {
      |                     ^~
answer.code: In function ‘void create_circuit(int, std::vector<int>)’:
answer.code:96:29: error: ‘lf’ was not declared in this scope; did you mean ‘l’?
   96 |                 X.push_back(lf[i]);
      |                             ^~
      |                             l
answer.code:97:29: error: ‘rg’ was not declared in this scope
   97 |                 Y.push_back(rg[i]);
      |                             ^~