답안 #300929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300929 2020-09-17T15:13:59 Z AmineWeslati 식물 비교 (IOI20_plants) C++14
컴파일 오류
0 ms 0 KB
//Never stop trying
include "plants.h"
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

void IO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int N,K;
vi r;
int a[MX];

int compare_plants(int x, int y){
	if(x>y) swap(x,y);
	if((a[x]!=a[y-1]) && (a[y]!=a[(x-1+N)%N])) return 0;
	if(a[x]==a[y-1]){if(r[x]==0) return -1; return 1;}
	if(r[y]==0) return -1; return 1;
}

void init(int kk, vi R){
	N=sz(R); r.assign(all(R)); K=kk;
	int cur=r[0],cnt=0;a[0]=0;
	FOR(i,1,N){
		if(r[i]!=cur){
			cnt++; cur=r[i];
		}
		a[i]=cnt;
	}
	//FOR(i,0,N) cout << a[i] << ' '; cout << endl;
	if(a[N-1]==a[0]){
		int x=a[N-1];
		int i=N-1;
		while(i>=0 && a[i]==x){
			a[i]=0;
			i--;
		}
	}
	//FOR(i,0,N) cout << a[i] << ' '; cout << endl;
}




/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/

Compilation message

plants.cpp:4: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    4 | #pragma GCC optimization ("O3")
      | 
plants.cpp:5: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("unroll-loops")
      | 
plants.cpp:2:1: error: 'include' does not name a type
    2 | include "plants.h"
      | ^~~~~~~
In file included from /usr/include/c++/9/cmath:43,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plants.cpp:6:
/usr/include/c++/9/ext/type_traits.h:162:35: error: 'bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
  162 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
/usr/include/c++/9/ext/type_traits.h:157:5: note: previous declaration 'template<class _Type> bool __gnu_cxx::__is_null_pointer(_Type)'
  157 |     __is_null_pointer(_Type)
      |     ^~~~~~~~~~~~~~~~~
/usr/include/c++/9/ext/type_traits.h:162:26: error: 'nullptr_t' is not a member of 'std'
  162 |   __is_null_pointer(std::nullptr_t)
      |                          ^~~~~~~~~
In file included from /usr/include/c++/9/bits/exception_ptr.h:40,
                 from /usr/include/c++/9/exception:143,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/new:125:50: error: declaration of 'operator new' as non-function
  125 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                                                  ^
/usr/include/c++/9/new:125:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  125 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                                            ^~~~~~
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here
  209 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
In file included from /usr/include/c++/9/bits/exception_ptr.h:40,
                 from /usr/include/c++/9/exception:143,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/new:126:41: error: attributes after parenthesized initializer ignored [-fpermissive]
  126 |   __attribute__((__externally_visible__));
      |                                         ^
/usr/include/c++/9/new:127:52: error: declaration of 'operator new []' as non-function
  127 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                                                    ^
/usr/include/c++/9/new:127:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  127 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                                              ^~~~~~
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here
  209 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
In file included from /usr/include/c++/9/bits/exception_ptr.h:40,
                 from /usr/include/c++/9/exception:143,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/new:128:41: error: attributes after parenthesized initializer ignored [-fpermissive]
  128 |   __attribute__((__externally_visible__));
      |                                         ^
/usr/include/c++/9/new:134:34: error: 'std::size_t' has not been declared
  134 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
      |                                  ^~~~~~
/usr/include/c++/9/new:136:36: error: 'std::size_t' has not been declared
  136 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
      |                                    ^~~~~~
/usr/include/c++/9/new:139:44: error: declaration of 'operator new' as non-function
  139 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
      |                                            ^~~~~~
/usr/include/c++/9/new:139:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here
  209 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
In file included from /usr/include/c++/9/bits/exception_ptr.h:40,
                 from /usr/include/c++/9/exception:143,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/new:139:52: error: expected primary-expression before 'const'
  139 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
      |                                                    ^~~~~
/usr/include/c++/9/new:141:46: error: declaration of 'operator new []' as non-function
  141 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
      |                                              ^~~~~~
/usr/include/c++/9/new:141:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here
  209 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
