답안 #28173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28173 2017-07-15T14:07:28 Z IE(#1205, kriii) 개미와 비트코인 (FXCUP2_ant) C++
컴파일 오류
0 ms 0 KB
#include <stdio.h>
#include <algorithm>
using namespace std;

int N; long long T,L,V,A[100100];
pair<long long, int> O[100100];

int main()
{
	scanf ("%d %lld %lld",&N,&L,&T);

	for (int i=0;i<N;i++){
		long long x; char S[5];
		scanf ("%lld %s",&x,S);
		O[i] = {x,i+1};
		if (S[0] == 'L') x = 2 * L - x;
		x = (x + T) % (2 * L);
		if (x >= L) x = 2 * L - x;
		A[i] = x;
	}

	scanf ("%d",&V);
	long long g = O[V-1].first;
	sort(O,O+N);

	long long f = A[lower_bound(O,O+N,g)->second];
	sort(A,A+N);
	printf ("%d\n",O[lower_bound(A,A+N,f)-A].second);

	return 0;
}

Compilation message

ant.cpp: In function 'int main()':
ant.cpp:15:16: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   O[i] = {x,i+1};
                ^
ant.cpp:15:8: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   O[i] = {x,i+1};
        ^
ant.cpp:22:16: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  scanf ("%d",&V);
                ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/algorithm:61,
                 from ant.cpp:2:
/usr/include/c++/5/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, int>*; _Value = const long long int]':
/usr/include/c++/5/bits/stl_algobase.h:975:14:   required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = std::pair<long long int, int>*; _Tp = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_val]'
/usr/include/c++/5/bits/stl_algobase.h:1009:32:   required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = std::pair<long long int, int>*; _Tp = long long int]'
ant.cpp:26:37:   required from here
/usr/include/c++/5/bits/predefined_ops.h:55:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, int>' and 'const long long int')
       { return *__it < __val; }
                      ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5/algorithm:61,
                 from ant.cpp:2:
/usr/include/c++/5/bits/stl_iterator.h:849:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)
     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
     ^
/usr/include/c++/5/bits/stl_iterator.h:849:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/algorithm:61,
                 from ant.cpp:2:
/usr/include/c++/5/bits/predefined_ops.h:55:22: note:   'std::pair<long long int, int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
       { return *__it < __val; }
                      ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5/algorithm:61,
                 from ant.cpp:2:
/usr/include/c++/5/bits/stl_iterator.h:856:5: note: candidate: template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
     ^
/usr/include/c++/5/bits/stl_iterator.h:856:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/algorithm:61,
                 from ant.cpp:2:
/usr/include/c++/5/bits/predefined_ops.h:55:22: note:   'std::pair<long long int, int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
       { return *__it < __val; }
                      ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5/algorithm:61,
                 from ant.cpp:2:
/usr/include/c++/5/bits/stl_iterator.h:348:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
     operator<(const reverse_iterator<_IteratorL>& __x,
     ^
/usr/include/c++/5/bits/stl_iterator.h:348:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/algorithm:61,
                 from ant.cpp:2:
/usr/include/c++/5/bits/predefined_ops.h:55:22: note:   'std::pair<long long int, int>' is not derived from 'const std::reverse_iterator<_Iterator>'
       { return *__it < __val; }
                      ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5/algorithm:61,
                 from ant.cpp:2:
/usr/include/c++/5/bits/stl_iterator.h:298:5: note: candidate: template<class _Iterator> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
     operator<(const reverse_iterator<_Iterator>& __x,
     ^
/usr/include/c++/5/bits/stl_iterator.h:298:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/algorithm:61,
                 from ant.cpp:2:
/usr/include/c++/5/bits/predefined_ops.h:55:22: note:   'std::pair<long long int, int>' is not derived from 'const std::reverse_iterator<_Iterator>'
       { return *__it < __val; }
                      ^
In file included from /usr/include/c++/5/utility:70:0,
                 from /usr/include/c++/5/algorithm:60,
                 from ant.cpp:2:
/usr/include/c++/5/bits/stl_pair.h:220:5: note: candidate: template<class _T1, class _T2> bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
     ^
/usr/include/c++/5/bits/stl_pair.h:220:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/algorithm:61,
                 from ant.cpp:2:
/usr/include/c++/5/bits/predefined_ops.h:55:22: note:   mismatched types 'const std::pair<_T1, _T2>' and 'const long long int'
       { return *__it < __val; }
                      ^
ant.cpp:10:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d %lld %lld",&N,&L,&T);
                                 ^
ant.cpp:14:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%lld %s",&x,S);
                         ^
ant.cpp:22:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d",&V);
                 ^