답안 #264319

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
264319 2020-08-14T06:10:55 Z 송준혁(#5083) Teams (CEOI11_tea) C++17
0 / 100
331 ms 64404 KB
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

int N;
pii A[1010101];
int D[1010101], P[1010101];
pii T[1010101];
vector<pii> V[1010101];

void upd(int k, pii v){while (k<=N){T[k]=max(T[k],v), k+=k&-k;}}
pii read(int k){pii r(0,0); while (k){r=max(T[k],r), k^=k&-k;} return r;}

int main(){
	scanf("%d", &N);
	for (int i=1; i<=N; i++) scanf("%d", &A[i].fi), A[i].se=i;
	sort(A+1, A+N+1);
	for (int i=1; i<=N; i++){
		for (pii t : V[i]) upd(t.se, t);
		pii x = read(i-A[i].fi);
		if (i-A[i].fi<0) continue;
		D[i] = x.fi+1, P[i] = x.se;
		if (2*i-x.se <= N) V[2*i-x.se].pb(pii(D[i], i));
	}
	printf("%d\n", D[N]);
	int t=N;
	while (t){
		printf("%d ", t-P[t]);
		for (int i=P[t]+1; i<=t; i++) printf("%d ", A[i].se);
		printf("\n");
		t = P[t];
	}
	return 0;
}

Compilation message

tea.cpp: In function 'int main()':
tea.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
tea.cpp:20:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  for (int i=1; i<=N; i++) scanf("%d", &A[i].fi), A[i].se=i;
      |                           ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 24064 KB Output is correct
2 Runtime error 51 ms 48504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 54 ms 48516 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 49 ms 48504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 53 ms 48644 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 52 ms 48632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 72 ms 49784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 72 ms 49888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 241 ms 60424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 331 ms 64376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 325 ms 64404 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -