제출 #1309479

#제출 시각아이디문제언어결과실행 시간메모리
1309479thuhienneRailway Trip 2 (JOI22_ho_t4)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define thuhien ""
#define re exit(0);

int n,k,m;
pair <int,int> line[maxm];
int q;

//create reach
pair <int,int> st[maxn * 4];

//segment tree
struct SegmentTree {
	pair <int,int> st[maxn * 4];
	
	void build(int id,int l,int r,pair <int,int> arr[]) {
		if (l == r) {
			st[id] = arr[l];
			return;
		}
		int mid = (l + r) >> 1;
		build(id*2,l,mid,arr);
		build(id*2+1,mid+1,r,arr);
		st[id] = merge(st[id*2],st[id*2+1]);
	}
	pair <int,int> get(int id,int l,int r,int u,int v) {
		if (l >= u && r <= v) return st[id];
		
		int mid = (l + r) >> 1;
		
		if (v <= mid) return get(id*2,l,mid,u,v);
		else if (u > mid) return get(id*2+1,mid+1,r,u,v);
		
		return merge(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
	}
	
};

SegmentTree jump[LOG + 1];
pair <int,int> TEMP;

int main() {
//  ios_base::sync_with_stdio(0);
//  cin.tie(nullptr);
	if (fopen(thuhien".inp","r")) {
	   freopen(thuhien".inp","r",stdin);
	   freopen(thuhien".out","w",stdout);
	}
	
	cin >> n >> k >> m;
	
	for (int i = 1;i <= n;i++) st[i] = {1e9,-1e9};
	
	for (int i = 1;i <= m;i++) {
		cin >> line[i].first >> line[i].second;
		
		if (line[i].first < line[i].second) {
			addmax(line[i].first,min(line[i].first + k - 1,line[i].second - 1),line[i].second);
		} else {
			addmin(max(line[i].first - k + 1,line[i].second + 1),line[i].first,line[i].second);
		}
		
	}
	
	for (int i = 1;i)

}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:10:21: error: 'maxm' was not declared in this scope
   10 | pair <int,int> line[maxm];
      |                     ^~~~
Main.cpp:14:19: error: 'maxn' was not declared in this scope
   14 | pair <int,int> st[maxn * 4];
      |                   ^~~~
Main.cpp:18:27: error: 'maxn' was not declared in this scope
   18 |         pair <int,int> st[maxn * 4];
      |                           ^~~~
Main.cpp: In member function 'void SegmentTree::build(int, int, int, std::pair<int, int>*)':
Main.cpp:22:25: error: 'st' was not declared in this scope; did you mean 'std'?
   22 |                         st[id] = arr[l];
      |                         ^~
      |                         std
Main.cpp:28:17: error: 'st' was not declared in this scope; did you mean 'std'?
   28 |                 st[id] = merge(st[id*2],st[id*2+1]);
      |                 ^~
      |                 std
Main.cpp: In member function 'std::pair<int, int> SegmentTree::get(int, int, int, int, int)':
Main.cpp:31:46: error: 'st' was not declared in this scope; did you mean 'std'?
   31 |                 if (l >= u && r <= v) return st[id];
      |                                              ^~
      |                                              std
Main.cpp:38:29: error: no matching function for call to 'merge(std::pair<int, int>, std::pair<int, int>)'
   38 |                 return merge(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
      |                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from Main.cpp:1:
/usr/include/c++/13/bits/stl_algo.h:4946:5: note: candidate: 'template<class _IIter1, class _IIter2, class _OIter> constexpr _OIter std::merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter)'
 4946 |     merge(_InputIterator1 __first1, _InputIterator1 __last1,
      |     ^~~~~
/usr/include/c++/13/bits/stl_algo.h:4946:5: note:   template argument deduction/substitution failed:
Main.cpp:38:29: note:   candidate expects 5 arguments, 2 provided
   38 |                 return merge(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
      |                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:4997:5: note: candidate: 'template<class _IIter1, class _IIter2, class _OIter, class _Compare> constexpr _OIter std::merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare)'
 4997 |     merge(_InputIterator1 __first1, _InputIterator1 __last1,
      |     ^~~~~
/usr/include/c++/13/bits/stl_algo.h:4997:5: note:   template argument deduction/substitution failed:
Main.cpp:38:29: note:   candidate expects 6 arguments, 2 provided
   38 |                 return merge(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
      |                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:73:
/usr/include/c++/13/pstl/glue_algorithm_defs.h:412:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::merge(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _ForwardIterator, _Compare)'
  412 | merge(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
      | ^~~~~
/usr/include/c++/13/pstl/glue_algorithm_defs.h:412:1: note:   template argument deduction/substitution failed:
Main.cpp:38:29: note:   candidate expects 7 arguments, 2 provided
   38 |                 return merge(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
      |                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/pstl/glue_algorithm_defs.h:417:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::merge(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _ForwardIterator)'
  417 | merge(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
      | ^~~~~
/usr/include/c++/13/pstl/glue_algorithm_defs.h:417:1: note:   template argument deduction/substitution failed:
Main.cpp:38:29: note:   candidate expects 6 arguments, 2 provided
   38 |                 return merge(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
      |                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: At global scope:
Main.cpp:43:18: error: 'LOG' was not declared in this scope
   43 | SegmentTree jump[LOG + 1];
      |                  ^~~
Main.cpp: In function 'int main()':
Main.cpp:56:36: error: 'st' was not declared in this scope; did you mean 'std'?
   56 |         for (int i = 1;i <= n;i++) st[i] = {1e9,-1e9};
      |                                    ^~
      |                                    std
Main.cpp:59:24: error: 'line' was not declared in this scope; did you mean 'link'?
   59 |                 cin >> line[i].first >> line[i].second;
      |                        ^~~~
      |                        link
Main.cpp:62:25: error: 'addmax' was not declared in this scope
   62 |                         addmax(line[i].first,min(line[i].first + k - 1,line[i].second - 1),line[i].second);
      |                         ^~~~~~
Main.cpp:64:25: error: 'addmin' was not declared in this scope
   64 |                         addmin(max(line[i].first - k + 1,line[i].second + 1),line[i].first,line[i].second);
      |                         ^~~~~~
Main.cpp:69:25: error: expected ';' before ')' token
   69 |         for (int i = 1;i)
      |                         ^
      |                         ;
Main.cpp:71:1: error: expected primary-expression before '}' token
   71 | }
      | ^
Main.cpp:50:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |            freopen(thuhien".inp","r",stdin);
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:51:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |            freopen(thuhien".out","w",stdout);
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~