ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1680. The First Nonqualifying

Wa2 please help,i cant find my mistake.My prog passes my all tests but stiill wa,The code is here.
Posted by Hrayr[Goris N4 High School] 11 Jul 2011 18:52
#include <iostream>
#include <cstring>
#include <string>
#include <fstream>
using namespace std;

struct team
{
    char full[100];
    char name[100];
};
team a[1005];
int q,n;

bool the_same(int t1,int t2)
{
    int i;
    int l1,l2;
    l1=strlen(a[t1].name);
    l2=strlen(a[t2].name);
    if (l1!=l2) return 0;
    for(i=0;i<l1-1;i++)
    {
        if (a[t1].name[i]!=a[t2].name[i]) return 0;
    }
    return 1;
}

void work(int t)
{
    int j,l;
    l=strlen(a[t].full);
    if (a[t].full[l-2]=='#')
    {
        for(j=0;j<l;j++)
        {
            a[t].name[j]=a[t].full[j];
        }
    }
    else
    {
        for(j=0;j<l;j++)
        {
            a[t].name[j]=a[t].full[j];
        }
        a[t].name[l]=' ';
        a[t].name[l+1]='#';
        a[t].name[l+2]='1';
    }
    _strlwr(a[t].name);
}


void input()
{
    //ifstream cin("input.txt");
    int i,j=0,pos=5;
    char data[50];
    char cn[10],cq[10];
    cin.getline(data,50);
    while(data[pos]!=' ')
    {
        cn[j]=data[pos];
        j++;
        pos++;
    }
    pos++;
    j=0;
    for(i=pos;i<strlen(data);i++)
    {
        cq[j]=data[i];
        j++;
    }
    q=atoi(cq);
    n=atoi(cn);
    for(i=0;i<n;i++)
    {
        cin.getline(a[i].full,100);
        work(i);
    }
}

int main()
{

    int i,j=0;
    input();
    int k=0;
    for(i=0;i<q+k;i++)
    {
        for(j=0;j<i;j++)
        {
            if (the_same(i,j))
            {
                k++;
                break;
            }
        }
    }
    cout<<a[q+k].full;
    return 0;
}