Submission #23226

#TimeUsernameProblemLanguageResultExecution timeMemory
2322614kgBoat (APIO16_boat)C++98
Compilation error
0 ms0 KiB
#include <stdio.h> #include <map> #include <set> #include <algorithm> #define MOD 1000000007 #define min2(x,y) (x<y?x:y) using namespace std; int n, w_len, d[501][1503]; bool check[501][1503]; pair<int, int> r[501], w[1503]; set<int> S; map<int,int> M; int f(int lev, int y) { if (lev == 0) return 1; if (!check[lev][y]) { check[lev][y] = true, d[lev][y] = f(lev - 1, y); for (int i = r[lev].first; i <= min2(r[lev].second, y); i++) { long long temp = f(lev - 1, i - 1), temp2 = w[i].second - w[i].first + 1; temp = (temp*temp2) % MOD; d[lev][y] = (d[lev][y] + temp) % MOD; } } return d[lev][y]; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d", &r[i].first, &r[i].second); S.insert(r[i].first), S.insert(r[i].second); } auto it1 = S.begin(), it2 = it1; it2++, w[++w_len] = { 0,*it1 - 1 }; while (it2 != S.end()) { M[*it1] = ++w_len, w[w_len] = { *it1,*it1 }; if (*it1 + 1 <= *it2 - 1) w[++w_len] = { *it1 + 1,*it2 - 1 }; it1++, it2++; } M[*it1] = ++w_len, w[w_len] = { *it1,*it1 }; for (int i = 1; i <= n; i++) { r[i].first = M[r[i].first]; r[i].second = M[r[i].second]; } int res = f(n, w_len); printf("%d", res ? res - 1 : MOD- 1); }

Compilation message (stderr)

boat.cpp: In function 'int main()':
boat.cpp:33:2: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
  auto it1 = S.begin(), it2 = it1;
  ^
boat.cpp:33:7: error: 'it1' does not name a type
  auto it1 = S.begin(), it2 = it1;
       ^
boat.cpp:35:2: error: 'it2' was not declared in this scope
  it2++, w[++w_len] = { 0,*it1 - 1 };
  ^
boat.cpp:35:27: error: 'it1' was not declared in this scope
  it2++, w[++w_len] = { 0,*it1 - 1 };
                           ^
boat.cpp:35:35: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
  it2++, w[++w_len] = { 0,*it1 - 1 };
                                   ^
boat.cpp:35:20: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
  it2++, w[++w_len] = { 0,*it1 - 1 };
                    ^
boat.cpp:35:20: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and '<brace-enclosed initializer list>')
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/5/bits/stl_tree.h:63,
                 from /usr/include/c++/5/map:60,
                 from boat.cpp:2:
/usr/include/c++/5/bits/stl_pair.h:96:12: note: candidate: std::pair<int, int>& std::pair<int, int>::operator=(const std::pair<int, int>&)
     struct pair
            ^
/usr/include/c++/5/bits/stl_pair.h:96:12: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::pair<int, int>&'
boat.cpp:37:45: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   M[*it1] = ++w_len, w[w_len] = { *it1,*it1 };
                                             ^
boat.cpp:37:31: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   M[*it1] = ++w_len, w[w_len] = { *it1,*it1 };
                               ^
boat.cpp:37:31: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and '<brace-enclosed initializer list>')
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/5/bits/stl_tree.h:63,
                 from /usr/include/c++/5/map:60,
                 from boat.cpp:2:
/usr/include/c++/5/bits/stl_pair.h:96:12: note: candidate: std::pair<int, int>& std::pair<int, int>::operator=(const std::pair<int, int>&)
     struct pair
            ^
/usr/include/c++/5/bits/stl_pair.h:96:12: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::pair<int, int>&'
boat.cpp:38:62: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   if (*it1 + 1 <= *it2 - 1) w[++w_len] = { *it1 + 1,*it2 - 1 };
                                                              ^
boat.cpp:38:40: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   if (*it1 + 1 <= *it2 - 1) w[++w_len] = { *it1 + 1,*it2 - 1 };
                                        ^
boat.cpp:38:40: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and '<brace-enclosed initializer list>')
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/5/bits/stl_tree.h:63,
                 from /usr/include/c++/5/map:60,
                 from boat.cpp:2:
/usr/include/c++/5/bits/stl_pair.h:96:12: note: candidate: std::pair<int, int>& std::pair<int, int>::operator=(const std::pair<int, int>&)
     struct pair
            ^
/usr/include/c++/5/bits/stl_pair.h:96:12: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::pair<int, int>&'
boat.cpp:40:46: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
  } M[*it1] = ++w_len, w[w_len] = { *it1,*it1 };
                                              ^
boat.cpp:40:32: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
  } M[*it1] = ++w_len, w[w_len] = { *it1,*it1 };
                                ^
boat.cpp:40:32: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and '<brace-enclosed initializer list>')
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/5/bits/stl_tree.h:63,
                 from /usr/include/c++/5/map:60,
                 from boat.cpp:2:
/usr/include/c++/5/bits/stl_pair.h:96:12: note: candidate: std::pair<int, int>& std::pair<int, int>::operator=(const std::pair<int, int>&)
     struct pair
            ^
/usr/include/c++/5/bits/stl_pair.h:96:12: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::pair<int, int>&'
boat.cpp:27:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
boat.cpp:29:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &r[i].first, &r[i].second);
                                            ^