[expelliarmus] the disarming charm [rictusempra] send a jet of silver light to hit the enemy [tarantallegra] control the movement of one's legs [serpensortia] shoot a snake out of the end of one's wand [lumos] light the wand [obliviate] the memory charm [expecto patronum] send a Patronus to the dementors [accio] the summoning charm @END@ 4 [lumos] the summoning charm [arha] take me to the skySample Output
light the wand accio what? what?本来以为可以用string和map做的题,结果到头来发现根本行不通,因为给的内存限制太小,做完就会出现
Memory Limit Exceeded |
所以改用直接用strcmp查找,稳过
#include<stdio.h> #include<iostream> #include<algorithm> #include <cstring> #include <string> #include <math.h> #include <cstdio> #include <cmath> #include<string.h> #include <stdlib.h> #include<map> #include<set> using namespace std; struct same { char a[100]; char b[100]; } q[100003]; int main() { int i=0; char c[6]="@END@"; while(scanf("%s",q[i].a)) { getchar(); if(strcmp(q[i].a,c)==0) break; gets(q[i++].b); } int n; scanf("%d",&n); getchar(); while(n--) { char str[100]; gets(str); int m=-1; if(str[0]=='[') { for(int j=0; j<i; j++) { if(strcmp(str,q[j].a)==0) { m=j; break; } } if(m!=-1) printf("%s\n",q[m].b); else printf("what?\n"); } else { for(int j=0; j<i; j++) { if(strcmp(str,q[j].b)==0) { m=j; break; } } if(m!=-1) { for(int j=1; q[m].a[j]!=']'; j++) printf("%c",q[m].a[j]); printf("\n"); } else printf("what?\n"); } } return 0; }