답안 #823429

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823429 2023-08-12T14:03:02 Z I_Love_EliskaM_ Sky Walking (IOI19_walk) C++17
컴파일 오류
0 ms 0 KB
#include "walk.h"
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0; i<n; ++i)
#define pb push_back
using ll = int64_t
const ll inf = 4e18;
#define pi pair<ll,ll>
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()

#define int ll
const int sz=1<<30;
struct sgt {
	sgt *L, *R; int s;
	sgt() {
		L=R=NULL; s=inf;
	}
	void set(int l, int r, int i, int x) {
		if (r-l==1) {
			s=x; return;
		}
		int m=(l+r)>>1;
		if (i<m) {
			if (!L) L=new sgt();
			L->set(l,m,i,x);
		} else {
			if (!R) R=new sgt();
			R->set(m,r,i,x);
		}
		s = min(L?L->s:inf, R?R->s:inf);
	}
	void set(int i, int x) {
		set(0,sz,i,x);
	}
	int query(int l, int r, int lx, int rx) {
		if (rx<=l || r<=lx) return inf;
		if (lx<=l && r<=rx) return s;
		int m=(l+r)>>1;
		int lq=L?L->query(l,m,lx,rx):inf;
		int rq=R?R->query(m,r,lx,rx):inf;
		return min(lq,rq);
	}
	int query(int l, int r) {
		return query(0,sz,l,r);
	}
};
#undef int

long long min_distance(vector<int>x, vector<int>h, vector<int>l, vector<int>r, vector<int>y, int s, int g) {
	int n=x.size(), m=l.size();
	
	#define int ll

	sgt bottom, top;
	bottom.set(0,0);
	top.set(0,0);
	vector<vector<int>> add(n), del(n);
	del[0].pb(0);
	add[n-1].pb(0);
	forn(i,m) {
		add[l[i]].pb(y[i]);
		del[r[i]].pb(y[i]);
	}
	forn(i,n) {
		vector<pi> toset;
		for(auto&y:add[i]) {
			int f = bottom.query(0,y+1);
			int s = top.query(y,h[i]);
			if (min(f,s)==inf) continue;
			f+=y; s-=y;
			int x=min(f,s);
			toset.pb({y,x});
		}
		for(auto&y:del[i]) {
			bottom.set(y,inf);
			top.set(y,inf);
		}
		for(auto&x:toset) {
			bottom.set(x.f,x.s-x.f);
			top.set(x.f,x.s+x.f);
		}
	}
	if (top.s==inf) return -1;
	int f = top.s+x[n-1]-x[0];
	return f;

	#undef int
}

Compilation message

walk.cpp:7:6: error: expected ';' before 'll'
    7 | const ll inf = 4e18;
      |      ^~~
      |      ;
walk.cpp:14:13: error: 'll' does not name a type; did you mean 'all'?
   14 | #define int ll
      |             ^~
walk.cpp:15:7: note: in expansion of macro 'int'
   15 | const int sz=1<<30;
      |       ^~~
walk.cpp:14:13: error: 'll' does not name a type; did you mean 'all'?
   14 | #define int ll
      |             ^~
walk.cpp:17:14: note: in expansion of macro 'int'
   17 |  sgt *L, *R; int s;
      |              ^~~
walk.cpp:14:13: error: 'll' has not been declared
   14 | #define int ll
      |             ^~
