제출 #1231807

#제출 시각아이디문제언어결과실행 시간메모리
1231807Tenis0206Bring Down the Grading Server (CEOI23_gradingserver)C++20
20 / 100
4107 ms1114112 KiB
#include <bits/stdc++.h> #define int long long using namespace std; map<pair<pair<int,int>,pair<int,int>>, bool> dp, sel; int s, q; bool solve(int C, int F, int c, int f) { if(C <= 0) { return false; } if(C <= s * f && c <= s * F) { int D = f - (C - 1) / s; int d = F - (c - 1) / s; if(D <= d) { return solve(C, F - D, c, f - D); } else { return !solve(c, f - d - 1, C, F - d); } } if(C - s * f >= 0 && c - s * F <= 0 && f > 0) { return true; } if(sel[{{C, F}, {c,f}}]) { return dp[{{C, F}, {c,f}}]; } sel[{{C, F}, {c,f}}] = true; dp[{{C, F}, {c,f}}] = false; /*if(C - f * s > s - 1) { dp[{{C, F}, {c,f}}] = !solve(c - (C - f * s), f, C, F); } else { dp[{{C, F}, {c,f}}] = !solve(c, f - 1, C, F); }*/ if(C > f * s && C < (f + 1) * s) { if(C - f * s > 0 && !solve(c - (C - f * s), f, C, F)) { dp[{{C, F}, {c,f}}] = true; } else if(f > 0 && !solve(c, f - 1, C, F)) { dp[{{C, F}, {c,f}}] = true; } } else { if(C - f * s > 0) { dp[{{C, F}, {c,f}}] = !solve(c - (C - f * s), f, C, F); } else if(f > 0) { dp[{{C, F}, {c,f}}] = !solve(c, f - 1, C, F); } } /*if(C - f * s > 0 && dp[{{C, F}, {c,f}}] != !solve(c - (C - f * s), f, C, F) && C != f * s + 1 && C != f * s + 2) { cerr<<C<<' '<<F<<' '<<c<<' '<<f<<'\n'; }*/ /*if(f > 0 && dp[{{C, F}, {c,f}}] != !solve(c, f - 1, C, F) && C > f * s && C < (f + 1) * s) { cerr<<C<<' '<<F<<' '<<c<<' '<<f<<'\n'; }*/ return dp[{{C, F}, {c,f}}]; } bool solve1(int C, int F, int c, int f) { if(C <= 0) { return false; } if(C <= f && c <= F) { if(f - C <= F - c) { return true; } return false; } if(C <= f) { return false; } return (!solve1(c - (C - f), f, C, F)); } signed main() { ios::sync_with_stdio(false); cin.tie(0); #ifdef home freopen("nr.in","r",stdin); freopen("nr.out","w",stdout); #endif // home cin>>s>>q; for(int i=1; i<=q; i++) { int ch, fh, cg, fg; cin>>ch>>fh>>cg>>fg; bool ok; if(s == 1) { ok = solve1(ch, fh, cg, fg); } else { ok = solve(ch, fh, cg, fg); } if(ok) { cout<<"YES\n"; } else { cout<<"NO\n"; } } return 0; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...