Submission #941230

# Submission time Handle Problem Language Result Execution time Memory
941230 2024-03-08T10:49:30 Z nguyentunglam Toxic Gene (NOI23_toxic) C++17
9.46154 / 100
4 ms 904 KB
#include<bits/stdc++.h>
#include "toxic.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
char a[N], b[N];
int query_sample(vector<int> species) {
  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 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 n; cin >> n;

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

  determine_type(n);

  for(int i = 1; i <= n; i++) cout << b[i] << " ";
}
#endif // ngu

# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Partially correct 4 ms 348 KB Partially correct
3 Partially correct 4 ms 348 KB Partially correct
4 Partially correct 4 ms 348 KB Partially correct
5 Partially correct 4 ms 344 KB Partially correct
6 Partially correct 4 ms 348 KB Partially correct
7 Partially correct 4 ms 348 KB Partially correct
8 Partially correct 4 ms 508 KB Partially correct
9 Partially correct 4 ms 904 KB Partially correct
10 Partially correct 4 ms 504 KB Partially correct
11 Partially correct 4 ms 532 KB Partially correct
12 Partially correct 4 ms 348 KB Partially correct
13 Partially correct 4 ms 528 KB Partially correct
14 Partially correct 4 ms 348 KB Partially correct
15 Partially correct 4 ms 348 KB Partially correct
16 Partially correct 4 ms 348 KB Partially correct
17 Partially correct 4 ms 432 KB Partially correct
18 Partially correct 4 ms 604 KB Partially correct
19 Partially correct 4 ms 348 KB Partially correct
20 Partially correct 4 ms 352 KB Partially correct
21 Partially correct 4 ms 508 KB Partially correct
22 Partially correct 4 ms 352 KB Partially correct
23 Partially correct 3 ms 356 KB Partially correct
24 Partially correct 4 ms 352 KB Partially correct
25 Partially correct 4 ms 352 KB Partially correct
26 Partially correct 3 ms 356 KB Partially correct
27 Partially correct 4 ms 352 KB Partially correct
28 Partially correct 3 ms 348 KB Partially correct
29 Partially correct 4 ms 352 KB Partially correct
30 Partially correct 4 ms 344 KB Partially correct
31 Partially correct 3 ms 352 KB Partially correct
32 Partially correct 4 ms 348 KB Partially correct
33 Partially correct 4 ms 356 KB Partially correct
34 Partially correct 4 ms 348 KB Partially correct
35 Partially correct 4 ms 552 KB Partially correct
36 Partially correct 1 ms 348 KB Partially correct