QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#874812#2742. ComboAlimkhanCompile Error//C++231.3kb2025-01-28 17:13:102025-01-28 17:13:10

Judging History

This is the latest submission verdict.

  • [2025-01-28 17:13:10]
  • Judged
  • [2025-01-28 17:13:10]
  • Submitted

answer

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

using namespace std;

char a[10];
int cnt, n;
char f;
vector <char> v;

char findfirst() {
	string s;
	s += a[1];
	s += a[2];
	int x = press(s);
	if (x == 1) {
		string s2 = a[1];
		x = press(s2);
		if (x == 1) {
			return a[1];
		} else {
			return a[2];
		}
	}
	s = "";
	s += a[3];
	int x = press(s);
	if (x == 1) {
		return a[3];
	}
	return a[4];
}

std::string guess_sequence(int N) {
	n = N;
	a[1] = 'A';
	a[2] = 'B';
	a[3] = 'X';
	a[4] = 'Y';
	f = findfirst();
	string s;
	s += f;
	cnt = 1;
	if (n == 1) {
		return s;
	}
	for (int i = 1; i <= 4; i++) {
		if (a[i] != f) {
			v.push_back(a[i]);
		}
	}
	while(s.size() + 1 < n) {
		string s1 = s;
		string s2 = s;
		string s3 = s;
		string s4 = s;
		cnt = s.size();
		string q;
		s1 += v[0];
		s2 += v[0];
		s3 += v[0];
		
		s1 += v[0];
		s2 += v[1];
		s3 += v[2];
		
		s4 += v[1];
		q += s1;
		q += s2;
		q += s3;
		q += s4;
		int x = press(q);
		if (x == cnt + 2) {
			s += v[0];
			continue;
		}
		if (x == cnt + 1) {
			s += v[1];
			continue;
		}
		s += v[2];
	}
	string s1 = s;
	string s2 = s;
	string s3 = s;
	s1 += v[0];
	s2 += v[1];
	s3 += v[2];
	int x = press(s1);
	if (x == n) {
		return s1;
	}
	x = press(s2);
	if (x == n) {
		return s2;
	}
	return s3;
}

详细

answer.code: In function ‘char findfirst()’:
answer.code:17:32: error: conversion from ‘char’ to non-scalar type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} requested
   17 |                 string s2 = a[1];
      |                             ~~~^
answer.code:27:13: error: redeclaration of ‘int x’
   27 |         int x = press(s);
      |             ^
answer.code:15:13: note: ‘int x’ previously declared here
   15 |         int x = press(s);
      |             ^