제출 #126545

#제출 시각아이디문제언어결과실행 시간메모리
126545briansuArranging Tickets (JOI17_arranging_tickets)C++14
10 / 100
332 ms504 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> ii; #define REP(i, n) for(int i = 0;i < n;i ++) #define REP1(i, n) for(int i = 1;i <= n;i ++) #define FILL(i, n) memset(i, n, sizeof(i)) #define X first #define Y second #define pb push_back #define SZ(_a) ((int)(_a).size()) #define ALL(_a) (_a).begin(), (_a).end() #ifdef brian #define IOS() template<typename T>void _do(T &&x){cerr<<x<<endl;} template<typename T, typename ...t>void _do(T &&x, t &&...X){cerr<<x<<", ";_do(X...);} #define debug(...) {\ fprintf(stderr, "%s - %d (%s) = ", __PRETTY_FUNCTION__, __LINE__, #__VA_ARGS__);\ _do(__VA_ARGS__);\ } #else #define debug(...) #define IOS() ios_base::sync_with_stdio(0);cin.tie(0); #define endl '\n' #endif const ll MAXn = 1e5 + 5; const ll INF = ll(1e18); const ll MOD = 1000000007; ll a[MAXn], b[MAXn], c[MAXn]; ll fg[MAXn], mn[MAXn]; map<ii, ll> mp; vector<ii> dt; ll n, m; ll d[MAXn]; ll chk(ll x) { REP1(i, n)d[i] = 0; for(int i = 0, I = 1;i < SZ(dt);i ++, I<<=1) { if(I & x)for(int j = dt[i].X;j < dt[i].Y;j ++)d[j]++; else { for(int j = 1;j < dt[i].X;j ++)d[j] ++; for(int j = dt[i].Y;j <= n;j ++)d[j] ++; } } ll mx = 0; REP1(i, n)mx = max(mx, d[i]); return mx; } int main(){ IOS(); cin>>n>>m; REP1(i, m)cin>>a[i]>>b[i]>>c[i]; REP1(i, m)if(a[i] > b[i])swap(a[i], b[i]); REP1(i, m)mp[ii(a[i], b[i])]++; ll tmptt = 0; for(auto &p:mp) { tmptt += p.Y / 2; if(p.Y & 1)dt.pb(p.X); } ll ans = INF; REP(I, (1<<SZ(dt)))ans = min(ans, chk(I)); cout<<ans + tmptt<<endl; }
#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...