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

WA test3
Posted by Berlin 1 Aug 2011 20:36
#include <iostream>
#include <vector>
#include <string>
using namespace std;
string read(string &s);
vector<string> vec;
bool isin(string s);
int main()
{
    int year,n,kol;
    cin>>year>>n>>kol;
    string s,th,st;
    th=read(st);
    for (int i=0;i<n;i++)
    {
        th=read(st);

             if ((!isin(st) || vec.size()==0))
        {
            vec.push_back(st);
        }
        if (vec.size()==kol+1) s=th;

    }
    cout<<s<<endl;
}
string read(string &s)
{
    string a,b;
    char c=cin.get();
    bool ok=true;
    while (c!='\n' && !cin.eof())
    {
        a.push_back(c);
        if (c=='#') ok=false;
        if (ok)
        {
            b.push_back(c);
        }

        c=cin.get();
    }
    s.clear();
    s=b;
    return a;
}
bool isin(string s)
{
    for (int i=0;i<vec.size();i++)
    {
        if (s==vec.at(i)) return true;
    }
    return false;
}