답안 #1041768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041768 2024-08-02T07:53:53 Z NeroZein Tricolor Lights (JOI24_tricolor) C++17
0 / 100
41 ms 1396 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[129]) {
      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); 
    }
  }
  assert(unchosen.size() == 2 && candidates.size() == 2); 
  s[129] = candidates[chosen]; 
  for (int i = 0, last = 0; i < n; ++i) {
    if (i == 129) {
      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 39 ms 1300 KB Output is correct
2 Correct 27 ms 1396 KB Output is correct
3 Correct 26 ms 1340 KB Output is correct
4 Correct 33 ms 1324 KB Output is correct
5 Correct 31 ms 1328 KB Output is correct
6 Correct 37 ms 1292 KB Output is correct
7 Incorrect 1 ms 856 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1300 KB Output is correct
2 Correct 27 ms 1396 KB Output is correct
3 Correct 26 ms 1340 KB Output is correct
4 Correct 33 ms 1324 KB Output is correct
5 Correct 31 ms 1328 KB Output is correct
6 Correct 37 ms 1292 KB Output is correct
7 Incorrect 1 ms 856 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1300 KB Output is correct
2 Correct 27 ms 1396 KB Output is correct
3 Correct 26 ms 1340 KB Output is correct
4 Correct 33 ms 1324 KB Output is correct
5 Correct 31 ms 1328 KB Output is correct
6 Correct 37 ms 1292 KB Output is correct
7 Incorrect 1 ms 856 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1300 KB Output is correct
2 Correct 27 ms 1396 KB Output is correct
3 Correct 26 ms 1340 KB Output is correct
4 Correct 33 ms 1324 KB Output is correct
5 Correct 31 ms 1328 KB Output is correct
6 Correct 37 ms 1292 KB Output is correct
7 Incorrect 1 ms 856 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 1388 KB Output is correct
2 Correct 28 ms 1380 KB Output is correct
3 Correct 38 ms 1308 KB Output is correct
4 Correct 27 ms 1308 KB Output is correct
5 Partially correct 26 ms 1372 KB Partially correct
6 Partially correct 34 ms 1292 KB Partially correct
7 Incorrect 1 ms 856 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -