Submission #1360760

#TimeUsernameProblemLanguageResultExecution timeMemory
1360760avahwCoins (IOI17_coins)C++20
25 / 100
4 ms660 KiB
#include "coins.h"
#include <bits/stdc++.h>
using namespace std;

std::vector<int> coin_flips(std::vector<int> b, int c) {
    vector<int> flips;
    // encode row in row 0
    int row = c / 8;
    int col = c % 8;
    // encode row in row 1
    for(int i = 2; i >= 0; i--){
        if(row >= pow(2, i)){
            row -= pow(2, i);
            if(b[i] != 1) flips.push_back(i); 
        }
        else{
            if(b[i] != 0) flips.push_back(i);
        }
    }
    for(int i = 2; i >= 0; i--){
        if(col >= pow(2, i)){
            col -= pow(2, i);
            if(b[i + 8] != 1){
                flips.push_back(i + 8);
            }
        }
        else{
            if(b[i + 8] != 0){
                flips.push_back(i + 8);
            }
        }
    }
    if(flips.size() == 0) flips.push_back(63);
    return flips;
}

int find_coin(std::vector<int> b) {
    int row = 0;
    int col = 0;
    // get row from row 0
    for(int i = 0; i < 3; i++){
        row += pow(2, i) * b[i];
    }
    // get col from row 1
    for(int i = 0; i < 3; i++){
        col += pow(2, i) * b[i + 8];
    }
    return (row * 8) + col;
}

Compilation message (stderr)

grader.cpp: In function 'void shuffle(std::vector<int>&)':
grader.cpp:88:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   88 |         random_shuffle(v.begin(), v.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from grader.cpp:5:
/usr/include/c++/13/bits/stl_algo.h:4581:5: note: declared here
 4581 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...