Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>;
- //#define maxA 30
- using namespace std;
- int a[30][30], ke[30];
- int n, m;
- void connect(char c) {
- for (int i=1; i<27; ++i)
- a[i][c - 'A' + 1] = a[c - 'A' + 1][i] = 1;
- ke[c] = 30;
- }
- int main() {
- #ifndef ONLINE_JUDGE
- freopen("uva10507.inp", "r", stdin);
- #endif // ONLINE_JUDGE
- while (1) {
- n = m = 0;
- scanf("%d%d", &n, &m); //cout << n << " " << m << endl;
- if (n == 0) break;
- memset(a, 0, sizeof(a));
- memset(ke, 0, sizeof(ke));
- int years = 0;
- string s; getline(cin, s);
- getline(cin, s);
- int len = s.length(); //cout << s << endl;
- for (int i=0; i<len; ++i) connect(s[i]);
- /*
- for (int i=1; i<27; ++i) {
- for (int j=1; j<27; ++j) cout << a[i][j] << " ";
- cout << endl;
- }
- */
- for (int i=0; i<m; ++i) {
- string s; getline(cin, s); cout << s[0] << " " << s[1] << " ";
- a[s[0] - 'A' + 1][s[1] - 'A' + 1] = a[s[1] - 'A' + 1][s[0] - 'A' + 1] = 1;
- ++ke[s[0] - 'A' + 1]; ++ke[s[1] - 'A' + 1]; cout << ke[s[0] - 'A' + 1] << " " << ke[s[1] - 'A' + 1] << endl;
- if (ke[s[0] - 'A' + 1] >= 3 && ke[s[0] - 'A' + 1] < 30) { connect(s[0]); ++years; }
- if (ke[s[1] - 'A' + 1] >= 3 && ke[s[1] - 'A' + 1] < 30) { connect(s[1]); ++years; }
- }
- if (!years) printf("THIS BRAIN NEVER WAKES UP");
- else printf("WAKE UP IN, %d, YEARS", years);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment