Submission #941240

# Submission time Handle Problem Language Result Execution time Memory
941240 2024-03-08T10:55:08 Z nguyentunglam Toxic Gene (NOI23_toxic) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;

const int N = 300 + 10;
bool mark[N];
#ifdef ngu
int cnt_query;
char a[N], b[N];
int query_sample(vector<int> species) {
  cnt_query++;
  bool toxic = 0;
  for(int &j : species) toxic |= a[j] == 'T';
  int ret = 0;
  for(int &j : species) {
    if (a[j] == 'S') ret++;
    else if (a[j] == 'R' && !toxic) ret++;
  }
  return ret;
}

void answer_type(int x, char c) {
  b[x] = c;
}
#endif // ngu

void determine_type (int n) {
  int timer = 0;
  for(int i = 1; i <= 300; i++) for(int j = 1; j <= 300; j++) for(int k = 1; k <= 300; k++) timer++;
  int toxic = 0;
  for(int i = 1; i <= n; i++) mark[i] = 0;
  for(int i = 1; i <= n; i++) if (query_sample({i}) == 0) {
    answer_type(i, 'T');
    toxic = i;
    mark[i] = 1;
  }

  for(int i = 1; i <= n;) {
    int cur = 1;
    vector<int> ask;
    ask.push_back(toxic);
    int j = i;
    while (ask.size() + cur <= 300 && j <= n) {
      for(int k = 1; k <= cur; k++) ask.push_back(j);
      cur *= 2;
      j++;
    }
    int result = query_sample(ask);
    for(int k = 0; k < j - i; k++) if (!mark[i + k]) {
      if (result >> k & 1) answer_type(i + k, 'S');
      else answer_type(i + k, 'R');
    }
    i = j;
  }
}
#ifdef ngu
int main() {

  freopen ("task.inp", "r", stdin);
  freopen ("task.out", "w", stdout);

  int t; cin >> t;

  while (t--) {
    cnt_query = 0;
    int n; cin >> n;

    for(int i = 1; i <= n; i++) cin >> a[i];

    determine_type(n);

    for(int i = 1; i <= n; i++) assert(a[i] == b[i]);

    for(int i = 1; i <= n; i++) cout << b[i] << " "; cout << endl;
    assert(cnt_query <= 600);

    cerr << cnt_query << endl;
  }
}
#endif // ngu

Compilation message

toxic.cpp: In function 'void determine_type(int)':
toxic.cpp:35:35: error: 'query_sample' was not declared in this scope
   35 |   for(int i = 1; i <= n; i++) if (query_sample({i}) == 0) {
      |                                   ^~~~~~~~~~~~
toxic.cpp:36:5: error: 'answer_type' was not declared in this scope
   36 |     answer_type(i, 'T');
      |     ^~~~~~~~~~~
toxic.cpp:51:18: error: 'query_sample' was not declared in this scope
   51 |     int result = query_sample(ask);
      |                  ^~~~~~~~~~~~
toxic.cpp:53:28: error: 'answer_type' was not declared in this scope
   53 |       if (result >> k & 1) answer_type(i + k, 'S');
      |                            ^~~~~~~~~~~
toxic.cpp:54:12: error: 'answer_type' was not declared in this scope
   54 |       else answer_type(i + k, 'R');
      |            ^~~~~~~~~~~