답안 #24346

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
24346 2017-06-05T16:17:54 Z Mamnoon_Siam 게임 (IOI13_game) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#ifndef __GAME_H__
#define __GAME_H__

#ifdef __cplusplus
extern "C" {
#endif

const long long maxn=2700;

map<long long, map<long long, long long> >tree; long long maxR, maxC;
vector<long long> edit;

long long gcd(long long X, long long Y) {
    long long tmp;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}

void make_update_merge_list(long long node, long long b, long long e, long long pos)
{
    if(b>pos || e<pos) return ; edit.push_back(node); if(b==e) return ;
    long long left=node<<1; long long right=left+1; long long mid=(b+e)>>1;
    make_update_merge_list(left, b, mid, pos); make_update_merge_list(right, mid+1, e, pos);
}

void update_col(long long row, long long node, long long b, long long e, long long pos, long long val)
{
    if(b>pos || e<pos) return ;
    if(b==e) { tree[row][node]=val; return ; }
    long long left=node<<1; long long right=left+1; long long mid=(b+e)>>1;
    update_col(row, left, b, mid, pos, val); update_col(row, right, mid+1, e, pos, val);
    if(tree[row].find(left) != tree[row].end()) tree[row][node]=tree[row][left];
    if(tree[row].find(right)!= tree[row].end()) tree[row][node]=gcd(tree[row][node], tree[row][right]);
}

void update_row(long long node, long long b, long long e, long long x, long long y, long long val)
{
    if(b>x || e<x) return ;
    if(b==e) { update_col(node, 1, 0, maxC-1, y, val); return ; }
    long long left=node<<1; long long right=left+1; long long mid=(b+e)>>1;
    update_row(left, b, mid, x, y, val); update_row(right, mid+1, e, x, y, val);
    for(int i=0; i<(int)edit.size(); i++) {
        if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
        if(tree[right].find(edit[i])!= tree.end()) tree[node][edit[i]]=gcd(tree[node][edit[i]], tree[right][edit[i]]);
    }
}

long long calculate_col(long long row, long long node, long long b, long long e, long long i, long long j)
{
    if(b>j || e<i) return (long long)0;
    if(i<=b && e<=j) return ((tree[row].find(node) != tree[row].end()) ? tree[row][node] : 0);
    long long left=node<<1; long long right=left+1; long long mid=(b+e)>>1;
    return gcd(calculate_col(row, left, b, mid, i, j), calculate_col(row, right, mid+1, e, i ,j));
}

long long calculate_row(long long node, long long b, long long e, long long i, long long j, long long l, long long r)
{
    if(b>j || e<i) return (long long)0;
    if(i<=b && e<=j) return calculate_col(node, 1, 0, maxC-1, l , r);
    long long left=node<<1; long long right=left+1; long long mid=(b+e)>>1;
    return gcd(calculate_row(left, b, mid, i, j, l, r), calculate_row(right, mid+1, e, i, j, l, r));
}

void init(long long R, long long C)
{
    maxR=R; maxC=C; //vector<long long> temp;
    //R = ((long long)ceil(log((double)R)/log(2.0)))+1; R=1<<R;
    //C = ((long long)ceil(log((double)C)/log(2.0)))+1; C=1<<C;
    //R+=20; C+=20;
    //for(int i=0; i<C; i++) temp.push_back(0LL);
    //for(int i=0; i<R; i++) tree.push_back(temp);
}
void update(long long P, long long Q, long long K)
{
    edit.clear();
    make_update_merge_list(1, 0, maxC-1, Q);
    update_row(1, 0, maxR-1, P, Q, K);
}
long long calculate(long long P, long long Q, long long U, long long V)
{
     return calculate_row(1, 0, maxR-1, P, U, Q, V);
}

#ifdef __cplusplus
}
#endif

#endif /* __GAME_H__ */

Compilation message

grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^
game.cpp: In function 'void update_row(long long int, long long int, long long int, long long int, long long int, long long int)':
game.cpp:50:37: error: no match for 'operator!=' (operand types are 'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' and 'std::map<long long int, std::map<long long int, long long int> >::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, std::map<long long int, long long int> > >}')
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                     ^
In file included from /usr/include/c++/5/map:60:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:80,
                 from game.cpp:1:
