#include<iostream> #include<set> usingnamespace std; int M, N, S; string s[1010]; set<string> P; intmain(){ cin >> M >> N >> S; for (int i = 1; i <= M; i++) { cin >> s[i]; } int i = S; while (i <= M) { while (P.count(s[i]) != 0) i++; cout << s[i] << endl; P.insert(s[i]); i = i + N ; } if (P.size() == 0) cout << "Keep going...\n"; }
#include<iostream> usingnamespace std; int N, M; int G[510][510]; bool flag[510]; int vertex[510]; int cnt = 0; voidDFS(int r){ cnt++; flag[r] = true; for (int i = 1; i <= N; i++) { if (!flag[i] && G[r][i]) { DFS(i); } } } intmain(){ cin >> N >> M; int a, b; for (int i = 0; i < M; i++) { cin >> a >> b; vertex[a]++; vertex[b]++; G[a][b] = 1; G[b][a] = 1; } DFS(1); int n = 0, flag = 1; for (int i = 1; i <= N; i++) { printf("%d", vertex[i]); if (i != N) printf(" "); elseprintf("\n"); if (vertex[i] % 2 != 0) { n++; } } if (cnt == N && n == 0) cout << "Eulerian\n"; elseif (cnt == N && n == 2) cout << "Semi-Eulerian\n"; else cout << "Non-Eulerian\n"; }