| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1365825 | LaMatematica14 | Fortune Telling 3 (JOI25_fortune3) | C++20 | 39 ms | 824 KiB |
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
// グローバル変数と内部関数は無名名前空間内で宣言すること
// All global variables and internal functions should be declared in an unnamed namespace
int bit = 10;
int process(bool a, int type, vector<int> &att) {
// -1: throw away
// 0 : 0 of the 10
// 1 : 1 of the 10
// 2 : too little 0
// 3 : remaining 1
// x-4 : normal has to choose bit
int pos = -1;
switch (type) {
case -1:
break;
case 0:
pos = att.size();
for (int i = 0; i+1 < att.size(); i++) {
if (att[i] == 1 && att[i+1] == 1) pos = i+1;
}
break;
case 1:
pos = 0;
if (att.size() > 0 && att[0] == 0) break;
for (int i = 0; i+1 < att.size(); i++) {
if (att[i] == 0 && att[i+1] == 0) {
pos = i+1; break;
}
}
break;
case 2:
pos = 0;
break;
case 3:
pos = att.size();
break;
default:
int pot = type-4;
int o = -1;
for (int i = 0; i < att.size(); i++) {
if (o == pot) {
pos = i; break;
}
if (att[i] == 1) {
if (i+1 < att.size() && att[i+1] == 1) i++;
o++;
}
}
}
if (pos > -1)
att.insert(att.begin()+pos, a);
return DrawCard(pos);
}} // namespace
void Anna(int N) {
vector<int> att;
int ones = 0, zeros = 0, type = -1;
bool a = 0;
// first standard
for (int i = 0; i < N-bit; i++) {
a = process(a, type, att);
if (a) {
if (ones < bit) type = 1;
else type = -1;
ones++;
} else if (zeros < bit) {
type = 0;
zeros++;
} else type = -1;
}
//last ten
if (zeros < bit) {
// less than 20 zeros
for (int i = 0; i < bit; i++) {
a = process(a, type, att);
if (a == 0) type = 2;
else type = -1;
}
} else if (ones < bit) {
// less than 20 ones
for (int i = 0; i < bit; i++) {
a = process(a, type, att);
if (a) type = 3;
else type = -1;
}
} else {
// normal case
ones-=bit-1;
for (int i = 0; i < bit; i++) {
a = process(a, type, att);
if (ones&(1<<i)) type = i+4;
else if (a) type = 3;
else type = -1;
}
}
process(a, type, att);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
// グローバル変数と内部関数は無名名前空間内で宣言すること
// All global variables and internal functions should be declared in an unnamed namespace
int bit = 10;
} // namespace
int Bruno(int N, int L, vector<int> C) {
if (L <= bit*2 || C[0] == 0) {
int zeros = 0;
for (int i : C) {
if (i == 0) zeros++;
}
if (L-zeros != bit) return L-zeros;
if (C[0] == 0) return N-zeros;
if (C[L-1] == 1 && zeros == bit) return L-zeros;
return N-zeros;
}
int cnt = 0;
int res = 0;
int norm = 0;
for (int i = 0; i < L; i++) {
if (i>=1 && C[i-1] == 1 && i+1 < L && C[i+1] == 0) res |= 1<<norm;
if (C[i] == 1) cnt++;
else {
if (i+1<L && C[i+1] == 0) i++;
norm++;
}
}
res--;
if (norm == bit) return res+cnt;
return cnt;
}컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