/usr/include/c++/5/bits/stl_tree.h:237:7: note: candidate: bool std::_Rb_tree_iterator<_Tp>::operator!=(const _Self&) const [with _Tp = std::pair<const long long int, long long int>; std::_Rb_tree_iterator<_Tp>::_Self = std::_Rb_tree_iterator<std::pair<const long long int, long long int> >]
       operator!=(const _Self& __x) const _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/5/bits/stl_tree.h:237:7: note:   no known conversion for argument 1 from 'std::map<long long int, std::map<long long int, long long int> >::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, std::map<long long int, long long int> > >}' to 'const _Self& {aka const std::_Rb_tree_iterator<std::pair<const long long int, long long int> >&}'
In file included from /usr/include/c++/5/regex:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:108,
                 from game.cpp:1:
/usr/include/c++/5/bits/regex.h:948:5: note: candidate: template<class _BiIter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&)
     operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
     ^
/usr/include/c++/5/bits/regex.h:948:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/regex:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:108,
                 from game.cpp:1:
/usr/include/c++/5/bits/regex.h:1026:5: note: candidate: template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::__cxx11::sub_match<_BiIter>&)
     operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
     ^
/usr/include/c++/5/bits/regex.h:1026:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/regex:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:108,
                 from game.cpp:1:
/usr/include/c++/5/bits/regex.h:1106:5: note: candidate: template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)
     operator!=(const sub_match<_Bi_iter>& __lhs,
     ^
/usr/include/c++/5/bits/regex.h:1106:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/regex:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:108,
                 from game.cpp:1:
/usr/include/c++/5/bits/regex.h:1183:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const std::__cxx11::sub_match<_BiIter>&)
     operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
     ^
/usr/include/c++/5/bits/regex.h:1183:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, std::map<long long int, long long int> >::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, std::map<long long int, long long int> > >}' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/regex:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:108,
                 from game.cpp:1:
/usr/include/c++/5/bits/regex.h:1257:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)
     operator!=(const sub_match<_Bi_iter>& __lhs,
     ^
/usr/include/c++/5/bits/regex.h:1257:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/regex:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:108,
                 from game.cpp:1:
/usr/include/c++/5/bits/regex.h:1334:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const std::__cxx11::sub_match<_BiIter>&)
     operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
     ^
/usr/include/c++/5/bits/regex.h:1334:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, std::map<long long int, long long int> >::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, std::map<long long int, long long int> > >}' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/regex:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:108,
                 from game.cpp:1:
/usr/include/c++/5/bits/regex.h:1414:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)
     operator!=(const sub_match<_Bi_iter>& __lhs,
     ^
/usr/include/c++/5/bits/regex.h:1414:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/regex:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:108,
                 from game.cpp:1:
/usr/include/c++/5/bits/regex.h:1938:5: note: candidate: template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const std::__cxx11::match_results<_BiIter, _Alloc>&, const std::__cxx11::match_results<_BiIter, _Alloc>&)
     operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
     ^
/usr/include/c++/5/bits/regex.h:1938:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/unordered_set:48:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:116,
                 from game.cpp:1:
/usr/include/c++/5/bits/unordered_set.h:1427:5: note: candidate: template<class _Value, class _Hash, class _Pred, class _Alloc> bool std::operator!=(const std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>&, const std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>&)
     operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
     ^
/usr/include/c++/5/bits/unordered_set.h:1427:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/unordered_set:48:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:116,
                 from game.cpp:1:
/usr/include/c++/5/bits/unordered_set.h:1415:5: note: candidate: template<class _Value, class _Hash, class _Pred, class _Alloc> bool std::operator!=(const std::unordered_set<_Value, _Hash, _Pred, _Alloc>&, const std::unordered_set<_Value, _Hash, _Pred, _Alloc>&)
     operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
     ^
/usr/include/c++/5/bits/unordered_set.h:1415:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::unordered_set<_Value, _Hash, _Pred, _Alloc>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/unordered_map:48:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:115,
                 from game.cpp:1:
