답안 #282527

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282527 2020-08-24T14:13:45 Z AaronNaidu Boat (APIO16_boat) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll mod = 1000000007; 
int n;
ll x;
vector<ll> v;
vector<pair<ll, int> > ycoords;
int index[501];

ll dp[501][501];

ll getDP(int a, int b) {
    if (a == -1)
    {
        return 1;
    }
    if (dp[a][b] > 0)
    {
        return dp[a][b];
    }
    
    ll ans = 0;
    if (ycoords[b].first >= v[a])
    {
        ans += getDP(a-1, index[a]);
        ans %= mod;
    }
    ans += getDP(a-1, b);
    ans %= mod;
    dp[a][b] = ans;
    return ans;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> x;
        v.push_back(x);
        ycoords.push_back({x, i});
    }
    sort(ycoords.begin(), ycoords.end());
    for (int i = 0; i < n; i++)
    {
        index[ycoords[i].second] = i;
    }
    ll ans = getDP(n-1, n-1) - 1;
    ans %= mod;
    cout << ans << "\n";
}

Compilation message

boat.cpp:10:14: error: 'int index [501]' redeclared as different kind of entity
   10 | int index[501];
      |              ^
In file included from /usr/include/c++/9/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:48,
                 from boat.cpp:1:
/usr/include/string.h:477:1: note: previous declaration 'const char* index(const char*, int)'
  477 | index (const char *__s, int __c) __THROW
      | ^~~~~
boat.cpp: In function 'll getDP(int, int)':
boat.cpp:27:34: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   27 |         ans += getDP(a-1, index[a]);
      |                                  ^
boat.cpp: In function 'int main()':
boat.cpp:47:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   47 |         index[ycoords[i].second] = i;
      |                                ^