0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

#1496. 麻将(mahjong)

https://sjzezoj.com/submission/55729
This commit is contained in:
Baoshuo Ren 2022-08-26 17:11:22 +08:00
parent 50abfb0abc
commit 1104a5b26c
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
52 changed files with 259 additions and 0 deletions

106
S2OJ/1496/1496.cpp Normal file
View File

@ -0,0 +1,106 @@
#include <iostream>
#include <algorithm>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 15;
int n, t, a[N << 2], b[N << 2];
bool check() {
int cnt = 0;
for (int i = 1; i <= 27; i++) {
if (b[i] < 0) return false;
if (b[i] >= 3) {
b[i] -= 3;
cnt++;
}
if (i % 9 == 0 || i % 9 == 8) continue;
while (b[i] > 0) {
b[i]--, b[i + 1]--, b[i + 2]--;
cnt++;
}
}
return cnt == 4;
}
bool check_hu() {
bool flag = false;
for (int i = 1; i <= 27; i++) {
if (a[i] >= 2) flag = true;
}
if (!flag) return false;
for (int i = 1; i <= 27; i++) {
if (a[i] < 2) continue;
std::copy_n(a, N << 2, b);
b[i] -= 2;
if (check()) return true;
}
return false;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> t;
while (t--) {
std::fill_n(a, N << 2, 0);
for (int i = 1; i <= n; i++) {
std::string s;
cin >> s;
int x = s[0] - '0';
char c = s[1];
if (c == 'p') x += 9;
else if (c == 's') x += 18;
a[x]++;
}
if (n == 14) {
cout << check_hu() << endl;
} else { // n == 13
for (int i = 1; i <= 27; i++) {
if (a[i] < 4) {
a[i]++;
if (check_hu()) {
cout << (i - 1) % 9 + 1;
if (1 <= i && i <= 9) {
cout << "m ";
} else if (10 <= i && i <= 18) {
cout << "p ";
} else { // 19 <= i && i <= 27
cout << "s ";
}
}
a[i]--;
}
}
cout << endl;
}
}
return 0;
}

BIN
S2OJ/1496/data/data1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data21.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data22.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data23.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data24.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data25.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/data9.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1496/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.