/usr/include/c++/5/bits/unordered_map.h:1548:5: note: candidate: template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> bool std::operator!=(const std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&, const std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&)
     operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
     ^
/usr/include/c++/5/bits/unordered_map.h:1548:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/unordered_map:48:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:115,
                 from game.cpp:1:
/usr/include/c++/5/bits/unordered_map.h:1536:5: note: candidate: template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> bool std::operator!=(const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&, const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&)
     operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
     ^
/usr/include/c++/5/bits/unordered_map.h:1536:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:109:0,
                 from game.cpp:1:
/usr/include/c++/5/scoped_allocator:462:5: note: candidate: template<class _OutA1, class _OutA2, class ... _InA> bool std::operator!=(const std::scoped_allocator_adaptor<_OutA1, _InA ...>&, const std::scoped_allocator_adaptor<_InnerHead, _InnerTail ...>&)
     operator!=(const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
     ^
/usr/include/c++/5/scoped_allocator:462:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::scoped_allocator_adaptor<_OutA1, _InA ...>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/future:40:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:103,
                 from game.cpp:1:
/usr/include/c++/5/thread:215:3: note: candidate: bool std::operator!=(std::thread::id, std::thread::id)
   operator!=(thread::id __x, thread::id __y) noexcept
   ^
/usr/include/c++/5/thread:215:3: note:   no known conversion for argument 1 from 'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' to 'std::thread::id'
In file included from /usr/include/c++/5/forward_list:38:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:102,
                 from game.cpp:1:
/usr/include/c++/5/bits/forward_list.h:1371:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::forward_list<_Tp, _Alloc>&, const std::forward_list<_Tp, _Alloc>&)
     operator!=(const forward_list<_Tp, _Alloc>& __lx,
     ^
/usr/include/c++/5/bits/forward_list.h:1371:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::forward_list<_Tp, _Alloc>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/c++/5/forward_list:38:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:102,
                 from game.cpp:1:
/usr/include/c++/5/bits/forward_list.h:266:5: note: candidate: template<class _Tp> bool std::operator!=(const std::_Fwd_list_iterator<_Tp>&, const std::_Fwd_list_const_iterator<_Tp>&)
     operator!=(const _Fwd_list_iterator<_Tp>& __x,
     ^
/usr/include/c++/5/bits/forward_list.h:266:5: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::_Fwd_list_iterator<_Tp>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:94:0,
                 from game.cpp:1:
/usr/include/c++/5/valarray:1180:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__not_equal_to, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__not_equal_to, _Tp>::result_type> std::operator!=(const _Tp&, const std::valarray<_Tp>&)
 _DEFINE_BINARY_OPERATOR(!=, __not_equal_to)
 ^
/usr/include/c++/5/valarray:1180:1: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, std::map<long long int, long long int> >::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, std::map<long long int, long long int> > >}' is not derived from 'const std::valarray<_Tp>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:94:0,
                 from game.cpp:1:
/usr/include/c++/5/valarray:1180:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__not_equal_to, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__not_equal_to, _Tp>::result_type> std::operator!=(const std::valarray<_Tp>&, const _Tp&)
 _DEFINE_BINARY_OPERATOR(!=, __not_equal_to)
 ^
/usr/include/c++/5/valarray:1180:1: note:   template argument deduction/substitution failed:
game.cpp:50:49: note:   'std::map<long long int, long long int>::iterator {aka std::_Rb_tree_iterator<std::pair<const long long int, long long int> >}' is not derived from 'const std::valarray<_Tp>'
         if(tree[left].find(edit[i]) != tree.end()) tree[node][edit[i]]=tree[left][edit[i]];
                                                 ^
In file included from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:94:0,
                 from game.cpp:1:
/usr/include/c++/5/valarray:1180:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__not_equal_to, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__not_equal_to, _Tp>::result_type> std::operator!=(const std::valarray<_Tp>&, const std::valarray<_Tp>&)
 _DEFINE_BINARY_OPERATOR(!=, __not_equal_to)
 ^
/usr/include/c++/5/valarray:1180:1: note:   template argument deduction/substitution fail