Submission #107755

#TimeUsernameProblemLanguageResultExecution timeMemory
107755Just_Solve_The_ProblemBoat (APIO16_boat)C++11
9 / 100
3 ms412 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = (int)507; const int mod = (int)1e9 + 7; int add(int a, int b) { return (a + b) % mod; } int mul(int a, int b) { return (a * 1LL * b) % mod; } int n; int a[N], b[N]; struct fen { int tree[N]; fen() { memset(tree, 0, sizeof tree); } void upd(int pos, int val) { while (pos < N) { tree[pos] = add(tree[pos], val); pos = pos | pos + 1; } } int get(int r) { int res = 0; while (r >= 0) { res = add(res, tree[r]); r = (r & r + 1) - 1; } return res; } }; fen tr; main() { scanf("%d", &n); vector < int > vec; vec.push_back(-1e9); for (int i = 1; i <= n; i++) { scanf("%d %d", &a[i], &b[i]); vec.push_back(a[i]); } sort(vec.begin(), vec.end()); for (int i = 1; i <= n; i++) { a[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin(); } tr.upd(0, 1); for (int i = 1; i <= n; i++) { tr.upd(a[i], tr.get(a[i] - 1)); } cout << add(tr.get(N - 1), mod - 1); }

Compilation message (stderr)

boat.cpp: In member function 'void fen::upd(int, int)':
boat.cpp:29:20: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
    pos = pos | pos + 1;
                ~~~~^~~
boat.cpp: In member function 'int fen::get(int)':
boat.cpp:36:15: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
    r = (r & r + 1) - 1;
             ~~^~~
boat.cpp: At global scope:
boat.cpp:43:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
boat.cpp: In function 'int main()':
boat.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
boat.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a[i], &b[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...