Submission #1365797

#TimeUsernameProblemLanguageResultExecution timeMemory
1365797LaMatematica14Fortune Telling 3 (JOI25_fortune3)C++20
0 / 100
4 ms756 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;
            for (int i = 0; i+1 < att.size(); i++) {
                if (att[i] == 0 && att[i+1] == 0) pos = i+1;
            }
            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;
        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 (C[0] == 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 (C[i+1] == 0) i++;
            norm++;
        }
    }
    if (norm == bit) return res+cnt;
    return cnt; 
}

Compilation message (stderr)

# 1번째 컴파일 단계

grader_anna.cpp: In function 'int main()':
grader_anna.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |     scanf("%d %d", &Q, &stubN);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~

# 2번째 컴파일 단계

grader_bruno.cpp: In function 'int main()':
grader_bruno.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d %d", &Q, &N);
      |     ~~~~~^~~~~~~~~~~~~~~~~
grader_bruno.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf(" %d", &L);
      |         ~~~~~^~~~~~~~~~~
grader_bruno.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |             scanf(" %d", &C[i]);
      |             ~~~~~^~~~~~~~~~~~~~
#Result Execution timeMemoryGrader output
Fetching results...