QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#325116 | #5614. Simple Solitaire | tom0727 | AC ✓ | 0ms | 3868kb | C++20 | 5.4kb | 2024-02-11 04:22:15 | 2024-02-11 04:22:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#if __cplusplus >= 201103L
struct pairhash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
template<class T, class U>
size_t operator() (const pair<T,U> &p) const {
static const uint64_t FIXED_RANDOM = (uint64_t)chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(p.first + FIXED_RANDOM) ^ splitmix64(p.second+ FIXED_RANDOM);
}
};
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = (uint64_t)chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
inline int randint(int l, int r) {
return uniform_int_distribution<int>(l,r)(rng);
}
inline double randdouble(double l, double r) {
return uniform_real_distribution<double>(l,r)(rng);
}
inline long long randll(long long l, long long r) {
mt19937_64 rng2((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
return uniform_int_distribution<long long>(l, r)(rng2);
}
#endif
#ifndef ONLINE_JUDGE
# define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
# define LOG(x) 0
#endif
#define fastio ios::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define ull unsigned long long
#define ll128 __int128_t
#define PI 3.14159265358979323846
#define abs(a) ((a>0)?a:-(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
const long double pi = acos(-1.0);
const long double eps = (double)1e-10;
// const int mod = 1e9+7;
int mod;
template<class T>
T qpow(T a, int b) {
T res = 1;
while (b) {
if (b & 1) res *= a;
a *= a;
b >>= 1;
}
return res;
}
int norm(int x) {
if (x < 0) {
x += mod;
}
if (x >= mod) {
x -= mod;
}
return x;
}
struct Z {
int x;
Z(int x = 0) : x(norm(x)) {}
Z(ll x) : x(norm((int)(x % mod))) {}
int val() const {
return x;
}
Z operator-() const {
return Z(norm(mod - x));
}
Z inv() const {
assert(x != 0);
return qpow(*this, mod - 2);
}
Z &operator*=(const Z &rhs) {
x = (int)((ll)(x) * rhs.x % mod);
return *this;
}
Z &operator+=(const Z &rhs) {
x = norm(x + rhs.x);
return *this;
}
Z &operator-=(const Z &rhs) {
x = norm(x - rhs.x);
return *this;
}
Z &operator/=(const Z &rhs) {
return *this *= rhs.inv();
}
friend Z operator*(const Z &lhs, const Z &rhs) {
Z res = lhs;
res *= rhs;
return res;
}
friend Z operator+(const Z &lhs, const Z &rhs) {
Z res = lhs;
res += rhs;
return res;
}
friend Z operator-(const Z &lhs, const Z &rhs) {
Z res = lhs;
res -= rhs;
return res;
}
friend Z operator/(const Z &lhs, const Z &rhs) {
Z res = lhs;
res /= rhs;
return res;
}
friend std::istream &operator>>(std::istream &is, Z &a) {
ll v;
is >> v;
a = Z(v);
return is;
}
friend std::ostream &operator<<(std::ostream &os, const Z &a) {
return os << a.val();
}
};
const int maxn = 1001;
const int maxm = 1e6+5;
vector<string> vec;
int cmp(int i, int j) {
if (vec[i][0] == vec[j][0]) return 4;
if (vec[i][1] == vec[j][1]) return 2;
return 0;
}
bool check() {
int n = vec.size();
for (int i = n-1; i >= 0; i--) {
int j = i-3;
if (j >= 0) {
int res = cmp(i, j);
if (res == 4) {
vector<string> tmp;
for (int k = 0; k < j; k++) {
tmp.push_back(vec[k]);
}
for (int k = i+1; k < n; k++) {
tmp.push_back(vec[k]);
}
vec = tmp;
return 1;
}
}
}
for (int i = n-1; i >= 0; i--) {
int j = i-3;
if (j >= 0) {
int res = cmp(i, j);
if (res == 2) {
vector<string> tmp;
for (int k = 0; k < j; k++) {
tmp.push_back(vec[k]);
}
for (int k = j+1; k < i; k++) {
tmp.push_back(vec[k]);
}
for (int k = i+1; k < n; k++) {
tmp.push_back(vec[k]);
}
vec = tmp;
return 1;
}
}
}
return 0;
}
int main() {
for (int i = 1; i <= 52; i++) {
string x; cin >> x;
// LOG(x);
vec.push_back(x);
while (check()) {}
}
cout << vec.size() << " ";
for (string x : vec) cout << x << " ";
cout << "\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
TC 2C 6C TS KC QS QC 3C KD 8D JH JS KH 5D JD 2S 8S AS 9S 3D 5H 9C AH 4D 4C KS JC 4S 7S 6D 2H 7C 8C 7D AD 7H TH 2D QH 8H 9H 5C TD 3S 6H 3H QD 5S 9D 4H 6S AC
output:
2 3S 9D
result:
ok single line: '2 3S 9D '
Test #2:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
TH 2C 8H AS JH JS TS QC KS 3S JC 4D AH QS 2S 5S 3D 7C 4H AD 5C 7S 6C 6S 9C 5D 8D 9H 7H 3H KD KH 4C 8S QD 2D 8C QH KC TC 2H 4S 6H 5H 3C TD 6D JD AC 9S 7D 9D
output:
6 KC 4S 6H TD AC 9S
result:
ok single line: '6 KC 4S 6H TD AC 9S '
Test #3:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
3H 8D 9H 4S 7H KC 6H 4D 4H 5H TS 2C JH QD QH 6C TD KD 3S KS TC 8S KH 2D 9D 9C QS 7D JS 5C 2H AS 5S 5D 4C 7C 8C AC 3C 6D 7S 8H AD 3D JC 2S 6S QC TH JD AH 9S
output:
12 TS AS 5S 5D 7C 3D 2S 6S TH JD AH 9S
result:
ok single line: '12 TS AS 5S 5D 7C 3D 2S 6S TH JD AH 9S '
Test #4:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
9C 2S 5H KS 3S QH 5D 6C JD TC 6H 7C 8H AS 8S 8C 3D JS 2C KD 4C JH AH 5S 4S JC 2D 9S QS QD KH 3H 5C 7H 7D 7S KC 4D 3C 9D 4H AD TH 9H 2H AC QC 6S TD 8D TS 6D
output:
10 KC 9D TH 9H 2H AC QC TD 8D 6D
result:
ok single line: '10 KC 9D TH 9H 2H AC QC TD 8D 6D '
Test #5:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
QS 6D 4H 3H 7S 2S 3C 4D 5H 7H KS 8S 8D 4S 3S KD 3D 2D 6C 4C 7D QH KH JH 2C 6S 6H QC 5D 7C 8H 2H AC JC TH TC JS TD 8C TS 5C 5S AS 9C 9D QD JD AD 9H 9S AH KC
output:
4 2H 5C QD JD
result:
ok single line: '4 2H 5C QD JD '
Test #6:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
AH AS AC AD 2H 2S 2C 2D 3H 3S 3C 3D 4H 4S 4C 4D 5H 5S 5C 5D 6H 6S 6C 6D 7H 7S 7C 7D 8H 8S 8C 8D 9H 9S 9C 9D TH TS TC TD JH JS JC JD QH QS QC QD KH KS KC KD
output:
0
result:
ok single line: '0 '
Test #7:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
AH 2H 3H 4H 5H 6H 7H 8H 9H TH JH QH KH AS 2S 3S 4S 5S 6S 7S 8S 9S TS JS QS KS AC 2C 3C 4C 5C 6C 7C 8C 9C TC JC QC KC AD 2D 3D 4D 5D 6D 7D 8D 9D TD JD QD KD
output:
2 JC QC
result:
ok single line: '2 JC QC '
Test #8:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
AH 2C 3D 4S 5H 6C 7D 8S 9H TC JD QS KH AC 2D 3S 4H 5C 6D 7S 8H 9C TD JS QH KC AD 2S 3H 4C 5D 6S 7H 8C 9D TS JH QC KD AS 2H 3C 4D 5S 6H 7C 8D 9S TH JC QD KS
output:
52 AH 2C 3D 4S 5H 6C 7D 8S 9H TC JD QS KH AC 2D 3S 4H 5C 6D 7S 8H 9C TD JS QH KC AD 2S 3H 4C 5D 6S 7H 8C 9D TS JH QC KD AS 2H 3C 4D 5S 6H 7C 8D 9S TH JC QD KS
result:
ok single line: '52 AH 2C 3D 4S 5H 6C 7D 8S 9H ... 4D 5S 6H 7C 8D 9S TH JC QD KS '
Test #9:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
AS 2S 3S 4H 5H 6H 7C 8C 9C TD JD QD KS 4S 5S 7H 8H 9H TC JC QC KD AD 2D 6S 7S 8S TH JH QH KC AC 2C 3D 4D 5D 9S TS JS KH AH 2H 3C 4C 5C 6D 7D 8D QS 3H 6C 9D
output:
52 AS 2S 3S 4H 5H 6H 7C 8C 9C TD JD QD KS 4S 5S 7H 8H 9H TC JC QC KD AD 2D 6S 7S 8S TH JH QH KC AC 2C 3D 4D 5D 9S TS JS KH AH 2H 3C 4C 5C 6D 7D 8D QS 3H 6C 9D
result:
ok single line: '52 AS 2S 3S 4H 5H 6H 7C 8C 9C ... 3C 4C 5C 6D 7D 8D QS 3H 6C 9D '
Test #10:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
AH 2C 3D 4S 5H 6C 7D 8S 9H TC JD QS KH AC 2D 3S 4H 5C 6D 7S 8H 9C TD JS QH KC AD 2S 3H 4C 5D 6S 7H 8C 9D TS JH QC KD AS 2H 3C 4D 5S 6H 7C 8D 9S TH QD JC KS
output:
36 AH 2C 3D 4S 5H 6C 7D 8S 9H TC JD QS KH AC 2D 3S 4H 5C 6D 7S 8H 9C TD JS QH KC AD 2S 3H 4C 5D 6S 7H QC 4D KS
result:
ok single line: '36 AH 2C 3D 4S 5H 6C 7D 8S 9H ... AD 2S 3H 4C 5D 6S 7H QC 4D KS '
Test #11:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
7D AH AD QS 2C TD 4D 6H JD JH KD 4H 2D 7H KC 8H JS 4C 9C 9H 6D 3H AC 2S TH QD 3S KS 7C 8S 5C 2H 5D QC 9D 9S 5H TS QH 6C 4S 8C KH 3C 5S 6S 7S 8D JC AS 3D TC
output:
16 7D KS 5C QC 9D 9S 5H 6C 8C 3C 5S 6S 8D JC 3D TC
result:
ok single line: '16 7D KS 5C QC 9D 9S 5H 6C 8C 3C 5S 6S 8D JC 3D TC '
Test #12:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
6S 3S KC JD 5H AD 3C 9D 4S 2H 3D 9C TC TD QH KS 8D 4H 2D 8H QS 3H JH AC 2C 5D AH 2S 8C 7D 8S 9H 7C 6H 6C 5C JC TS 6D 7H 4C 7S QD QC KH 5S AS 9S KD 4D TH JS
output:
4 4C 4D TH JS
result:
ok single line: '4 4C 4D TH JS '
Test #13:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
QC 2C 8H 8C 7D 8S 5S TH 7H 9D 5H 4D 9H 6S QH 5C JD KH 3H 6H 6D 4S 3C 4H JH 9C 8D 7S JS TC KS QD TS AC 4C KD AD 3D 7C 2D 3S JC 2S AS 5D 9S KC 6C QS 2H AH TD
output:
4 6C QS AH TD
result:
ok single line: '4 6C QS AH TD '
Test #14:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
5S TD AD QS 9S 5H 7H 7C 5D 3S 8S 7D 4H AH 8H TS 2H JC 6H 5C JD TC 3H TH 6S QH 2S QC KC 4S KD 4D AC 6C 3C 7S AS 2C 9D JH KS KH 4C 8D QD 8C 6D 9C 3D 9H JS 2D
output:
6 8D 6D 9C 9H JS 2D
result:
ok single line: '6 8D 6D 9C 9H JS 2D '
Test #15:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
5D AC 4C 6C KS TH JH TS 4H 2C 3C QC 3H 3D 9S 6D AH 5S QS QH KC 2D TC KD 9C 7H TD 2H AD 8C 3S 9D 2S 6S 6H 8S 7S 4D 7D AS 9H JC 5H 7C JS KH 4S 8H JD 8D QD 5C
output:
4 KH JD QD 5C
result:
ok single line: '4 KH JD QD 5C '
Test #16:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
8H 3S QH KC TS 8D TH 5D 7C AS 4D 6H 4S JH 9S 6D 3H 6S AH 8C KD 3C 9C 7S 5S TD AD 5C 5H AC TC KS 7H 2H 9D 9H 4C 8S KH 4H 7D QC 3D JS 2C JD 6C QD JC 2D 2S QS
output:
4 TC KS 2D QS
result:
ok single line: '4 TC KS 2D QS '
Test #17:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
8S 6H 3S 7C TH 7H 4S 5H KC TD 5S 5C TC KS 9C AC QC JD AH 6C AD JS 8C 9S QH QD QS 9H 2S JH 2D 9D 3H AS 4C 8D 7S 3C 2H 8H 3D 6D KH 5D 4H 2C 6S 7D KD TS 4D JC
output:
4 7D KD 4D JC
result:
ok single line: '4 7D KD 4D JC '
Test #18:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
6C 9D 4C 8D TD 7C 2H 7H 6D JD 4D 8S 3S AC TC 9H 8H 5S QD 9S QH 2S 7S QC 5C 9C JH KC KD 4S AS 2C AH 4H 6S KH TH JS KS 5D 6H 7D 2D 5H TS 3H 8C JC AD 3D 3C QS
output:
4 2C JS 7D QS
result:
ok single line: '4 2C JS 7D QS '
Test #19:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
6S TH 2C AS AC JC 3C AD 3D TD 3S QH 8S 5C KH 9S 9H 4H 8D 8C 7D AH QD JS 2S KS 5S 6D 4D JD 5D 5H 6H TC JH 2D KC 4C KD 8H 7C QC QS 7H 3H 4S 2H 7S 6C TS 9C 9D
output:
10 TH AC JC AD 2H 7S 6C TS 9C 9D
result:
ok single line: '10 TH AC JC AD 2H 7S 6C TS 9C 9D '
Test #20:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
2D 8D 6C 9H KH TS TC AS 6D 2S 2H 3H 5D QC 9D 5S 4D 5H 4H JC 4C 2C 7S 8S 7D 9S 6H 8H JS JH 3D AD KS 7H AC 3C KD 8C KC QS 4S TD AH QD 5C 7C 9C JD TH 6S 3S QH
output:
20 2D 4C 7S 6H 8H JH 3D KD 8C QS 4S TD AH QD 5C 7C 9C JD 6S 3S
result:
ok single line: '20 2D 4C 7S 6H 8H JH 3D KD 8C QS 4S TD AH QD 5C 7C 9C JD 6S 3S '
Test #21:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
9H 7D AC QH JD 8D 2S KS 9C 9D 7H 7S 4C QC 4H 6S QD 8C JH KD 2C 5C TC 3S 3D 5H KC JS QS 5D 8H 9S TD AD 6H 6D AH 3C 3H TS 4D 7C 8S KH 2D 4S 5S 2H AS TH 6C JC
output:
0
result:
ok single line: '0 '
Test #22:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
JC 7H AH TH 3D 6C 9S 7S QH 7C TD 8S 6S 6H 4C 9C 2H 5H 6D TS 5D 3S 8C 4H 2C AC 4S 8D 5S KS 4D AS KH 9H KD 2D 7D QC JS 2S JH 9D 3H 3C 8H KC AD JD QD TC 5C QS
output:
22 JC 7H 8D 5S 4D AS KH 9H KD 2D 7D QC JS 2S JH 9D 3H 3C 8H KC AD JD
result:
ok single line: '22 JC 7H 8D 5S 4D AS KH 9H KD ... JS 2S JH 9D 3H 3C 8H KC AD JD '
Test #23:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
AH 2C 3D 4S 5H 6C 7D 8S 9H 5S JD QS KH AC 2D 3S 4H 5C 6D 7S 8H 9C TD JS QH KC AD 2S 3H 4C 7C 6S 7H 8C 9D TS JH QC KD AS 2H 3C 4D TC 6H 5D 8D 9S TH JC QD KS
output:
14 AH 2C 3D 4S 5H 6C 7D 8S 8D 9S TH JC QD KS
result:
ok single line: '14 AH 2C 3D 4S 5H 6C 7D 8S 8D 9S TH JC QD KS '
Test #24:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
AH 2C 3D 4S 5H 6C 7D 8S 9H TC JD QS KH AC 2D 3S 4H 5C 6D 7S 8H 9C TD KC JS QH AD 2S 3H 4C 5D 6S 7H 9D 8C TS JH QC KD AS 2H 3C 4D 5S 6H 7C 8D 9S TH JC QD KS
output:
22 AH 2C 3D 4S 5H 9H JH QC KD AS 2H 3C 4D 5S 6H 7C 8D 9S TH JC QD KS
result:
ok single line: '22 AH 2C 3D 4S 5H 9H JH QC KD ... 4D 5S 6H 7C 8D 9S TH JC QD KS '
Test #25:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
AH 2C 3D 4S 5H 6C 7D 8S 9H TC JD QS KH AC 2D 3S 4H 5C 6D 7S 8H 9C TD JS QH KC AD 2S 3H KS 5D 6S 7H 8C 9D TS JH QC KD AS 2H 3C 4D 5S 6H 7C 9S 8D TH JC QD 4C
output:
0
result:
ok single line: '0 '
Test #26:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
AH 2H 3H 4C 5S 6S 7S 4H 8H 9S 5H 6H 7H 9H TH JH QH KH AS 2S 3S 4S 8S TS JS QS KS AC 2C 3C 5C 6C 7C 8C 9C TC JC QC KC AD 2D 3D 4D 5D 6D 7D 8D 9D TD JD QD KD
output:
4 TH QH TC QC
result:
ok single line: '4 TH QH TC QC '