首页 > 代码库 > usaco-3.4-heritage-passed
usaco-3.4-heritage-passed
水题,呵呵:
/*ID: qq104801LANG: C++TASK: heritage*/#include <iostream>#include <fstream>#include <cstring>#include <vector>#include <queue>#include <stack>#include <algorithm>using namespace std;#define nmax 27int n,len;char mid[nmax],pre[nmax],post[nmax];int xindex=0;void getlast(int head,int start,int end){ for(int i=start;i<end;i++) if(mid[i]==pre[head]) { getlast(head+1,start,i); getlast(head+1+i-start,i+1,end); post[xindex]=pre[head]; xindex++; break; }}void test(){ freopen("heritage.in","r",stdin); freopen("heritage.out","w",stdout); char str[nmax]; cin>>str; len=strlen(str); for(int i=0;i<len;i++) mid[i]=str[i]; cin>>pre; getlast(0,0,len); post[len]=‘\0‘; cout<<post<<endl; }int main () { test(); return 0;}
test data:
USACO TrainingGrader Results 19 users onlineARE/1 AUS/1 BGD/1 CHN/11 IND/2 LTU/1 TWN/1 YUG/1USER: cn tom [qq104801]TASK: heritageLANG: C++Compiling...Compile: OKExecuting... Test 1: TEST OK [0.011 secs, 3376 KB] Test 2: TEST OK [0.011 secs, 3376 KB] Test 3: TEST OK [0.005 secs, 3376 KB] Test 4: TEST OK [0.008 secs, 3376 KB] Test 5: TEST OK [0.005 secs, 3376 KB] Test 6: TEST OK [0.005 secs, 3376 KB] Test 7: TEST OK [0.005 secs, 3376 KB] Test 8: TEST OK [0.008 secs, 3376 KB] Test 9: TEST OK [0.008 secs, 3376 KB]All tests OK.YOUR PROGRAM (‘heritage‘) WORKED FIRST TIME! That‘s fantastic -- and a rare thing. Please accept these special automated congratulations.Here are the test data inputs:------- test 1 ----ABEDFCHGCBADEFGH------- test 2 ----FF------- test 3 ----BCADABCD------- test 4 ----GOLEAFSSFAELOG------- test 5 ----GSHBAQTPMABGHSPQTM------- test 6 ----AUBYCVDZEWFXGTHZYUABVCDXWEFTGH------- test 7 ----ABDCJHKILMNPOQFEGRSABCDEFHJIKLMNOPQGRS------- test 8 ----GFDIHKLJMBNESRTPOQAUCWVZYXABDFGHIJKLMENOPRSTQCUVWXYZ------- test 9 ----EHGDIFJLKMBNCOQSPRAWUXZYTVABDEGHFIJKLMCNOPQSRTUWXYZVKeep up the good work!Thanks for your submission!
usaco-3.4-heritage-passed
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。