Submission #946520

#TimeUsernameProblemLanguageResultExecution timeMemory
946520n3rm1nBoat (APIO16_boat)C++17
Compilation error
0 ms0 KiB
/// boat #include<bits/stdc++.h> #define endl '\n' using namespace std; const long long MAXN = 505, MAXX = 1e6+10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } long long n, m; long long a[MAXN], b[MAXN]; map < long long, long long > index; vector < long long > g, u; void read_hash() { cin >> n; for (long long i = 1; i <= n; ++ i) { cin >> a[i] >> b[i]; for (long long j = a[i]; j <= b[i]; ++ j) g.push_back(j); } sort(g.begin(), g.end()); u.push_back(g[0]); for (long long i = 1; i < g.size(); ++ i) { if(u.back() != g[i]) u.push_back(g[i]); } for (long long i = 0; i < u.size(); ++ i) { index[u[i]] = i+1; } } long long dp[MAXX]; const long long mod = 1e9 + 7; long long pref[MAXX]; void solve() { long long ans = 0; long long maxx = 1e6; for (long long i = 1; i <= n; ++ i) { for (long long j = 1; j <= 1e6; ++ j) pref[j] = (pref[j-1] + dp[j]) % mod; for (long long j = b[i]; j >= a[i]; -- j) { dp[j] += pref[j-1] + 1; dp[j] %= mod; } } for (long long j = 1; j <= maxx; ++ j) pref[j] = pref[j-1] + dp[j]; ans += pref[maxx]; ans %= mod; cout << ans << endl; } int main() { speed(); read_hash(); solve(); return 0; }

Compilation message (stderr)

boat.cpp:14:30: error: 'std::map<long long int, long long int> index' redeclared as different kind of entity
   14 | map < long long, long long > index;
      |                              ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from boat.cpp:2:
/usr/include/strings.h:61:1: note: previous declaration 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
boat.cpp: In function 'void read_hash()':
boat.cpp:27:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (long long i = 1; i < g.size(); ++ i)
      |                           ~~^~~~~~~~~~
boat.cpp:32:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (long long i = 0; i < u.size(); ++ i)
      |                           ~~^~~~~~~~~~
boat.cpp:34:14: error: invalid types '<unresolved overloaded function type>[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript
   34 |         index[u[i]] = i+1;
      |              ^