QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#142809#4565. Rarest Insectsscidroid#Compile Error//C++17579b2023-08-19 23:10:062024-07-04 01:49:05

Judging History

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

  • [2024-07-04 01:49:05]
  • 评测
  • [2023-08-19 23:10:06]
  • 提交

answer

#include "insects.h"

int min_cardinality(int N) {
  bool vis[N];

  memset(vis, true, sizeof vis);

  std::vector<int> apps;

  for (int i = 0; i < N; ++i) {
    if (vis[i]) {
	  move_inside(i);
	  vis[i] = false;

	  int count = 1;

	  for (int j = i + 1; j < N; ++j) {
		  if (vis[j]) {
			  move_inside(j);

			  if (press_button() == 2) {
				  count++;
				  vis[j] = false;
			  }
			  
			  move_outside(j);
		  }
	  }

    move_outside(i);

	  apps.push_back(count);
    }
  }

  sort(apps.begin(), apps.end());

  return apps[0];
}

Details

answer.code: In function ‘int min_cardinality(int)’:
answer.code:6:3: error: ‘memset’ was not declared in this scope
    6 |   memset(vis, true, sizeof vis);
      |   ^~~~~~
answer.code:2:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
    1 | #include "insects.h"
  +++ |+#include <cstring>
    2 | 
answer.code:8:8: error: ‘vector’ is not a member of ‘std’
    8 |   std::vector<int> apps;
      |        ^~~~~~
answer.code:2:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    1 | #include "insects.h"
  +++ |+#include <vector>
    2 | 
answer.code:8:15: error: expected primary-expression before ‘int’
    8 |   std::vector<int> apps;
      |               ^~~
answer.code:32:11: error: ‘apps’ was not declared in this scope
   32 |           apps.push_back(count);
      |           ^~~~
answer.code:36:8: error: ‘apps’ was not declared in this scope
   36 |   sort(apps.begin(), apps.end());
      |        ^~~~
answer.code:36:3: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   36 |   sort(apps.begin(), apps.end());
      |   ^~~~
      |   short