求调必关
#include <bits/stdc++.h>
using namespace std;
int np,nfp,nhp,nt;
int sgu[22][102],sna[22][102],sd[22][102];
string name[22],utt[22],acc[22],una[22];
int i,j,mt1;
int sg,td,tnf,tno,ang;
bool tpd,tpo;
string p,s;
int main()
{
cin>>np>>nfp>>nt;
nhp=np-nfp;
for(i=1;i<=np;i++){
cin>>name[i];
utt[i]=name[i]+":";
acc[i]=name[i]+" is guilty.\r";
una[i]=name[i]+" is not guilty.\r";
}
for(i=1;i<=nt;i++){
cin>>p;
scanf("%*c");
for(j=1;utt[j]!=p;j++) ;
getline(cin,s);
if(s=="I am guilty.\r"){
sgu[j][++sgu[j][0]]=j;
continue;
}
if(s=="I am not guilty.\r"){
sna[j][++sna[j][0]]=j;
continue;
}
if(s=="Today is Monday.\r"){
sd[j][++sd[j][0]]=1;
continue;
}
if(s=="Today is Tuesday.\r"){
sd[j][++sd[j][0]]=2;
continue;
}
if(s=="Today is Wednesday.\r"){
sd[j][++sd[j][0]]=3;
continue;
}
if(s=="Today is Thursday.\r"){
sd[j][++sd[j][0]]=4;
continue;
}
if(s=="Today is Friday.\r"){
sd[j][++sd[j][0]]=5;
continue;
}
if(s=="Today is Saturday.\r"){
sd[j][++sd[j][0]]=6;
continue;
}
if(s=="Today is Sunday.\r"){
sd[j][++sd[j][0]]=7;
continue;
}
for(mt1=1;mt1<=np;mt1++){
if(s==acc[mt1]){
sgu[j][++sgu[j][0]]=mt1;
goto con;
}
}
for(mt1=1;mt1<=np;mt1++){
if(s==una[mt1]){
sna[j][++sna[j][0]]=mt1;
goto con;
}
}
con:;
}
for(sg=1;sg<=np;sg++){
for(td=1;td<=7;td++){
tnf=tno=0;
for(i=1;i<=np;i++){
tpd=0;
for(j=1;j<=sgu[i][0];j++){
if(sgu[i][j]==sg){
if(tpd){
if(tpo) continue;
else goto nextt;
}
else{
tpd=tpo=1;
tno++;
}
}
else{
if(tpd){
if(tpo) goto nextt;
else continue;
}
else{
tnf++;
tpd=1; tpo=0;
}
}
}
for(j=1;j<=sna[i][0];j++){
if(sna[i][j]!=sg){
if(tpd){
if(tpo) continue;
else goto nextt;
}
else{
tpd=tpo=1;
tno++;
}
}
else{
if(tpd){
if(tpo) goto nextt;
else continue;
}
else{
tnf++;
tpd=1; tpo=0;
}
}
}
for(j=1;j<=sd[i][0];j++){
if(sd[i][j]==td){
if(tpd){
if(tpo) continue;
else goto nextt;
}
else{
tpd=tpo=1;
tno++;
}
}
else{
if(tpd){
if(tpo) goto nextt;
else continue;
}
else{
tnf++;
tpd=1; tpo=0;
}
}
}
}
if(tnf<=nfp&&tno<=nhp){
if(ang==0){
ang=sg;
td=7;
}
else { cout<<"Cannot Determin"; return 0; }
}
nextt:;
}
}
if(ang==0) cout<<"Impossible";
else cout<<name[ang];
return 0;
}