답안 #121097

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121097 2019-06-26T06:07:08 Z 임유진(#2971) Coin Collecting (JOI19_ho_t4) C++14
컴파일 오류
0 ms 0 KB
#include<stdio.h>
#include<queue>
#include<algorithm>

using namespace std;

#define MAXN 100005

typedef long long lint;
typedef pair<lint, lint> pll;

pll C[MAXN*2];
int s[MAXN*2], e[MAXN*2];
lint ans;
int con[MAXN*2];
int un, dn;

int main(){
	int N;

	scanf("%d", &N);
	for(int i=0; i<N*2; i++) scanf("%lld%lld", &C[i].first, &C[i].second);

	sort(C, C+2*N);
	int s=0;
	for(int i=0; i<2*N; i+){
		if(C[i].first<i/2+1){
			s[i]=max(0, C[i].first);
			e[i]=i/2;
		}
		else{
			s[i]=i/2;
			e[i]=min(N-1, C[i].first);
		}
	}
	for(int i=0; i<2*N; i++){
		if(i<2*N-1&&s[i+1]>dn) con[i]=(un++)*2;
		else if(i<2*N-1&&s[i+1]>un) con[i]=(dn++)*2+1;
		else if(C[i].second>=2) con[i]=(un++)*2;
		else con[i]=(dn++)*2+1;
	}

	for(int i=0; i<2*N; i++){
		if(con[i]%2==0) ans+=abs(C[i].first-con[i]/2-1)+abs(C[i].second-2);
		else ans+=abs(C[i].first-con[i]/2-1)+abs(C[i].second-1);
	}

	printf("%lld", ans);
	return 0;
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:26:24: error: expected primary-expression before ')' token
  for(int i=0; i<2*N; i+){
                        ^
joi2019_ho_t4.cpp:28:7: error: invalid types 'int[int]' for array subscript
    s[i]=max(0, C[i].first);
       ^
joi2019_ho_t4.cpp:28:26: error: no matching function for call to 'max(int, long long int&)'
    s[i]=max(0, C[i].first);
                          ^
In file included from /usr/include/c++/7/deque:60:0,
                 from /usr/include/c++/7/queue:60,
                 from joi2019_ho_t4.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
joi2019_ho_t4.cpp:28:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
    s[i]=max(0, C[i].first);
                          ^
In file included from /usr/include/c++/7/deque:60:0,
                 from /usr/include/c++/7/queue:60,
                 from joi2019_ho_t4.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
joi2019_ho_t4.cpp:28:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
    s[i]=max(0, C[i].first);
                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from joi2019_ho_t4.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
joi2019_ho_t4.cpp:28:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    s[i]=max(0, C[i].first);
                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from joi2019_ho_t4.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
joi2019_ho_t4.cpp:28:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    s[i]=max(0, C[i].first);
                          ^
joi2019_ho_t4.cpp:32:7: error: invalid types 'int[int]' for array subscript
    s[i]=i/2;
       ^
joi2019_ho_t4.cpp:33:28: error: no matching function for call to 'min(int, long long int&)'
    e[i]=min(N-1, C[i].first);
                            ^
In file included from /usr/include/c++/7/deque:60:0,
                 from /usr/include/c++/7/queue:60,
                 from joi2019_ho_t4.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
joi2019_ho_t4.cpp:33:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
    e[i]=min(N-1, C[i].first);
                            ^
In file included from /usr/include/c++/7/deque:60:0,
                 from /usr/include/c++/7/queue:60,
                 from joi2019_ho_t4.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
joi2019_ho_t4.cpp:33:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
    e[i]=min(N-1, C[i].first);
                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from joi2019_ho_t4.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
joi2019_ho_t4.cpp:33:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    e[i]=min(N-1, C[i].first);
                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from joi2019_ho_t4.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
joi2019_ho_t4.cpp:33:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    e[i]=min(N-1, C[i].first);
                            ^
joi2019_ho_t4.cpp:37:20: error: invalid types 'int[int]' for array subscript
   if(i<2*N-1&&s[i+1]>dn) con[i]=(un++)*2;
                    ^
joi2019_ho_t4.cpp:38:25: error: invalid types 'int[int]' for array subscript
   else if(i<2*N-1&&s[i+1]>un) con[i]=(dn++)*2+1;
                         ^
joi2019_ho_t4.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
joi2019_ho_t4.cpp:22:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<N*2; i++) scanf("%lld%lld", &C[i].first, &C[i].second);
                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~