HDU

来源:互联网 发布:双十一每年数据 编辑:程序博客网 时间:2024/05/17 22:41
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <string>#include <cmath>#include <set>#include <map>#include <stack>#include <queue>#include <ctype.h>#include <vector>#include <algorithm>#include <sstream>#define PI acos(-1.0)#define in freopen("in.txt", "r", stdin)#define out freopen("out.txt", "w", stdout)using namespace std;const int maxn = 100000 + 7;int T, n;string c;string s[10][30];set<string> st, st2;void init() {    st.clear();    //st2.clear();    scanf("%d", &n);    cin >> c;    for(int i = 0; i < 6; ++i) {        for(int j = 0; j < 20; ++j) {            cin >> s[i][j];        }    }    //cout << n << " + " << c << endl;}void solve() {    int cnt = 0, f = 0;    for(int j = 0; j < 20; ++j) {        for(int i = 0; i < 5; ++i) {            if(s[i][j] == c) {  f = 1; break;}            else {                if(st.count(s[i][j]) == 0) {                    st.insert(s[i][j]);                    cnt++;                }            }            if(cnt >= n) break;        }        if(f || cnt >= n) break;    }    //cout << cnt << endl;    if(cnt >= n) { cout << 0 << endl; return; }    int t = n - cnt;    int cnt2 = 0;    f = 0;    for(int i = 5; i < 6; ++i) {        for(int j = 0; j < 20; ++j) {            if(s[i][j] == c) { f = 1; break;}            else {                if(st.count(s[i][j]) == 0) {                    st.insert(s[i][j]);                    cnt2++;                }            }            if(cnt2 >= t) break;        }        if(f || cnt2 >= t) break;    }    if(cnt2 >= t) cout << t << endl;    else cout << "ADVANCED!" << endl;}int main() {    scanf("%d", &T);    int kase = 1;    while(T--) {        init();        printf("Case #%d: ", kase++);        solve();    }    return 0;}