In file included from /usr/include/c++/9/bits/exception_ptr.h:40,
                 from /usr/include/c++/9/exception:143,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/new:141:54: error: expected primary-expression before 'const'
  141 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
      |                                                      ^~~~~
/usr/include/c++/9/new:173:51: error: declaration of 'operator new' as non-function
  173 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
      |                                                   ^~~~~~
/usr/include/c++/9/new:173:51: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here
  209 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
In file included from /usr/include/c++/9/bits/exception_ptr.h:40,
                 from /usr/include/c++/9/exception:143,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/new:173:59: error: expected primary-expression before 'void'
  173 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
      |                                                           ^~~~
/usr/include/c++/9/new:175:53: error: declaration of 'operator new []' as non-function
  175 | _GLIBCXX_NODISCARD inline void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
      |                                                     ^~~~~~
/usr/include/c++/9/new:175:53: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here
  209 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
In file included from /usr/include/c++/9/bits/exception_ptr.h:40,
                 from /usr/include/c++/9/exception:143,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/new:175:61: error: expected primary-expression before 'void'
  175 | _GLIBCXX_NODISCARD inline void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
      |                                                             ^~~~
In file included from /usr/include/c++/9/bits/move.h:55,
                 from /usr/include/c++/9/bits/nested_exception.h:40,
                 from /usr/include/c++/9/exception:144,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/type_traits:361:31: error: 'std::size_t' has not been declared
  361 |   template<typename _Tp, std::size_t _Size>
      |                               ^~~~~~
/usr/include/c++/9/type_traits:362:25: error: '_Size' was not declared in this scope
  362 |     struct is_array<_Tp[_Size]>
      |                         ^~~~~
/usr/include/c++/9/type_traits:362:31: error: template argument 1 is invalid
  362 |     struct is_array<_Tp[_Size]>
      |                               ^
/usr/include/c++/9/type_traits:560:42: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
  560 |     struct __is_null_pointer_helper<std::nullptr_t>
      |                                          ^~~~~~~~~
In file included from /usr/include/c++/9/cstddef:50,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:45,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:433:29: note: 'nullptr_t' declared here
  433 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
In file included from /usr/include/c++/9/bits/move.h:55,
                 from /usr/include/c++/9/bits/nested_exception.h:40,
                 from /usr/include/c++/9/exception:144,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/type_traits:560:42: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
  560 |     struct __is_null_pointer_helper<std::nullptr_t>
      |                                          ^~~~~~~~~
In file included from /usr/include/c++/9/cstddef:50,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:45,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:433:29: note: 'nullptr_t' declared here
  433 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
In file included from /usr/include/c++/9/bits/move.h:55,
                 from /usr/include/c++/9/bits/nested_exception.h:40,
                 from /usr/include/c++/9/exception:144,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/type_traits:560:51: error: template argument 1 is invalid
  560 |     struct __is_null_pointer_helper<std::nullptr_t>
      |                                                   ^
/usr/include/c++/9/type_traits:1253:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1253 |     : public integral_constant<std::size_t, alignof(_Tp)> { };
      |                                     ^~~~~~
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here
  209 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
In file included from /usr/include/c++/9/bits/move.h:55,
                 from /usr/include/c++/9/bits/nested_exception.h:40,
                 from /usr/include/c++/9/exception:144,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/type_traits:1253:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1253 |     : public integral_constant<std::size_t, alignof(_Tp)> { };
      |                                     ^~~~~~
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here
  209 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
In file included from /usr/include/c++/9/bits/move.h:55,
                 from /usr/include/c++/9/bits/nested_exception.h:40,
                 from /usr/include/c++/9/exception:144,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/type_traits:1253:57: error: template argument 1 is invalid
 1253 |     : public integral_constant<std::size_t, alignof(_Tp)> { };
      |                                                         ^
/usr/include/c++/9/type_traits:1253:57: note: invalid template non-type parameter
/usr/include/c++/9/type_traits:1258:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1258 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from plants.cpp:6:
/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:209:23: note: 'size_t' declared here
  209 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
In file included from /usr/include/c++/9/bits/move.h:55,
                 from /usr/include/c++/9/bits/nested_exception.h:40,
                 from /usr/include/c++/9/exception:144,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plants.cpp:6:
/usr/include/c++/9/type_traits:1258:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1258 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu