제출 #1219128

#제출 시각아이디문제언어결과실행 시간메모리
1219128giorgi123glmCoins (IOI17_coins)C++20
0 / 100
1 ms584 KiB
#include "coins.h"
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

vector<int> coin_flips(vector<int> b, int c) {
    int dplus = 0;
    int dminu = 0;
    int hash = 0;
    for (int& e : b)
        if (e == 0)
            dplus++;
        else
            dminu++, hash++;

    hash %= 64;

    if (c == hash)
        // nice
        return b;
    else {
        int ansplus = hash - c;
        if (ansplus < 0)
            ansplus += 64;
        if (ansplus < dplus) {
            for (int& e : b)
                if (e == 0 && ansplus) {
                    e = 1;
                    ansplus--;
                }
            return b;
        }

        int ansminu = c - hash;
        if (ansminu < 0)
            ansminu += 64;
        if (ansminu < dminu) {
            for (int& e : b)
                if (e == 1 && ansminu) {
                    e = 0;
                    ansminu--;
                }
            return b;
        }

        // ?
        exit (1);
    }
}

int find_coin(vector<int> b) {
    int hash = 0;
    for (int& e : b)
        if (e == 1)
            hash++;
    return (hash + 64) % 64;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...