답안 #522694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522694 2022-02-05T12:39:05 Z InternetPerson10 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
#include "candies.h"

#include <vector>

using namespace std;

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    int n = c.size();
    vector<ll> s(n+1);
    bool subtask2 = true, subtask3 = true, subtask4 = true;
    for(int i = 0; i < n; i++) {
        if(v[j] < 0) subtask2 = false;
        if(i > 0 && c[i] != c[i-1]) subtask3 = false;
        if(r[i] - l[i] != n-1) subtask4 = false;
    }
    if(n <= 2000 && q <= 2000) { // Subtask 1
        for(int i = 0; i < q; i++) {
            for(int j = l[i], j <= r[i], j++) {
                s[j] += v[j];
                s[j] = max(s[j], 0);
                s[j] = min(s[j], c[j]);
            }
        }
    }
    else if(subtask2) {
        for(int i = 0; i < q; i++) {
            s[l[i]] += v[i];
            s[r[i]+1] -= v[i];
        }
        for(int i = 1; i < n; i++) {
            s[i] += s[i-1];
        }
        for(int i = 0; i < n; i++) {
            s[i] = min(s[i], c[i]);
        }
    }
    else if(subtask3) {

    }
    else if(subtask4) {

    }
    else {

    }
    vector<int> sInt(n);
    for(int i = 0; i < n; i++) sInt[i] = s[i];
    return sInt;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:9:12: error: 'll' was not declared in this scope; did you mean 'l'?
    9 |     vector<ll> s(n+1);
      |            ^~
      |            l
candies.cpp:9:14: error: template argument 1 is invalid
    9 |     vector<ll> s(n+1);
      |              ^
candies.cpp:9:14: error: template argument 2 is invalid
candies.cpp:12:14: error: 'j' was not declared in this scope
   12 |         if(v[j] < 0) subtask2 = false;
      |              ^
candies.cpp:16:21: error: 'q' was not declared in this scope
   16 |     if(n <= 2000 && q <= 2000) { // Subtask 1
      |                     ^
candies.cpp:18:32: error: expected ';' before '<=' token
   18 |             for(int j = l[i], j <= r[i], j++) {
      |                                ^~~
      |                                ;
candies.cpp:18:33: error: expected primary-expression before '<=' token
   18 |             for(int j = l[i], j <= r[i], j++) {
      |                                 ^~
candies.cpp:18:45: error: expected ';' before ')' token
   18 |             for(int j = l[i], j <= r[i], j++) {
      |                                             ^
      |                                             ;
candies.cpp:19:18: error: invalid types 'int[int]' for array subscript
   19 |                 s[j] += v[j];
      |                  ^
candies.cpp:20:18: error: invalid types 'int[int]' for array subscript
   20 |                 s[j] = max(s[j], 0);
      |                  ^
candies.cpp:20:29: error: invalid types 'int[int]' for array subscript
   20 |                 s[j] = max(s[j], 0);
      |                             ^
candies.cpp:21:18: error: invalid types 'int[int]' for array subscript
   21 |                 s[j] = min(s[j], c[j]);
      |                  ^
candies.cpp:21:29: error: invalid types 'int[int]' for array subscript
   21 |                 s[j] = min(s[j], c[j]);
      |                             ^
candies.cpp:27:14: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   27 |             s[l[i]] += v[i];
      |              ^
candies.cpp:28:14: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   28 |             s[r[i]+1] -= v[i];
      |              ^
candies.cpp:31:14: error: invalid types 'int[int]' for array subscript
   31 |             s[i] += s[i-1];
      |              ^
candies.cpp:31:22: error: invalid types 'int[int]' for array subscript
   31 |             s[i] += s[i-1];
      |                      ^
candies.cpp:34:14: error: invalid types 'int[int]' for array subscript
   34 |             s[i] = min(s[i], c[i]);
      |              ^
candies.cpp:34:25: error: invalid types 'int[int]' for array subscript
   34 |             s[i] = min(s[i], c[i]);
      |                         ^
candies.cpp:47:43: error: invalid types 'int[int]' for array subscript
   47 |     for(int i = 0; i < n; i++) sInt[i] = s[i];
      |                                           ^