#include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <cstring> #include <cmath> using namespace std; #define ll long long int main() { char str[1010][110]; int ans[1010], a, x, n, m, j, temp; while (~scanf("%d%d", &n, &m)) { temp = 0;//控制空格输出 memset(ans, 0, sizeof(ans));//设每个人都是复读机 scanf("%d%s", &a, str[0]); for (int i = 1; i < m; i++) { scanf("%d%s", &x, str[i]);//第x个人的复读情况 if (strcmp(str[i], str[i - 1])) ans[x] = 1;//若不是复读机,则单独标记 } ans[a] = 1;//特别的,第一个肯定不是复读机 for (int i = 1; i <= n; i++) if (!ans[i])//如果是复读机 { if (temp)//控制空格 printf(" "); temp = 1; printf("%d", i); } printf("\n"); } return 0; }
3 5 1 gugugu 2 gugugu 1 gugu 3 tingzhifudu 2 tingzhifudu
2
原文:https://www.cnblogs.com/RootVount/p/10350999.html