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

Общий форум

Strange Compilation Error
Послано Kalyanov Dmitri (Kazan SU#3) 1 янв 2006 00:33
This program (solution for problem 1218) gets CE:
---BEGIN QUOTE---
#include <iostream>
#include <fstream>
#include <vector>
#include <iterator>
#include <numeric>
#include <algorithm>
#include <functional>
#include <queue>

using namespace std;

#ifndef ONLINE_JUDGE
ifstream in("input.txt");
ofstream out("output.txt");
#else
#define in cin
#define out cout
#endif

struct jedi
{
    string name;
    int a1,a2,a3;
};

istream& operator >> (istream& o, jedi& j)
{
    return o >> j.name >> j.a1 >> j.a2 >> j.a3;
}

vector<jedi> sequence;
vector<string> ans;
#define MAXN 500
bool conn[MAXN][MAXN];

void readdata()
{
    int n;
    in >> n;
    sequence.assign(istream_iterator<jedi>(in),istream_iterator<jedi>());
}

void writedata()
{    copy(ans.begin(),ans.end(),ostream_iterator<string>(out,"\n"));
}

bool jedi_more(int i, int j)
{
    if (i == j) return false;
    int c = 0;
    if (sequence[i].a1 > sequence[j].a1)
        ++c;
    if (sequence[i].a2 > sequence[j].a2)
        ++c;
    if (sequence[i].a3 > sequence[j].a3)
        ++c;
    return c >= 2;
}

void make_conn()
{
    int n = sequence.size();
    for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
        conn[i][j] = jedi_more(i,j);
}

bool check(int jedi_no)
{
    bool marked[MAXN];
    fill(marked,marked+MAXN,false);
    int n = sequence.size();
    marked[jedi_no] = true;
    queue<int> q;
    q.push(jedi_no);
    while (!q.empty())
    {
        int i = q.front();
        q.pop();
        for (int j = 0; j < n; ++j)
        if (!marked[j] && conn[i][j])
        {
            marked[j] = true;
            q.push(j);
        }
    }
    return find(marked,marked+n,false) == marked+n;
}

void solve()
{
    make_conn();
    int n = sequence.size();
    for (int i = 0; i < n; ++i)
        if (check(i))
            ans.push_back(sequence[i].name);
}

int main(int argc, char *argv[])
{
    readdata();
    solve();
    writedata();
    return 0;
}
---END QUOTE---

The error message (that came to e-mail) is:

--BEGIN QUOTE---
You tried to solve problem 1218 Episode N-th: The Jedi Tournament.
Your solution was compiled with the following errors:

ef92586f-a694-42a1-a0e3-22d241682008
temp\ef92586f-a694-42a1-a0e3-22d241682008(28): error: no operator ">>" matches these operands
            operand types are: std::istream >> std::string
      return o >> j.name >> j.a1 >> j.a2 >> j.a3;
               ^

e:\judge\Judge\Vc7\include\iterator(257): error: no operator "<<" matches these operands
            operand types are: std::ostream_iterator<std::string, char, std::char_traits<char>>::ostream_type << const std::string
          *_Myostr << _Val;

                   ^
          detected during:
            instantiation of "std::ostream_iterator<_Ty, _Elem, _Traits> &std::ostream_iterator<_Ty, _Elem, _Traits>::operator=(const _Ty &) [with _Ty=std::string, _Elem=char, _Traits=std::char_traits<char>]" at line 1130 of "e:\judge\Judge\Vc7\include\xutility"
            instantiation of "_OutIt std::_Copy_opt(_InIt, _InIt, _OutIt, std::_Nonscalar_ptr_iterator_tag) [with _InIt=std::_Ptrit<std::vector<std::string, std::allocator<std::string>>::value_type, std::vector<std::string, std::allocator<std::string>>::difference_type={std::allocator<std::string>::difference_type={ptrdiff_t={int}}}, std::vector<std::string, std::allocator<std::string>>::_Tptr, std::vector<std::string, std::allocator<std::string>>::reference, std::vector<std::string,
                      std::allocator<std::string>>::_Tptr, std::vector<std::string, std::allocator<std::string>>::reference>, _OutIt=std::ostream_iterator<std::string, char, std::char_traits<char>>]" at line 1121 of "e:\judge\Judge\Vc7\include\xutility"
            instantiation of "_OutIt std::copy(_InIt, _InIt, _OutIt) [with _InIt=std::_Ptrit<std::vector<std::string, std::allocator<std::string>>::value_type, std::vector<std::string, std::allocator<std::string>>::difference_type={std::allocator<std::string>::difference_type={ptrdiff_t={int}}}, std::vector<std::string, std::allocator<std::string>>::_Tptr, std::vector<std::string, std::allocator<std::string>>::reference, std::vector<std::string, std::allocator<std::string>>::_Tptr,
                      std::vector<std::string, std::allocator<std::string>>::reference>, _OutIt=std::ostream_iterator<std::string, char, std::char_traits<char>>]" at line 45 of "temp\ef92586f-a694-42a1-a0e3-22d241682008"

compilation aborted for temp\ef92586f-a694-42a1-a0e3-22d241682008 (code 2)
---END QUOTE---

This code compiles with gcc 3.4.4 (mingw32) ok.