제출 #896338

#제출 시각아이디문제언어결과실행 시간메모리
896338vjudge1서열 (APIO23_sequence)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "sequence.h" using namespace std; const int LIM = 5e5+1; vector<int> bit(LIM,0); int n; void add(int p,int v) { for (int i=p;i<=n;i+=i&-i) bit[i]+=v; } int get(int p) { int ans = 0; for (int i=p;i>0;i-=i&-i) ans+=bit[i]; return ans; } int sequence(int N, std::vector<int> A) { n = N; vector<int> sme(N+1); vector<int> sm(N+1); for (int i=1;i<=N;i++) { add(A[i-1],1); sme[i] = get(A[i-1]); sm[i] = get(A[i-1]-1); } vector<int> poss[N+1]; for (int i=1;i<=n;i++) poss[A[i-1]].push_back(i); /* int l = 1; int r = N; while (l<=r) { int m = (l+r) >> 1; bool flag = 0; for (int i=1;i<=n;i++) { int sz = poss[i].size(); for (int j=0;j+m-1<sz;j++) { int smme = sme[poss[i][j+m-1]]-sme[poss[i][j]]+1; int smm = sm[poss[i][j+m-1]]-sm[poss[i][j]]; int len = (poss[i][j+m-1]-poss[i][j]+1); int mid = (len+1)/2; if (smme >= mid && smm < mid) flag = 1; if (len%2==0 && smm<mid+1 && smme>=mid+1) flag = 1; } } if (flag) l = m+1; else r = m-1; }*/ int ans = 1; for (int i=1;i<=n;i++) { int sz = poss[i].size(); for (int j=0;j<sz;j++) { for (int j2=j;j2<sz;j2++) { int smme = sme[poss[i][j2]]-sme[poss[i][j]]+1; int smm = sm[poss[i][j2]]-sm[poss[i][j]]; int len = (poss[i][j2]-poss[i][j]+1); int mid = (len+1)/2; if (smme >= mid && smm < mid) ans = max(ans,j2-j+1); if (len%2==0 && smm<mid+1 && smme>=mid+1) ans = max(ans,j2-j+1); } } } return ans; } int main() { 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; }

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

/usr/bin/ld: /tmp/ccI0y3Ur.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccA3CZnp.o:sequence.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status