Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

WA in TIDRICE

$
0
0
        #include<iostream>
    #include<vector>
    #include<algorithm>

    using namespace std;

    class user {
    public:
    string id;
    char vote;
    };

    class test{
    public:
    int n,net;
    user u[100];


    };

    bool comp(user a, user b)
    {
    return (a.id>b.id);  // Or
    //return lexicographical_compare( a.id.begin(), a.id.end() , b.id.begin(), b.id.end());
    }


    int main(){
    int t;
    long long int c;
    cin>>t;
    test s[t];
    for(int i=0;i<t;i++)
    {
    cin>>s[i].n;
    for(int j=0;j<s[i].n;j++)
    cin>>s[i].u[j].id>>s[i].u[j].vote;

    }

    for(int i=0;i<t;i++)
    {

    sort(s[i].u , s[i].u+s[i].n , comp);


    if(s[i].u[0].vote=='+')
    c=1;
    else
    c=-1;




    for(int j=1;j<s[i].n;j++)
    {

    if(s[i].u[j-1].id == s[i].u[j].id)
    {
    if(s[i].u[j-1].vote=='-')
    c++;
    else
    c--;

    if(s[i].u[j].vote=='+')
    c++;
    else
    c--;

    }
    else
    {
    if(s[i].u[j].vote=='+')
    c++;
    else
    c--;

    }

    }

    cout<<c<<endl;

      }
    return 0;
    }

I am getting WA when i submit the code, This codes gives correct output for the provided sample test cases.. Please point out some case in which i'll get WA..

Thanks


Viewing all articles
Browse latest Browse all 40121

Trending Articles