답안 #1041762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041762 2024-08-02T07:51:00 Z NeroZein Tricolor Lights (JOI24_tricolor) C++17
0 / 100
47 ms 1392 KB
#include "Anna.h"
#include <bits/stdc++.h>

using namespace std; 

const char d[] = {'R', 'G', 'B'};

pair<string, int> anna(int N, string S) {
  int n = N;
  string s = S; 
  string t(n, '0');
  if (n <= 130) {
    for (int i = 0; i < n; ++i) {
      for (char c : d) {
        if (c != s[i]) {
          t[i] = c;
          break; 
        }
      }
    }
    return {t, n}; 
  }
  map<char, int> mp;
  for (char c : s) {
    mp[c]++; 
  }
  vector<char> candidates; 
  for (char c : d) {
    if (c != s[130]) {
      candidates.push_back(c); 
    }
  }
  int chosen = 0; 
  if (mp[candidates[1]] > n / 2) {
    chosen = 1; 
  }
  //now the unchosen appears atmost n / 2 times. 
  vector<char> unchosen;
  for (char c : d) {
    if (c != candidates[chosen]) {
      unchosen.push_back(c); 
    }
  }
  s[130] = candidates[chosen]; 
  for (int i = 0, last = 0; i < n; ++i) {
    if (i == 130) {
      continue; 
    } 
    if (s[i] != unchosen[last ^ 1]) {
      t[i] = unchosen[last ^ 1]; 
      last ^= 1;       
    } else {
      t[i] = unchosen[last]; 
    }
  }
  return {t, 130};
}
#include "Bruno.h"
#include <bits/stdc++.h>

using namespace std; 

int n, l;
void init(int N, int l_) {
  n = N, l = l_; 
}

int bruno(string u) {
  if (n <= 130) {
    return 1; 
  }
  map<char, int> mp;
  for (char c : u) {
    mp[c]++; 
  }
  int ind = -1; 
  for (int i = 0; i < l; ++i) {
    if (mp[u[i]] == 1) {
      assert(ind == -1);
      ind = i; 
    }
  } 
  return 1 + (129 - ind); 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1388 KB Output is correct
2 Correct 35 ms 1324 KB Output is correct
3 Correct 25 ms 1320 KB Output is correct
4 Correct 42 ms 1384 KB Output is correct
5 Correct 28 ms 1336 KB Output is correct
6 Correct 46 ms 1392 KB Output is correct
7 Incorrect 0 ms 856 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1388 KB Output is correct
2 Correct 35 ms 1324 KB Output is correct
3 Correct 25 ms 1320 KB Output is correct
4 Correct 42 ms 1384 KB Output is correct
5 Correct 28 ms 1336 KB Output is correct
6 Correct 46 ms 1392 KB Output is correct
7 Incorrect 0 ms 856 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1388 KB Output is correct
2 Correct 35 ms 1324 KB Output is correct
3 Correct 25 ms 1320 KB Output is correct
4 Correct 42 ms 1384 KB Output is correct
5 Correct 28 ms 1336 KB Output is correct
6 Correct 46 ms 1392 KB Output is correct
7 Incorrect 0 ms 856 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1388 KB Output is correct
2 Correct 35 ms 1324 KB Output is correct
3 Correct 25 ms 1320 KB Output is correct
4 Correct 42 ms 1384 KB Output is correct
5 Correct 28 ms 1336 KB Output is correct
6 Correct 46 ms 1392 KB Output is correct
7 Incorrect 0 ms 856 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1324 KB Output is correct
2 Correct 28 ms 1292 KB Output is correct
3 Correct 24 ms 1336 KB Output is correct
4 Correct 28 ms 1304 KB Output is correct
5 Partially correct 29 ms 1324 KB Partially correct
6 Partially correct 47 ms 1304 KB Partially correct
7 Incorrect 1 ms 856 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -