I wrote program on C++ and got WA1. I rewrote program on Pascal and got AC. I think my error in input string. How do i read lines? My attempts: 1) int c; n=0; while ((c = getchar()) != EOF) { if(c=='\n') break; s[++n]=c; } m=0; while ((c = getchar()) != EOF) t[++m]=(char)c; 2) void Input() { int c; scanf("%c",&c); n=0; while (c!='\n') { s[++n]=c; scanf("%c",&c); } m=0; while ((c = getchar()) != EOF) t[++m]=(char)c; }
Probably <string> will help, but i prefer work with index>=1.
Conflict graph may help. Positions of possible substrings are vertices and two positions conflict if they can not be simultaneously. Answer= max number of independent vertices. Also let relation a<b means that position is before of position b and they don't conflict.Then a<b,b<c=> a<c so we have an order. Answer is a height of ordered structure.