2 solutions
-
0
#include <bits/stdc++.h> using namespace std; const int N = 15; vector<int> cards[N]; int ver[N]; map<char, int> s; void get() { // 对于当前的所有牌做映射 for(int i = 2; i <= 9; i ++ ) { int c = '0' + i; s[c] = i; } s['A'] = 1, s['J'] = 11, s['Q'] = 12, s['K'] = 13, s['0'] = 10; } int main() { get(); for(int i = 1; i <= 13; i ++ ) for(int j = 0; j < 4; j ++ ) { char c[2]; cin >> c; cards[i].push_back(s[c[0]]); } //模拟题目的操作置换牌 for(int i = 0; i < 4; i ++ ) { int t = cards[13][i]; while(t != 13) { int r = cards[t].back(); cards[t].pop_back(); ver[t] ++ ; t = r; } } int ans = 0; //如果当前牌是被开出四次,就累加进入答案 for(int i = 1; i <= 13; i ++ ) ans += (ver[i] >= 4); cout << ans << endl; return 0; }
-
0
#include<bits/stdc++.h> using namespace std; int cnt[15]; int a[15][4], now[15]; int cc[15][4]; bool work(int x){ if(x == 13) return 0; int dx = a[x][--now[x]]; cnt[dx] ++; return work(dx); return 1; } int main(){ int c; for(int i=1;i<=13;i++) now[i] = 4; for(int i=1;i<=13;i++){ for(int j=0;j<3;j++) scanf("%c ",&cc[i][j]); scanf("%c\n",&cc[i][3]); } for(int i=1,x;i<=13;i++) for(int j=0;j<4;j++){ char c = cc[i][j]; if(c == 'A') x = 1; if(c == 'J') x = 11; if(c == 'Q') x = 12; if(c == 'K') x = 13; if(c == '0') x = 10; if(c <= '9' && c >= '2') x = c - '0'; a[i][j] = x; } int life = 0; while(life < 4){ int x = a[13][life++]; cnt[x] ++; if(!work(x)) ; } int sum = 0; for(int i=1;i<=12;i++) if(cnt[i] == 4) sum ++; printf("%d\n",sum); return 0; }
- 1
Information
- ID
- 527
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 9
- Tags
- (None)
- # Submissions
- 13
- Accepted
- 2
- Uploaded By