#include "grader.h"
#include "memory.h"
#include <bits/stdc++.h>
using namespace std;
constexpr int SZ = 25;
void play() {
int i;
char a, b;
vector<pair<int, int>> ready;
int found = 0;
vector<pair<int, int>> cards(SZ, {-1, -1});
auto addCard = [&](char c, int card) -> void {
int pos = c - 'A';
if (cards[pos].first == -1) {
cards[pos].first = card;
}
else {
cards[pos].second = card;
ready.emplace_back(cards[pos]);
}
};
int cardToCheck = 1;
for (int i = 0; i < 100 && found < SZ; i++) {
if (ready.size()) {
auto [f1, f2] = ready.back(); ready.pop_back();
a = faceup(f1);
b = faceup(f2);
found++;
}
else {
a = faceup(cardToCheck);
b = faceup(cardToCheck + 1);
if (a == b) {
found++;
}
else {
addCard(a, cardToCheck);
addCard(b, cardToCheck + 1);
}
cardToCheck += 2;
}
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |