Submission #1364268

#TimeUsernameProblemLanguageResultExecution timeMemory
1364268ahmetlbktd4서열 (APIO23_sequence)C++20
Compilation error
0 ms0 KiB
#include "sequence.h"
#import std
//#include <cassert>
using namespace std;

const int MXN = 2e5+5;

int tr[MXN],fr[MXN];
int n;

void upd(int in,int x){
	for (;in <= n;in+=in&-in){
		tr[in] += x;
	}
}

int knj(int k){
	int in = 0;
	for (int mask = 20;mask >= 0;mask--){
		int j = in+(1<<mask);
		if (j <= n && tr[j] < k){
			in = j;
			k -= tr[in];
		}
	}
	return ++in;
}

int sequence(int N,vector <int> a){
	n = N;
	int p = 0;
	for (int l = 0;l < n;l++){
		for (int i = 0;i <= n;i++){
			tr[i] = 0;
			fr[i] = 0;
		}
		for (int r = l;r < n;r++){
			upd(a[r],1);
			fr[a[r]]++;
			int len = r-l+1;
			int m1 = knj((len+1)/2);
			int m2 = knj((len+2)/2);
			p = max({p,fr[m1],fr[m2]});
		}
	}
	return p;
}
//
//int main() {
//	freopen("file.in","r",stdin);
//  int N;
//  assert(1 == scanf("%d", &N));
//
//  std::vector<int> A(N);
//  for (int i = 0; i < N; ++i) {
//    assert(1 == scanf("%d", &A[i]));
//  }
//
//  int result = sequence(N, A);
//  printf("%d\n", result);
//  return 0;
//}

Compilation message (stderr)

sequence.cpp:2:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    2 | #import std
      |  ^~~~~~
sequence.cpp:2:9: error: #import expects "FILENAME" or <FILENAME>
    2 | #import std
      |         ^~~
sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:43:32: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   43 |                         p = max({p,fr[m1],fr[m2]});
      |                             ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/vector:62,
                 from sequence.h:1,
                 from sequence.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
sequence.cpp:43:32: note:   candidate expects 2 arguments, 1 provided
   43 |                         p = max({p,fr[m1],fr[m2]});
      |                             ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
sequence.cpp:43:32: note:   candidate expects 3 arguments, 1 provided
   43 |                         p = max({p,fr[m1],fr[m2]});
      |                             ~~~^~~~~~~~~~~~~~~~~~~