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 1728. Curse on Team.GOV

WA17
Posted by Michail Yudin 22 Oct 2009 00:46
#include <limits>
#include <fstream>
#include <algorithm>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <time.h>
#include <cmath>

#define fori(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forbi(i,a,b) for(int i = a; i<=b; i++)
#define len(v) (int((v).size()))
#define vi vector<int>
#define vvi vector<vi >
#define sz(v) (int)v.size()
#define mmin(a,b,c) min(a,min(b,c))
#define sqr(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define inf 987654321
#define mmax(a,b,c) max(a,max(b,c))
#define ii pair<int,int>
#define si pair<int,string>
#define sii vector<si >
#define vii vector<ii >
#define vvii vector<vii >
const double pi = acos(0.0)*2;
const double eps = 1e-7;
#define mp(a,b) make_pair(a,b)

using namespace std;

#ifndef ONLINE_JUDGE
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

set <string> Q;
set <string> P;

void main()
{
    int n,m,k,x,y,z;
    string X;
    cin>>n;
    fori(i,n)
    {
        cin>>k;
        if (k==3){
            cin>>X;
            Q.insert(X);
            cin>>X;
            Q.insert(X);
            cin>>X;
            Q.insert(X);
        }
        if (k==2){
            cin>>X;
            P.insert(X);
            cin>>X;
            P.insert(X);
        }
    }
    cin>>x>>y;
    cin>>m;
    sii V;
    fori(i,m)
    {
        cin>>X>>k;
        V.push_back(mp(k,X));
    }
    sort(V.rbegin(),V.rend());
si M,Z;
M=mp(0,"");
Z=mp(0,"");

    fori(i,m)
    {
        if (Q.find(V[i].second)==Q.end() && V[i].first>M.first)
        {
            M=mp(V[i].first+x+y,V[i].second);
        }

    }
    fori(i,m)
    {
        if (P.find(V[i].second)==P.end() && V[i].first>Z.first)
        {
            Z=mp(V[i].first+y,V[i].second);
        }
    }
    if (M.first==0 && Z.first==0)
    {
        cout<<"Fail";
        return;
    }
    if (M.first>Z.first)
        cout<<"Win"<<endl<<M.second;
    else
        cout<<"Win"<<endl<<Z.second;



}

Edited by author 22.10.2009 02:16