walk.cpp:21:11: note: in expansion of macro 'int'
   21 |  void set(int l, int r, int i, int x) {
      |           ^~~
walk.cpp:14:13: error: 'll' has not been declared
   14 | #define int ll
      |             ^~
walk.cpp:21:18: note: in expansion of macro 'int'
   21 |  void set(int l, int r, int i, int x) {
      |                  ^~~
walk.cpp:14:13: error: 'll' has not been declared
   14 | #define int ll
      |             ^~
walk.cpp:21:25: note: in expansion of macro 'int'
   21 |  void set(int l, int r, int i, int x) {
      |                         ^~~
walk.cpp:14:13: error: 'll' has not been declared
   14 | #define int ll
      |             ^~
walk.cpp:21:32: note: in expansion of macro 'int'
   21 |  void set(int l, int r, int i, int x) {
      |                                ^~~
walk.cpp:14:13: error: 'll' has not been declared
   14 | #define int ll
      |             ^~
walk.cpp:35:11: note: in expansion of macro 'int'
   35 |  void set(int i, int x) {
      |           ^~~
walk.cpp:14:13: error: 'll' has not been declared
   14 | #define int ll
      |             ^~
walk.cpp:35:18: note: in expansion of macro 'int'
   35 |  void set(int i, int x) {
      |                  ^~~
walk.cpp:14:13: error: 'll' does not name a type; did you mean 'all'?
   14 | #define int ll
      |             ^~
walk.cpp:38:2: note: in expansion of macro 'int'
   38 |  int query(int l, int r, int lx, int rx) {
      |  ^~~
walk.cpp:14:13: error: 'll' does not name a type; did you mean 'all'?
   14 | #define int ll
      |             ^~
walk.cpp:46:2: note: in expansion of macro 'int'
   46 |  int query(int l, int r) {
      |  ^~~
walk.cpp: In constructor 'sgt::sgt()':
walk.cpp:10:11: error: 'second' was not declared in this scope
   10 | #define s second
      |           ^~~~~~
walk.cpp:19:13: note: in expansion of macro 's'
   19 |   L=R=NULL; s=inf;
      |             ^
walk.cpp:19:15: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   19 |   L=R=NULL; s=inf;
      |               ^~~
      |               ynf
walk.cpp: In member function 'void sgt::set(int, int, int, int)':
walk.cpp:10:11: error: 'second' was not declared in this scope
   10 | #define s second
      |           ^~~~~~
walk.cpp:23:4: note: in expansion of macro 's'
   23 |    s=x; return;
      |    ^
walk.cpp:14:13: error: 'll' was not declared in this scope; did you mean 'l'?
   14 | #define int ll
      |             ^~
walk.cpp:25:3: note: in expansion of macro 'int'
   25 |   int m=(l+r)>>1;
      |   ^~~
walk.cpp:26:9: error: 'm' was not declared in this scope; did you mean 'tm'?
   26 |   if (i<m) {
      |         ^
      |         tm
walk.cpp:10:11: error: 'second' was not declared in this scope
   10 | #define s second
      |           ^~~~~~
walk.cpp:33:3: note: in expansion of macro 's'
   33 |   s = min(L?L->s:inf, R?R->s:inf);
      |   ^
walk.cpp:10:11: error: 'struct sgt' has no member named 'second'
   10 | #define s second
      |           ^~~~~~
walk.cpp:33:16: note: in expansion of macro 's'
   33 |   s = min(L?L->s:inf, R?R->s:inf);
      |                ^
walk.cpp:33:18: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   33 |   s = min(L?L->s:inf, R?R->s:inf);
      |                  ^~~
      |                  ynf
walk.cpp:10:11: error: 'struct sgt' has no member named 'second'
   10 | #define s second
      |           ^~~~~~
walk.cpp:33:28: note: in expansion of macro 's'
   33 |   s = min(L?L->s:inf, R?R->s:inf);
      |                            ^
walk.cpp: In member function 'void sgt::set(int, int)':
walk.cpp:36:9: error: 'sz' was not declared in this scope; did you mean 's'?
   36 |   set(0,sz,i,x);
      |         ^~
      |         s
walk.cpp: In function 'long long int min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:55:14: error: 'll' was not declared in this scope; did you mean 'l'?
   55 |  #define int ll
      |              ^~
walk.cpp:60:16: note: in expansion of macro 'int'
   60 |  vector<vector<int>> add(n), del(n);
      |                ^~~
walk.cpp:55:14: error: template argument 1 is invalid
   55 |  #define int ll
      |              ^~
walk.cpp:60:16: note: in expansion of macro 'int'
   60 |  vector<vector<int>> add(n), del(n);
      |                ^~~
walk.cpp:55:14: error: template argument 2 is invalid
   55 |  #define int ll
      |              ^~
walk.cpp:60:16: note: in expansion of macro 'int'
   60 |  vector<vector<int>> add(n), del(n);
      |                ^~~
walk.cpp:60:19: error: template argument 1 is invalid
   60 |  vector<vector<int>> add(n), del(n);
      |                   ^~
walk.cpp:60:19: error: template argument 2 is invalid
walk.cpp:61:5: error: invalid types 'int[int]' for array subscript
   61 |  del[0].pb(0);
      |     ^
walk.cpp:62:5: error: invalid types 'int[int]' for array subscript
   62 |  add[n-1].pb(0);
      |     ^
walk.cpp:63:7: error: expected ';' before 'i'
   63 |  forn(i,m) {
      |       ^
walk.cpp:4:27: note: in definition of macro 'forn'
    4 | #define forn(i,n) for(int i=0; i<n; ++i)
      |                           ^
walk.cpp:63:7: error: 'i' was not declared in this scope
   63 |  forn(i,m) {
      |       ^
walk.cpp:4:32: note: in definition of macro 'forn'
    4 | #define forn(i,n) for(int i=0; i<n; ++i)
      |                                ^
walk.cpp:67:7: error: expected ';' before 'i'
   67 |  forn(i,n) {
      |       ^
walk.cpp:4:27: note: in definition of macro 'forn'
    4 | #define forn(i,n) for(int i=0; i<n; ++i)
      |                           ^
walk.cpp:67:7: error: 'i' was not declared in this scope
   67 |  forn(i,n) {
      |       ^
walk.cpp:4:32: note: in definition of macro 'forn'
    4 | #define forn(i,n) for(int i=0; i<n; ++i)
      |                                ^
walk.cpp:68:12: error: template argument 1 is invalid
   68 |   vector<pi> toset;
      |            ^
walk.cpp:68:12: error: template argument 2 is invalid
walk.cpp:9:11: error: expected ';' before 'first'
    9 | #define f first
      |           ^~~~~
walk.cpp:70:8: note: in expansion of macro 'f'
   70 |    int f = bottom.query(0,y+1);
      |        ^
walk.cpp:10:11: error: expected ';' before 'second'
   10 | #define s second
      |           ^~~~~~
walk.cpp:71:8: note: in expansion of macro 's'
   71 |    int s = top.query(y,h[i]);
      |        ^
walk.cpp:9:11: error: 'first' was not declared in this scope
    9 | #define f first
      |           ^~~~~
walk.cpp:72:12: note: in expansion of macro 'f'
   72 |    if (min(f,s)==inf) continue;
      |            ^
walk.cpp:72:18: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   72 |    if (min(f,s)==inf) continue;
      |                  ^~~
      |                  ynf
walk.cpp:9:11: error: 'first' was not declared in this scope
    9 | #define f first
      |           ^~~~~
walk.cpp:73:4: note: in expansion of macro 'f'
   73 |    f+=y; s-=y;
      |    ^
walk.cpp:74:8: error: expected ';' before 'x'
   74 |    int x=min(f,s);
      |        ^
walk.cpp:5:12: error: request for member 'push_back' in 'toset', which is of non-class type 'int'
    5 | #define pb push_back
      |            ^~~~~~~~~
walk.cpp:75:10: note: in expansion of macro 'pb'
   75 |    toset.pb({y,x});
      |          ^~
walk.cpp:78:17: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   78 |    bottom.set(y,inf);
      |                 ^~~
      |                 ynf
walk.cpp:81:14: error: 'begin' was not declared in this scope
   81 |   for(auto&x:toset) {
      |              ^~~~~
walk.cpp:81:14: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from walk.cpp:2:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from walk.cpp:2:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
walk.cpp:81:14: error: 'end' was not declared in this scope
   81 |   for(auto&x:toset) {
      |              ^~~~~
walk.cpp:81:14: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from walk.cpp:2:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from walk.cpp:2:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
walk.cpp:10:11: error: 'struct sgt' has no member named 'second'
   10 | #define s second
      |           ^~~~~~
walk.cpp:86:10: note: in expansion of macro 's'
   86 |  if (top.s==inf) return -1;
      |          ^
walk.cpp:86:13: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   86 |  if (top.s==inf) return -1;
      |             ^~~
      |             ynf
walk.cpp:9:11: error: expected ';' before 'first'
    9 | #define f first
      |           ^~~~~
walk.cpp:87:6: note: in expansion of macro 'f'
   87 |  int f = top.s+x[n-1]-x[0];
      |      ^
walk.cpp:9:11: error: 'first' was not declared in this scope
    9 | #define f first
      |           ^~~~~
walk.cpp:88:9: note: in expansion of macro 'f'
   88 |  return f;
      |         ^