QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#360863#7104. Halting ProblemYeongTreeCompile Error//C++171.6kb2024-03-22 12:44:552024-03-22 12:44:56

Judging History

你现在查看的是最新测评结果

  • [2024-03-22 12:44:56]
  • 评测
  • [2024-03-22 12:44:55]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <queue>
#include <numeric>
#include <set>
#include <map>
#include <random>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define piii pair<int, pii>
#define plll pair<long long, pll>
#define tiii array<int, 3>
#define tiiii array<int, 4>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
typedef long long ll;
const int INF = (int)1e9 + 7;

using namespace std;

bool chc[101010][256];
map<string, int> M = {
	{"add", 0},
	{"beq", 1},
	{"bne", 2},
	{"blt", 3},
	{"bgt", 4}
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int T; cin >> T;
	while(T--)
	{
		int n; cin >> n;

		for(int i = 0; i < n; ++i) for(int j = 0; j < 256; ++j) chc[i][j] = false;

		vector<tiii> A(n);
		for(int i = 0; i < n; ++i)
		{
			string s; int x; cin >> s >> x;
			if(M[s] == 0) A[i] = {M[s], x, 0};
			else
			{
				int y; cin >> y; --y;
				A[i] = {M[s], x, y};
			}
		}

		int i = 0; unsigned char x = 0;
		bool ans = false;
		while(1)
		{
			// cout << "!!" << i << ' ' << (int)x << '\n';
			if(i == n) { ans = true; break; }
			if(chc[i][x]) break;
			chc[i][x] = true;

			if(A[i][0] == 0) x += A[i][1], ++i;
			else if(A[i][0] == 1) i = (x == A[i][1] ? A[i][2] : i + 1);
			else if(A[i][0] == 2) i = (x != A[i][1] ? A[i][2] : i + 1);
			else if(A[i][0] == 3) i = (x < A[i][1] ? A[i][2] : i + 1);
			else if(A[i][0] == 4) i = (x > A[i][1] ? A[i][2] : i + 1);
		}

		cout << (ans ? "Yes" : "No") << '\n';
	}
}

Details

answer.code: In function ‘int main()’:
answer.code:51:57: error: invalid use of incomplete type ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘struct std::array<int, 3>’}
   51 |                         if(M[s] == 0) A[i] = {M[s], x, 0};
      |                                                         ^
In file included from /usr/include/c++/13/bits/memory_resource.h:47,
                 from /usr/include/c++/13/string:58,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/c++/13/tuple:2005:45: note: declaration of ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘struct std::array<int, 3>’}
 2005 |   template<typename _Tp, size_t _Nm> struct array;
      |                                             ^~~~~
answer.code:55:51: error: invalid use of incomplete type ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘struct std::array<int, 3>’}
   55 |                                 A[i] = {M[s], x, y};
      |                                                   ^
/usr/include/c++/13/tuple:2005:45: note: declaration of ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘struct std::array<int, 3>’}
 2005 |   template<typename _Tp, size_t _Nm> struct array;
      |                                             ^~~~~
answer.code:68:32: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘std::array<int, 3>’} and ‘int’)
   68 |                         if(A[i][0] == 0) x += A[i][1], ++i;
      |                                ^
answer.code:68:51: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘std::array<int, 3>’} and ‘int’)
   68 |                         if(A[i][0] == 0) x += A[i][1], ++i;
      |                                                   ^
answer.code:69:37: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘std::array<int, 3>’} and ‘int’)
   69 |                         else if(A[i][0] == 1) i = (x == A[i][1] ? A[i][2] : i + 1);
      |                                     ^
answer.code:69:61: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘std::array<int, 3>’} and ‘int’)
   69 |                         else if(A[i][0] == 1) i = (x == A[i][1] ? A[i][2] : i + 1);
      |                                                             ^
answer.code:69:71: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘std::array<int, 3>’} and ‘int’)
   69 |                         else if(A[i][0] == 1) i = (x == A[i][1] ? A[i][2] : i + 1);
      |                                                                       ^
answer.code:70:37: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘std::array<int, 3>’} and ‘int’)
   70 |                         else if(A[i][0] == 2) i = (x != A[i][1] ? A[i][2] : i + 1);
      |                                     ^
answer.code:70:61: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘std::array<int, 3>’} and ‘int’)
   70 |                         else if(A[i][0] == 2) i = (x != A[i][1] ? A[i][2] : i + 1);
      |                                                             ^
answer.code:70:71: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘std::array<int, 3>’} and ‘int’)
   70 |                         else if(A[i][0] == 2) i = (x != A[i][1] ? A[i][2] : i + 1);
      |                                                                       ^
answer.code:71:37: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type’ {aka ‘std::array<int, 3>’} and ‘int’)
   71 |                         else if(A[i][0] == 3) i = (x < A[i][1] ? A[i][2] : i + 1);
      |                                     ^
answer.code:71:60: error: no match for ‘operator[]’ (operand types are ‘__gnu_cxx::__alloc...