답안 #1072685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072685 2024-08-24T02:49:25 Z _rain_ Lasers (NOI19_lasers) C++14
100 / 100
126 ms 13780 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fixbug false

void SETIO(string name = ""){
    if (name=="") return;
    freopen((name+".inp").c_str(),"r",stdin);
//    freopen((name+".out").c_str(),"w",stdout);
    return;
}

int numrow , L;
#define fi first
#define se second

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    SETIO("");

    cin >> L >> numrow;
    vector<pair<int,int>> ev;
    for (int i = 1; i <= numrow; ++i){
          int x; cin >> x;
          vector<int> a(x+2,0) , pre(x+2,0);
          for (int j = 1; j <= x; ++j) {
            cin >> a[j];
            pre[j] = pre[j - 1] + a[j];
          }
          for (int j = 1; j <= x; ++j){
            int jump = a[j];
            int l = pre[j - 1] + 1 , r = L - (pre[x] - pre[j]);
            if (l + jump - 1 < r - jump + 1) continue;
            ev.push_back({min(L+1,l + jump) , -1});
            ev.push_back({max(1,r - jump + 1) , 1});
            if (fixbug){
                cout << "FIXBUG\n";
                cout << i << ' ' << j << ' ' << l << ' ' << r << '\n';
            }
          }
    }
    sort(ev.begin(),ev.end());
    int leftmost = -1 , sum = 0 , ans= 0;
    for (int i = 0; i < ev.size(); ++i){
        if (leftmost == -1) leftmost = ev[i].fi;
        sum += ev[i].se;
        if (sum==0){
            if (fixbug){
                    cout << "DEBUG\n";
                    cout << ev[i].fi << ' ' << ev[i].se << '\n';
            }
            ans += ev[i].fi - leftmost ;
            leftmost = -1;
        }
    }
    cout << ans;
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i = 0; i < ev.size(); ++i){
      |                     ~~^~~~~~~~~~~
lasers.cpp: In function 'void SETIO(std::string)':
lasers.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen((name+".inp").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 416 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 452 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 416 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 452 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 104 ms 13780 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 104 ms 10384 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 7668 KB Output is correct
2 Correct 10 ms 1760 KB Output is correct
3 Correct 11 ms 1476 KB Output is correct
4 Correct 48 ms 8164 KB Output is correct
5 Correct 17 ms 4044 KB Output is correct
6 Correct 21 ms 3928 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 25 ms 4748 KB Output is correct
9 Correct 22 ms 5824 KB Output is correct
10 Correct 43 ms 8308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 7668 KB Output is correct
2 Correct 10 ms 1760 KB Output is correct
3 Correct 11 ms 1476 KB Output is correct
4 Correct 48 ms 8164 KB Output is correct
5 Correct 17 ms 4044 KB Output is correct
6 Correct 21 ms 3928 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 25 ms 4748 KB Output is correct
9 Correct 22 ms 5824 KB Output is correct
10 Correct 43 ms 8308 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 121 ms 8776 KB Output is correct
22 Correct 15 ms 2124 KB Output is correct
23 Correct 10 ms 1972 KB Output is correct
24 Correct 49 ms 7424 KB Output is correct
25 Correct 108 ms 8640 KB Output is correct
26 Correct 39 ms 7596 KB Output is correct
27 Correct 15 ms 2052 KB Output is correct
28 Correct 112 ms 8620 KB Output is correct
29 Correct 104 ms 8636 KB Output is correct
30 Correct 29 ms 3824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 416 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 452 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 104 ms 13780 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 104 ms 10384 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 35 ms 7668 KB Output is correct
22 Correct 10 ms 1760 KB Output is correct
23 Correct 11 ms 1476 KB Output is correct
24 Correct 48 ms 8164 KB Output is correct
25 Correct 17 ms 4044 KB Output is correct
26 Correct 21 ms 3928 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 25 ms 4748 KB Output is correct
29 Correct 22 ms 5824 KB Output is correct
30 Correct 43 ms 8308 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 121 ms 8776 KB Output is correct
42 Correct 15 ms 2124 KB Output is correct
43 Correct 10 ms 1972 KB Output is correct
44 Correct 49 ms 7424 KB Output is correct
45 Correct 108 ms 8640 KB Output is correct
46 Correct 39 ms 7596 KB Output is correct
47 Correct 15 ms 2052 KB Output is correct
48 Correct 112 ms 8620 KB Output is correct
49 Correct 104 ms 8636 KB Output is correct
50 Correct 29 ms 3824 KB Output is correct
51 Correct 15 ms 2256 KB Output is correct
52 Correct 108 ms 9792 KB Output is correct
53 Correct 126 ms 9660 KB Output is correct
54 Correct 23 ms 4080 KB Output is correct
55 Correct 58 ms 8572 KB Output is correct
56 Correct 35 ms 7864 KB Output is correct
57 Correct 42 ms 8448 KB Output is correct
58 Correct 105 ms 10024 KB Output is correct
59 Correct 32 ms 3576 KB Output is correct
60 Correct 40 ms 4828 KB Output is correct