Created
December 29, 2020 02:29
-
-
Save colorbox/0a5afb1d607a3614e5cf75426b683162 to your computer and use it in GitHub Desktop.
doukaku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
#define rep(i,n) for(int i = 0; i < (n); i++) | |
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--) | |
#define rep1(i,n) for(int i = 1; i <= (n); i++) | |
#define rrep1(i,n) for(int i = (n); i > 0; i--) | |
#define ll long long | |
#define pi pair<int, int> | |
#define pll pair<ll, ll> | |
#define MOD 1000000007 | |
#define INF 1000000000000000LL | |
using namespace std; | |
int cor[8][3] = { | |
{1,2,3}, | |
{4,5,6}, | |
{7,8,9}, | |
{1,4,7}, | |
{2,5,8}, | |
{3,6,9}, | |
{1,5,9}, | |
{3,5,7}, | |
}; | |
bool ok(int a, int b, int c){ | |
rep(i, 8){ | |
if(cor[i][0]==a && cor[i][1]==b && cor[i][2]==c)return true; | |
if(cor[i][0]==a && cor[i][2]==b && cor[i][1]==c)return true; | |
if(cor[i][1]==a && cor[i][0]==b && cor[i][2]==c)return true; | |
if(cor[i][1]==a && cor[i][2]==b && cor[i][0]==c)return true; | |
if(cor[i][2]==a && cor[i][0]==b && cor[i][1]==c)return true; | |
if(cor[i][2]==a && cor[i][1]==b && cor[i][0]==c)return true; | |
} | |
return false; | |
} | |
int main(){ | |
int n;cin>>n; | |
rep(i, n){ | |
string s,t;cin>>s>>t; | |
vector<pi>input; | |
rep(i, s.size()/2){ | |
pi t; | |
if(s[i*2]=='J')t.first = 9; | |
else t.first = s[i*2]-'A'+1; | |
t.second = s[i*2+1]-'0'; | |
// cout<<t.first<<t.second<<endl; | |
input.push_back(t); | |
} | |
set<vector<pi>>r; | |
int c=s.size()/2; | |
rep(i, c)rep(j, c)rep(k, c){ | |
if( ok(input[i].first,input[j].first,input[k].first)&&ok(input[i].second,input[j].second,input[k].second) ){ | |
vector<pi>t; | |
t.push_back(input[i]); | |
t.push_back(input[j]); | |
t.push_back(input[k]); | |
sort(t.begin(), t.end()); | |
r.insert(t); | |
} | |
} | |
if(r.empty()){ cout<<"NONE"<<endl; continue;} | |
for(auto t:r){ | |
for(auto tt:t){ | |
if(tt.first==9)cout<<'J'<<tt.second; | |
else cout<<(char)('A'-1+tt.first)<<tt.second; | |
} | |
cout<<";"; | |
} | |
cout<<endl; | |
cout<<"---"<<endl; | |
} | |
return 0; | |
} | |
// https://gist.github.com/mattsan/aeb3dec4f0c33488efc6e88b5586514d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment