Submission #1501596
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define FOR(i,l,r) for(int i = int(l);i < int(r);i++) template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; } template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; } typedef long long ll; int N; const int MAX_N = 15; int L [MAX_N],R [MAX_N]; bool isOk [1 << MAX_N]; int dp [1 << MAX_N]; const int INF = 1e9; int main() { scanf("%d",&N); FOR(i,0,N){ int p,q,r,s; scanf("%02d:%02d %02d:%02d",&p,&q,&r,&s); L [i] = (p * 60 + q) % 1440; R [i] = (r * 60 + s) % 1440; } FOR(mask,0,1 << N){ isOk [mask] = true; int mx = 2880; vector<int> v(mx); FOR(i,0,N) if(mask >> i & 1){ if(L [i] <= R [i]){ v [L [i]]++; v [R [i]]--; } else{ v [0]++; v [R [i]]--; v [L [i]]++; } } FOR(i,0,mx){ if(i > 0) v [i] += v [i - 1]; isOk [mask] &= v [i] <= 1; } } fill(dp,dp + (1 << N),INF); dp [0] = 0; FOR(mask,0,1 << N){ int t = ((1 << N) - 1) ^ mask; for(int mask2 = t;mask2 > 0;mask2 = (mask2 - 1) & t) if(isOk [mask2]){ chmin(dp [mask | (mask2)],dp [mask] + 1); } } printf("%d\n",dp [(1 << N) - 1]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 席が足りない |
User | gigime |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 1247 Byte |
Status | AC |
Exec Time | 285 ms |
Memory | 384 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:18:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&N); ^ ./Main.cpp:21:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%02d:%02d %02d:%02d",&p,&q,&r,&s); ^
Judge Result
Set Name | small1 | small2 | large | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 20 / 20 | 30 / 30 | 50 / 50 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
small1 | small1/00_sample1, small1/10_input00, small1/10_input01, small1/10_input02, small1/10_input03, small1/10_input04, small1/10_input05, small1/10_input06, small1/10_input07, small1/10_input08, small1/10_input09, small1/10_input10, small1/10_input11, small1/10_input12, small1/10_input13, small1/10_input14, small1/10_input15, small1/10_input16, small1/10_input17, small1/10_input18, small1/10_input19, small2/50_sample2, small2/50_sample3, small2/60_input41, small2/60_input42, small2/60_input43, small2/60_input44, small2/60_input45, small2/60_input46, small2/60_input47, small2/60_input48, small2/60_input49, small2/60_input50, small2/60_input51, small2/60_input52, small2/60_input53, small2/60_input54, small2/60_input55, small2/60_input56, small2/60_input57, small2/60_input58, small2/60_input59, small2/60_input60, small2/60_input61, small2/60_input62 |
small2 | small1/00_sample1, small1/10_input00, small1/10_input01, small1/10_input02, small1/10_input03, small1/10_input04, small1/10_input05, small1/10_input06, small1/10_input07, small1/10_input08, small1/10_input09, small1/10_input10, small1/10_input11, small1/10_input12, small1/10_input13, small1/10_input14, small1/10_input15, small1/10_input16, small1/10_input17, small1/10_input18, small1/10_input19, large1/20_input20, large1/20_input21, large1/20_input22, large1/20_input23, large1/20_input24, large1/20_input25, large1/20_input26, large1/20_input27, large1/20_input28, large1/20_input29, large1/20_input30, large1/20_input31, large1/20_input32, large1/20_input33, large1/20_input34, large1/20_input35, large1/20_input36, large1/20_input37, large1/20_input38, large1/20_input39, large1/20_input40 |
large | small1/00_sample1, small1/10_input00, small1/10_input01, small1/10_input02, small1/10_input03, small1/10_input04, small1/10_input05, small1/10_input06, small1/10_input07, small1/10_input08, small1/10_input09, small1/10_input10, small1/10_input11, small1/10_input12, small1/10_input13, small1/10_input14, small1/10_input15, small1/10_input16, small1/10_input17, small1/10_input18, small1/10_input19, small2/50_sample2, small2/50_sample3, small2/60_input41, small2/60_input42, small2/60_input43, small2/60_input44, small2/60_input45, small2/60_input46, small2/60_input47, small2/60_input48, small2/60_input49, small2/60_input50, small2/60_input51, small2/60_input52, small2/60_input53, small2/60_input54, small2/60_input55, small2/60_input56, small2/60_input57, small2/60_input58, small2/60_input59, small2/60_input60, small2/60_input61, small2/60_input62, large1/20_input20, large1/20_input21, large1/20_input22, large1/20_input23, large1/20_input24, large1/20_input25, large1/20_input26, large1/20_input27, large1/20_input28, large1/20_input29, large1/20_input30, large1/20_input31, large1/20_input32, large1/20_input33, large1/20_input34, large1/20_input35, large1/20_input36, large1/20_input37, large1/20_input38, large1/20_input39, large1/20_input40, large2/70_input61, large2/70_input62, large2/70_input63, large2/70_input64, large2/70_input65, large2/70_input66, large2/70_input67, large2/70_input68, large2/70_input69, large2/70_input70, large2/70_input71, large2/70_input72, large2/70_input73, large2/70_input74, large2/70_input75, large2/70_input76, large2/70_input77, large2/70_input78, large2/70_input79, large2/70_input80, large2/70_input81, large2/70_input82 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
large1/20_input20 | AC | 5 ms | 256 KB |
large1/20_input21 | AC | 9 ms | 256 KB |
large1/20_input22 | AC | 17 ms | 256 KB |
large1/20_input23 | AC | 33 ms | 256 KB |
large1/20_input24 | AC | 67 ms | 256 KB |
large1/20_input25 | AC | 136 ms | 384 KB |
large1/20_input26 | AC | 269 ms | 384 KB |
large1/20_input27 | AC | 5 ms | 256 KB |
large1/20_input28 | AC | 9 ms | 256 KB |
large1/20_input29 | AC | 17 ms | 256 KB |
large1/20_input30 | AC | 33 ms | 256 KB |
large1/20_input31 | AC | 67 ms | 256 KB |
large1/20_input32 | AC | 133 ms | 384 KB |
large1/20_input33 | AC | 272 ms | 384 KB |
large1/20_input34 | AC | 5 ms | 256 KB |
large1/20_input35 | AC | 9 ms | 256 KB |
large1/20_input36 | AC | 17 ms | 256 KB |
large1/20_input37 | AC | 33 ms | 256 KB |
large1/20_input38 | AC | 66 ms | 256 KB |
large1/20_input39 | AC | 133 ms | 384 KB |
large1/20_input40 | AC | 271 ms | 384 KB |
large2/70_input61 | AC | 5 ms | 256 KB |
large2/70_input62 | AC | 9 ms | 256 KB |
large2/70_input63 | AC | 17 ms | 256 KB |
large2/70_input64 | AC | 34 ms | 256 KB |
large2/70_input65 | AC | 67 ms | 256 KB |
large2/70_input66 | AC | 136 ms | 384 KB |
large2/70_input67 | AC | 275 ms | 384 KB |
large2/70_input68 | AC | 5 ms | 256 KB |
large2/70_input69 | AC | 9 ms | 256 KB |
large2/70_input70 | AC | 17 ms | 256 KB |
large2/70_input71 | AC | 34 ms | 256 KB |
large2/70_input72 | AC | 66 ms | 256 KB |
large2/70_input73 | AC | 133 ms | 384 KB |
large2/70_input74 | AC | 273 ms | 384 KB |
large2/70_input75 | AC | 5 ms | 256 KB |
large2/70_input76 | AC | 9 ms | 256 KB |
large2/70_input77 | AC | 17 ms | 256 KB |
large2/70_input78 | AC | 34 ms | 256 KB |
large2/70_input79 | AC | 67 ms | 256 KB |
large2/70_input80 | AC | 134 ms | 384 KB |
large2/70_input81 | AC | 272 ms | 384 KB |
large2/70_input82 | AC | 285 ms | 384 KB |
small1/00_sample1 | AC | 1 ms | 256 KB |
small1/10_input00 | AC | 1 ms | 256 KB |
small1/10_input01 | AC | 1 ms | 256 KB |
small1/10_input02 | AC | 2 ms | 256 KB |
small1/10_input03 | AC | 2 ms | 256 KB |
small1/10_input04 | AC | 2 ms | 256 KB |
small1/10_input05 | AC | 1 ms | 256 KB |
small1/10_input06 | AC | 1 ms | 256 KB |
small1/10_input07 | AC | 3 ms | 256 KB |
small1/10_input08 | AC | 3 ms | 256 KB |
small1/10_input09 | AC | 2 ms | 256 KB |
small1/10_input10 | AC | 1 ms | 256 KB |
small1/10_input11 | AC | 1 ms | 256 KB |
small1/10_input12 | AC | 1 ms | 256 KB |
small1/10_input13 | AC | 1 ms | 256 KB |
small1/10_input14 | AC | 1 ms | 256 KB |
small1/10_input15 | AC | 1 ms | 256 KB |
small1/10_input16 | AC | 2 ms | 256 KB |
small1/10_input17 | AC | 1 ms | 256 KB |
small1/10_input18 | AC | 2 ms | 256 KB |
small1/10_input19 | AC | 2 ms | 256 KB |
small2/50_sample2 | AC | 1 ms | 256 KB |
small2/50_sample3 | AC | 1 ms | 256 KB |
small2/60_input41 | AC | 1 ms | 256 KB |
small2/60_input42 | AC | 1 ms | 256 KB |
small2/60_input43 | AC | 1 ms | 256 KB |
small2/60_input44 | AC | 1 ms | 256 KB |
small2/60_input45 | AC | 2 ms | 256 KB |
small2/60_input46 | AC | 1 ms | 256 KB |
small2/60_input47 | AC | 2 ms | 256 KB |
small2/60_input48 | AC | 2 ms | 256 KB |
small2/60_input49 | AC | 1 ms | 256 KB |
small2/60_input50 | AC | 2 ms | 256 KB |
small2/60_input51 | AC | 1 ms | 256 KB |
small2/60_input52 | AC | 2 ms | 256 KB |
small2/60_input53 | AC | 1 ms | 256 KB |
small2/60_input54 | AC | 2 ms | 256 KB |
small2/60_input55 | AC | 1 ms | 256 KB |
small2/60_input56 | AC | 1 ms | 256 KB |
small2/60_input57 | AC | 1 ms | 256 KB |
small2/60_input58 | AC | 1 ms | 256 KB |
small2/60_input59 | AC | 1 ms | 256 KB |
small2/60_input60 | AC | 1 ms | 256 KB |
small2/60_input61 | AC | 2 ms | 256 KB |
small2/60_input62 | AC | 2 ms | 256 KB |