Submission #1119614

#TimeUsernameProblemLanguageResultExecution timeMemory
1119614Neco_arcArranging Tickets (JOI17_arranging_tickets)C++17
0 / 100
2 ms608 KiB
#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; int d[maxn]; struct dl { int l, r, c; } a[maxn]; void solve() { cin >> n; fi(i, 1, n) { 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); auto go = [&](int l, int r) { fi(i, l, r) d[i] ++; }; int ans = 1e9; fi(x, 0, (1 << n) - 1) { fi(i, 1, n) d[i] = 0; fi(i, 1, n) { if((x >> (i - 1))&1) go(a[i].l, a[i].r); 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(); }

Compilation message (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...