이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define name "Arranging Tickets"
#define fi(i, a, b) for(int i = a; i <= b; ++i)
#define fid(i, a, b) for(int i = a; i >= b; --i)
#define maxn (int) (2e5 + 7)
using namespace std;
int n, m;
int d[maxn];
struct dl { int l, r, c; } a[maxn];
void solve() {
cin >> n >> m;
fi(i, 1, m) {
cin >> a[i].l >> a[i].r >> a[i].c;
if(a[i].l > a[i].r) swap(a[i].l, a[i].r);
assert(a[i].c == 1);
}
assert(n <= 20 && m <= 20);
auto go = [&](int l, int r) {
fi(i, l, r) d[i] ++;
};
int ans = 1e9;
fi(x, 0, (1 << m) - 1) {
fi(i, 1, n) d[i] = 0;
fi(i, 1, m) {
if((x >> (i - 1))&1) go(a[i].l, a[i].r - 1);
else go(1, a[i].l - 1), go(a[i].r, n);
}
ans = min(ans, *max_element(d + 1, d + 1 + n));
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
if(fopen(name".inp", "r")) {
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
arranging_tickets.cpp: In function 'int main()':
arranging_tickets.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
53 | freopen(name".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
arranging_tickets.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
54 | freopen(name".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |