답안 #668767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
668767 2022-12-05T00:35:13 Z vuavisao Lasers (NOI19_lasers) C++14
0 / 100
23 ms 4700 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define ll long long
using namespace std;

template<typename Lhs, typename Rhs> inline void Max_self(Lhs &a, Rhs b) { a = (a > b ? a : b); }
template<typename Lhs, typename Rhs> inline void Min_self(Lhs &a, Rhs b) { a = (a < b ? a : b); }

const int N = 5e5 + 10;

int LEN, n;
vector<vector<int>> door;

namespace sub2 {
    bool check() {
        for(int i = 0; i < n; ++ i) if(door[i].size() != 1) return false;
        return true;
    }

    void solve() {
        int best = 0;
        for(int i = 0; i < n; ++ i) {
            Max_self(best, door[i][0]);
        }
        int res = 2 * max(0, res - (LEN / 2));
        if(res > 0) res -= (LEN & 1);
        cout << res;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (fopen("lasers.inp", "r")) {
        freopen("lasers.inp", "r", stdin);
        freopen("lasers.out", "w", stdout);
    }
    cin >> LEN >> n;
    for(int i = 1; i <= n; ++ i) {
        int cnt; cin >> cnt;
        vector<int> tmp(cnt + 1);
        for(int j = 1; j <= cnt; ++ j) cin >> tmp[j];
        door.push_back(tmp);
    }
    if(sub2::check()) {
        sub2::solve();
        return 0;
    }
    assert(false);
//    if(sub4::check()) {
//        sub4::solve();
//        return 0;
//    }
    return 0;
}

/// Code by vuavisao

Compilation message

lasers.cpp: In function 'int32_t main()':
lasers.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen("lasers.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
lasers.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen("lasers.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
lasers.cpp: In function 'void sub2::solve()':
lasers.cpp:26:34: warning: 'res' is used uninitialized in this function [-Wuninitialized]
   26 |         int res = 2 * max(0, res - (LEN / 2));
      |                              ~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 23 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 448 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 23 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -