| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 333022 | guka415 | Lasers (NOI19_lasers) | C++14 | 58 ms | 7500 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int sz = 5e5+5;
ll l, n;
vector<pair<int, bool>> segs;
inline bool intersect(const pii& lhs, const pii& rhs) {
return (rhs.first - lhs.second <= 1);
}
int main() {
fast;
cin >> l >> n;
bool bad = 0;
while (n--) {
vector<int> v;
int x, tmp, rsum = 0, lsum = 0;
cin >> x;
foru(i, 0, x) {
cin >> tmp;
rsum += tmp;
v.pb(tmp);
}
if (rsum == l) {
bad = 1;
continue;
}
vector<pii> yes;
yes.pb({ 0,l - rsum - 1 });
lsum += v[0];
rsum -= v[0];
foru(i, 1, x + 1) {
pii inval = { lsum, l - rsum - 1 }, yb = yes.back();
if (intersect(yb, inval)) {
yes.back() = { yb.first,inval.second };
}
else {
yes.pb(inval);
}
if (i != x) {
lsum += v[i];
rsum -= v[i];
}
}
foru(i, 0, yes.size() - 1) {
segs.pb({ yes[i].second + 1,0 });
segs.pb({ yes[i + 1].first - 1,1 });
}
}
sort(segs.begin(), segs.end());
ll tot = 0, prvLit = -1;
int o = 0;
for (auto x : segs) {
if (!x.second) {
if (o == 0) {
prvLit = x.first;
}
o++;
}
else {
o--;
if (o == 0) {
tot += (x.first - prvLit + 1);
}
}
}
cout << tot << '\n';
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
