Submission #23036

# Submission time Handle Problem Language Result Execution time Memory
23036 2017-05-02T05:19:42 Z ngkan146 Boat (APIO16_boat) C++
9 / 100
0 ms 2032 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = (ll) 1e9+7;
int n, a[505], b[505];
vector <int> mjk(1,0);
ll dp[505];
int len(int l1,int r1,int l2,int r2){
   return max(0, min(r1,r2) - max(l1,l2) + 1);
}
int main(){
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
      scanf("%d %d",&a[i],&b[i]),
      mjk.push_back(a[i]),
      mjk.push_back(b[i]);
   sort(mjk.begin(),mjk.end());
   mjk.push_back((int)1e9+1);
   mjk.resize(unique(mjk.begin(),mjk.end()) - mjk.begin());
   dp[0] = 1;
   for(int i=1;i<=n;i++){
      ll cnt = 0;
      for(int j=0;j<mjk.size()-1;j++){
         ll tmp = cnt + dp[j];
         dp[j] = (dp[j] + len(mjk[j], mjk[j+1]-1, a[i], b[i]) * cnt) % mod;
         cnt = tmp;
      }
   }
   ll ans = 0;
   for(int i=1;i<mjk.size()-1;i++)
      ans = (ans + dp[i]) % mod;
   cout << ans;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int j=0;j<mjk.size()-1;j++){
                    ^
boat.cpp:30:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i=1;i<mjk.size()-1;i++)
                 ^
boat.cpp:12:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&n);
                  ^
boat.cpp:16:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       mjk.push_back(b[i]);
                          ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2032 KB Output is correct
2 Correct 0 ms 2032 KB Output is correct
3 Correct 0 ms 2032 KB Output is correct
4 Correct 0 ms 2032 KB Output is correct
5 Correct 0 ms 2032 KB Output is correct
6 Correct 0 ms 2032 KB Output is correct
7 Correct 0 ms 2032 KB Output is correct
8 Correct 0 ms 2032 KB Output is correct
9 Correct 0 ms 2032 KB Output is correct
10 Correct 0 ms 2032 KB Output is correct
11 Correct 0 ms 2032 KB Output is correct
12 Correct 0 ms 2032 KB Output is correct
13 Correct 0 ms 2032 KB Output is correct
14 Correct 0 ms 2032 KB Output is correct
15 Correct 0 ms 2032 KB Output is correct
16 Correct 0 ms 2032 KB Output is correct
17 Correct 0 ms 2032 KB Output is correct
18 Correct 0 ms 2032 KB Output is correct
19 Correct 0 ms 2032 KB Output is correct
20 Correct 0 ms 2032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2032 KB Output is correct
2 Correct 0 ms 2032 KB Output is correct
3 Correct 0 ms 2032 KB Output is correct
4 Correct 0 ms 2032 KB Output is correct
5 Correct 0 ms 2032 KB Output is correct
6 Correct 0 ms 2032 KB Output is correct
7 Correct 0 ms 2032 KB Output is correct
8 Correct 0 ms 2032 KB Output is correct
9 Correct 0 ms 2032 KB Output is correct
10 Correct 0 ms 2032 KB Output is correct
11 Correct 0 ms 2032 KB Output is correct
12 Correct 0 ms 2032 KB Output is correct
13 Correct 0 ms 2032 KB Output is correct
14 Correct 0 ms 2032 KB Output is correct
15 Correct 0 ms 2032 KB Output is correct
16 Correct 0 ms 2032 KB Output is correct
17 Correct 0 ms 2032 KB Output is correct
18 Correct 0 ms 2032 KB Output is correct
19 Correct 0 ms 2032 KB Output is correct
20 Correct 0 ms 2032 KB Output is correct
21 Runtime error 0 ms 2032 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2032 KB Output is correct
2 Correct 0 ms 2032 KB Output is correct
3 Correct 0 ms 2032 KB Output is correct
4 Correct 0 ms 2032 KB Output is correct
5 Correct 0 ms 2032 KB Output is correct
6 Correct 0 ms 2032 KB Output is correct
7 Correct 0 ms 2032 KB Output is correct
8 Correct 0 ms 2032 KB Output is correct
9 Correct 0 ms 2032 KB Output is correct
10 Correct 0 ms 2032 KB Output is correct
11 Correct 0 ms 2032 KB Output is correct
12 Correct 0 ms 2032 KB Output is correct
13 Correct 0 ms 2032 KB Output is correct
14 Correct 0 ms 2032 KB Output is correct
15 Correct 0 ms 2032 KB Output is correct
16 Correct 0 ms 2032 KB Output is correct
17 Correct 0 ms 2032 KB Output is correct
18 Correct 0 ms 2032 KB Output is correct
19 Correct 0 ms 2032 KB Output is correct
20 Correct 0 ms 2032 KB Output is correct
21 Runtime error 0 ms 2032 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -