| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Why is this prog is wrong??#include<iostream> //#include<fstream> #define MAX 5002 using namespace std; int n,i,j,k; char pal[MAX],m[MAX][MAX]; int main() { //ifstream cin("input.txt"); //ofstream cout("output.txt"); while(cin >> n) { cin >> pal+1; for(i = 1;i <= n;i++) { for(j = n,k=1;j > 0;j--,k++) { if(pal[i] == pal[j]) m[i][k] = m[i-1][k-1]+1; else if(m[i-1][k] > m[i][k-1]) m[i][k] = m[i-1][k]; else m[i][k] = m[i][k-1]; } } cout << n-(int)m[n][n] << endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator