제출 #6956

#제출 시각아이디문제언어결과실행 시간메모리
6956tncks0121Split the sequence (APIO14_sequence)C++98
컴파일 에러
0 ms0 KiB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <bits/stdc++.h>
#include <memory.h>
 
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef long double llf;
typedef unsigned int uint;
 
using namespace std;
 
const int N_ = 100500, K_ = 205;
int N, K, A[N_];
ll Table[2][N_], S[N_];
int opt[K_][N_];
 
void solve (int k, int i) {
    if(k == 1) return;
    solve(k - 1, opt[k][i] - 1);
    printf("%d ", opt[k][i] - 1);
}

ll *now, *prev;

void conq (int k, int l, int r, int optl, int optr) {
  int m = (l+r) >> 1;
  for(int j = optl; j <= optr; j++) {
    ll val = prev[j-1] + (S[i] - S[j-1]) * (S[N] - S[i]);
    if(v >= now[m]) now[m] = v, opt[k][m] = j;
  }
  conq (k, l, m-1, optl, opt[k][m]);
  conq (k, m+1, r, opt[k][m], optr);
}
 
int main() {
    scanf("%d%d", &N, &K);
    for(int i = 1; i <= N; i++) scanf("%d", A+i), S[i] = S[i-1] + A[i];
 
    for(int i = 1; i <= N; i++) Table[1][i] = S[i] * (S[N] - S[i]);
    for(int k = 2; k <= K+1; k++) {
        now = Table[k&1], prev = Table[~k&1];
        for(int i = 1; i <= N; i++) now[i] = -1, opt[k][i] = -1;
        conq(k, 1, N, 1, N);
    }
 
    printf("%lld\n", Table[~K&1][N]);
    solve(K+1, N);
 
    return 0;
}

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

sequence.cpp: In function 'void conq(int, int, int, int, int)':
sequence.cpp:33:29: error: 'i' was not declared in this scope
sequence.cpp:34:8: error: 'v' was not declared in this scope
sequence.cpp:33:8: warning: unused variable 'val' [-Wunused-variable]
sequence.cpp: In function 'int main()':
sequence.cpp:41:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
sequence.cpp:42:71: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]