Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

this my code plz guys help, WHY WA??

Posted by hasan83 at 2007-04-14 00:14:57 on Problem 1918
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>

using namespace std;

void sort(vector<int> by);
void sortt(vector<int> by);

vector<string> team;
vector<int> line;
vector<int> timee,sol;

int main()
{
    int n,m,k,t,submit_time,problem,size;
    string s,result;
    cin>>t;
    for(int ll=0;ll<t;ll++)
    {
       cin>>n;   
       size=0;  
       team.clear();
       for(int i=0;i<n;i++)
       {
          cin>>s;
         // for(int j=0;j<s.size();j++)if(s[j]>='A'&&s[j]<='Z')s[j]=s[j]-'A'+'a';
          team.push_back(s);
          if(s.size()>size)size=s.size();     
       }
       cin>>k>>m;
       vector<int> l(k,0),f(n,0);
       line=l;
       timee=f,sol=f;
       vector< vector<int> > score(n,line);
       for(int i=0;i<m;i++)
       {
          cin>>problem>>submit_time>>result>>s;
          problem--;
          for(int j=0;j<team.size();j++)
          {
              if(s==team[j])
              {          
                 if(result=="Yes"&&score[j][problem]!=-1)
                 {
                     timee[j]+=submit_time+(score[j][problem]*20); 
                     score[j][problem]=-1;
                     sol[j]++; 
                 }
                 else
                 {
                     score[j][problem]++;
                 } 
                 break;          
              }    
          }     
       }
       
       sortt(timee); 
       sort(sol);
       
       vector<int> rank(team.size(),0);
       for(int i=0;i<rank.size();i++)rank[i]=i+1;
       for(int i=0;i<team.size();i++)
       {    
           string space(8+1-team[i].size(),' '); 
           if(i!=0&&(sol[i]==sol[i-1]&&timee[i]==timee[i-1]))rank[i]=rank[i-1];
           if(rank[i]<10)cout<<" ";
           cout<<rank[i]<<". "<<team[i]<<space<<sol[i]<<" "<<setw(4)<<timee[i]<<endl;    
       }
       cout<<endl;
    }
    
    return 0;
}

void sort(vector<int> by)
{
     for(int i=0;i<team.size()-1;i++)
     {
        for(int j=0;j<team.size()-1;j++)
        {
            if(by[j]<by[j+1])
            {
                string temp;
                temp=team[j];
                team[j]=team[j+1];
                team[j+1]=temp;
                int tmp;
                tmp=sol[j];
                sol[j]=sol[j+1];
                sol[j+1]=tmp;
                tmp=timee[j];
                timee[j]=timee[j+1];
                timee[j+1]=tmp;
                tmp=by[j];
                by[j]=by[j+1];
                by[j+1]=tmp;
            }    
        }     
     }
}

void sortt(vector<int> by)
{
     for(int i=0;i<team.size()-1;i++)
     {
        for(int j=0;j<team.size()-1;j++)
        {
            if(by[j]>by[j+1])
            {
                string temp;
                temp=team[j];
                team[j]=team[j+1];
                team[j+1]=temp;
                int tmp;
                tmp=sol[j];
                sol[j]=sol[j+1];
                sol[j+1]=tmp;
                tmp=timee[j];
                timee[j]=timee[j+1];
                timee[j+1]=tmp;
                tmp=by[j];
                by[j]=by[j+1];
                by[j+1]=tmp;
            }    
        }     
     }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator