ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1650. Миллиардеры

admins why CE??? help
Послано Crash_access_violation 6 авг 2010 23:33
In Microsoft VS2008. I get right answers, why CE?
thanks.
Here is my code:

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;

set <pair <string, pair <string, __int64> > > People;
set <pair <string, __int64> > City, Ans;
multiset <pair <__int64, string> > CityCost;
pair <string, pair <string, __int64> > nName, mName;
pair <string, __int64> cPair;
pair <__int64, string> ccPair;

class InInterval {
public:
    InInterval() {};
    bool operator () (const pair <string, __int64> a) {
        return (nName.second.first == a.first);
    }
};

class IsPeople {
public:
    IsPeople() {};
    bool operator () (const pair <string, pair <string, __int64> > a) {
        return (nName.first == a.first);
    }
};

class InCity {
public:
    InCity() {};
    bool operator () (const pair <__int64, string> a) {
        return (nName.second.first == a.second);
    }
};

class InAns {
public:
    InAns() {};
    bool operator () (const pair <string, __int64> a) {
        return (nName.second.first == a.first);
    }
};

int main() {
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "wt", stdout);
    int n, m, k;
    char ch;
    set <pair <string, pair <string, __int64> > >::iterator it;
    set <pair <string, __int64> >::iterator itr;
    multiset <pair <__int64, string> >::iterator msitr;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%c", &ch); scanf("%c", &ch); nName.first = "";
        while (ch != ' ') {
            nName.first += ch; scanf("%c", &ch);
        }
        scanf("%c", &ch); nName.second.first = "";
        while (ch != ' ') {
            nName.second.first += ch; scanf("%c", &ch);
        }
        scanf("%I64d", &nName.second.second);
        People.insert(nName);
        itr = find_if(City.begin(), City.end(), InInterval());
        if (itr == City.end()) {
            cPair.first = nName.second.first;
            cPair.second = nName.second.second;
            City.insert(cPair);
            ccPair.first = cPair.second;
            ccPair.second = cPair.first;
            CityCost.insert(ccPair);
        } else {
            (*itr).second += nName.second.second;
            msitr = find_if(CityCost.begin(), CityCost.end(), InCity());
            CityCost.erase(msitr);
            ccPair.first = (*itr).second;
            ccPair.second = (*itr).first;
            CityCost.insert(ccPair);
        }
    }

    int pred = 1, pos, npos;
    __int64 cost;
    scanf("%d%d", &m, &k);
    for (int i = 0; i <= k; i++) {
        if (i != k) {
            if (i == 0)
                scanf("%d", &pos);
            scanf("%c%c", &ch, &ch);
            nName.first = "";
            while (ch != ' ') {
                nName.first += ch;
                scanf("%c", &ch);
            }
            nName.second.first = "";
            scanf("%c", &ch);
            while (ch != '\n') {
                nName.second.first += ch;
                scanf("%c", &ch);
            }
        } else {
            pos = m;
            nName = mName;
        }
        if (i != k)
            scanf("%d", &npos);
        msitr = CityCost.end();
        msitr--;
        cost = (*msitr).first;
        if (CityCost.size() == 1) {
            mName = nName;
            nName.second.first = (*msitr).second;
            cPair.second = pos - pred;
            cPair.first = (*msitr).second;
            itr = find_if(Ans.begin(), Ans.end(), InAns());
            if (itr == Ans.end()) {
                Ans.insert(cPair);
            } else {
                (*itr).second += cPair.second;
            }
            nName = mName;
            nName.second.first = (*it).second.first;
            itr = find_if(City.begin(), City.end(), InInterval());
            (*itr).second -= (*it).second.second;
            msitr = find_if(CityCost.begin(), CityCost.end(), InCity());
            CityCost.erase(msitr);
            ccPair.first = (*itr).second;
            ccPair.second = (*itr).first;
            CityCost.insert(ccPair);
            nName = mName;
            (*it).second.first = nName.second.first;
            nName.second.second = (*it).second.second;
            itr = find_if(City.begin(), City.end(), InInterval());
            if (itr == City.end()) {
                cPair.first = nName.second.first;
                cPair.second = nName.second.second;
                City.insert(cPair);
                ccPair.first = cPair.second;
                ccPair.second = cPair.first;
                CityCost.insert(ccPair);
            } else {
                (*itr).second += nName.second.second;
                msitr = find_if(CityCost.begin(), CityCost.end(), InCity());
                CityCost.erase(msitr);
                ccPair.first = (*itr).second;
                ccPair.second = (*itr).first;
                CityCost.insert(ccPair);
            }
        } else {
            msitr--;
            if ((*msitr).first == cost)
                pred = pos;
            msitr++;
            mName = nName;
            nName.second.first = (*msitr).second;
            cPair.second = pos - pred;
            cPair.first = (*msitr).second;
            itr = find_if(Ans.begin(), Ans.end(), InAns());
            if (itr == Ans.end()) {
                Ans.insert(cPair);
            } else {
                (*itr).second += cPair.second;
            }
            nName = mName;
            it = find_if(People.begin(), People.end(), IsPeople());
            mName = nName;
            nName.second.first = (*it).second.first;
            itr = find_if(City.begin(), City.end(), InInterval());
            (*itr).second -= (*it).second.second;
            msitr = find_if(CityCost.begin(), CityCost.end(), InCity());
            CityCost.erase(msitr);
            ccPair.first = (*itr).second;
            ccPair.second = (*itr).first;
            CityCost.insert(ccPair);
            nName = mName;
            (*it).second.first = nName.second.first;
            nName.second.second = (*it).second.second;
            itr = find_if(City.begin(), City.end(), InInterval());
            if (itr == City.end()) {
                cPair.first = nName.second.first;
                cPair.second = nName.second.second;
                City.insert(cPair);
                ccPair.first = cPair.second;
                ccPair.second = cPair.first;
                CityCost.insert(ccPair);
            } else {
                (*itr).second += nName.second.second;
                msitr = find_if(CityCost.begin(), CityCost.end(), InCity());
                CityCost.erase(msitr);
                ccPair.first = (*itr).second;
                ccPair.second = (*itr).first;
                CityCost.insert(ccPair);
            }
        }
        if (npos != pos)
            pred = pos;
        pos = npos;
    }

    for (itr = Ans.begin(); itr != Ans.end(); itr++) {
        if ((*itr).second) {
            for (int i = 0; i != (*itr).first.length(); i++) {
                printf("%c", (*itr).first[i]);
            }
            printf(" %I64d\n", (*itr).second);
        }
    }
    return 0;
}
Re: admins why CE??? help
Послано r1d1 6 авг 2010 23:57
Look the compilation report, http://acm.timus.ru/ce.aspx?id=3123270. Or poste the report here.
Re: admins why CE??? help
Послано Andrew Hoffmann aka SKYDOS [Vladimir SU] 7 авг 2010 00:20
hey)
If you want you can download 2010 visual studio professional   ( http://thepiratebay.org/torrent/5494125/Microsoft.Visual.Studio.2010.Professional.x86-KOPiE )

without any crack or keygens.
I have this copy and its perfect, but I am writing on C#.
Re: admins why CE??? help
Послано Crash_access_violation 7 авг 2010 02:29
thanks, but it's very strange. I think that changes in MVS2010  isn't global.

Edited by author 07.08.2010 02:36