답안 #1059105

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059105 2024-08-14T17:19:03 Z byunjaewoo Bring Down the Grading Server (CEOI23_gradingserver) C++17
100 / 100
2919 ms 124424 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

int S, Q;
map<pair<int, pair<int, int>>, int> X[2];
map<pair<int, pair<int, int>>, bool> chk[2];

bool F(int a1, int f1, int a2, int f2, int p) {
    if(a2<=-f1*S) return true;
    if(a1<=-f2*S) return false;
    int c1=a1+f2*S, c2=a2+f1*S, b1=S-a1, b2=S-a2;
    if(a1>=S && a2<S) return true;
    if(a1<=0 && a2>=S) return false;
    if(a1>0 && a2>=S) return !F(a2-a1, f2, a1, f1, 1-p);
    if(a1<=0 && a2<=0) {
        int tmp=min({f1, f2, (-a1)/S+1, (-a2)/S+1});
        return F(a1+S*tmp, f1-tmp, a2+S*tmp, f2-tmp, p);
    }
    if(a1<=0 && 0<a2 && a2<S) {
        if(!f2) return false;
        if(!f1) {
            int tmp=(-a1)/b2+1;
            if(f2>=tmp) return F(a1+tmp*b2, f1, a2, f2-tmp, p);
            return false;
        }
        return !F(a2, f2-1, a1+S, f1, 1-p);
    }
    if(0<a1 && a1<S && a2<=0) {
        if(!f2) return !F(a2-a1, f2, a1, f1, 1-p);
        return true;
    }
    if(!f2) return !F(a2-a1, f2, a1, f1, 1-p);
    if(b2*f2>=b1) return true;
    if(a2-a1+b1*f1>=S) {
        int tmp=min(f2, (b1*f1-a1+a2-S)/(b2*(f1+1))+1);
        return F(a1+b2*tmp,f1,a2,f2-tmp,p);
    }
    if(f1>=8*S || f2>=8*S) return true;
    if(b2*max(1ll, f1)*f2>=(8*S)/f2) return true;
    if(chk[p][{f1, {b2, f2}}]) return c1>=X[p][{f1, {b2, f2}}];
    chk[p][{f1, {b2, f2}}]=true;
    int tmp=1e17;
    for(int s=0, e=1e12; s<=e; ) {
        int _c1=(s+e)/2;
        if(F(a2, f2-1, (_c1-S*f2)+S, f1, 1-p) && F(a2-(_c1-S*f2), f2, (_c1-S*f2), f1, 1-p)) s=_c1+1;
        else tmp=_c1, e=_c1-1;
    }
    X[p][{f1, {b2, f2}}]=tmp;
    return c1>=tmp;
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>S>>Q;
    while(Q--) {
        int c1, f1, c2, f2; cin>>c1>>f1>>c2>>f2;
        if(F(c1-f2*S, f1, c2-f1*S, f2, 0)) cout<<"YES\n";
        else cout<<"NO\n";
    }
    return 0;
}

Compilation message

gradingserver.cpp: In function 'bool F(long long int, long long int, long long int, long long int, long long int)':
gradingserver.cpp:12:21: warning: unused variable 'c2' [-Wunused-variable]
   12 |     int c1=a1+f2*S, c2=a2+f1*S, b1=S-a1, b2=S-a2;
      |                     ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 38 ms 3088 KB Output is correct
3 Correct 41 ms 3052 KB Output is correct
4 Correct 41 ms 2948 KB Output is correct
5 Correct 39 ms 2900 KB Output is correct
6 Correct 41 ms 2640 KB Output is correct
7 Correct 49 ms 2764 KB Output is correct
8 Correct 40 ms 2644 KB Output is correct
9 Correct 38 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 38 ms 3088 KB Output is correct
3 Correct 41 ms 3052 KB Output is correct
4 Correct 41 ms 2948 KB Output is correct
5 Correct 39 ms 2900 KB Output is correct
6 Correct 41 ms 2640 KB Output is correct
7 Correct 49 ms 2764 KB Output is correct
8 Correct 40 ms 2644 KB Output is correct
9 Correct 38 ms 2644 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 39 ms 2772 KB Output is correct
12 Correct 38 ms 2896 KB Output is correct
13 Correct 46 ms 2964 KB Output is correct
14 Correct 41 ms 2868 KB Output is correct
15 Correct 42 ms 2692 KB Output is correct
16 Correct 41 ms 2640 KB Output is correct
17 Correct 45 ms 3036 KB Output is correct
18 Correct 38 ms 2616 KB Output is correct
19 Correct 41 ms 3152 KB Output is correct
20 Correct 49 ms 3048 KB Output is correct
21 Correct 63 ms 3652 KB Output is correct
22 Correct 48 ms 3156 KB Output is correct
23 Correct 44 ms 3152 KB Output is correct
24 Correct 49 ms 3100 KB Output is correct
25 Correct 46 ms 3404 KB Output is correct
26 Correct 41 ms 3372 KB Output is correct
27 Correct 42 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 8076 KB Output is correct
2 Correct 83 ms 7448 KB Output is correct
3 Correct 90 ms 8132 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 38 ms 3088 KB Output is correct
3 Correct 41 ms 3052 KB Output is correct
4 Correct 41 ms 2948 KB Output is correct
5 Correct 39 ms 2900 KB Output is correct
6 Correct 41 ms 2640 KB Output is correct
7 Correct 49 ms 2764 KB Output is correct
8 Correct 40 ms 2644 KB Output is correct
9 Correct 38 ms 2644 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 39 ms 2772 KB Output is correct
12 Correct 38 ms 2896 KB Output is correct
13 Correct 46 ms 2964 KB Output is correct
14 Correct 41 ms 2868 KB Output is correct
15 Correct 42 ms 2692 KB Output is correct
16 Correct 41 ms 2640 KB Output is correct
17 Correct 45 ms 3036 KB Output is correct
18 Correct 38 ms 2616 KB Output is correct
19 Correct 41 ms 3152 KB Output is correct
20 Correct 49 ms 3048 KB Output is correct
21 Correct 63 ms 3652 KB Output is correct
22 Correct 48 ms 3156 KB Output is correct
23 Correct 44 ms 3152 KB Output is correct
24 Correct 49 ms 3100 KB Output is correct
25 Correct 46 ms 3404 KB Output is correct
26 Correct 41 ms 3372 KB Output is correct
27 Correct 42 ms 3412 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 43 ms 2792 KB Output is correct
30 Correct 43 ms 3076 KB Output is correct
31 Correct 58 ms 2984 KB Output is correct
32 Correct 55 ms 2904 KB Output is correct
33 Correct 48 ms 2684 KB Output is correct
34 Correct 55 ms 2796 KB Output is correct
35 Correct 54 ms 2616 KB Output is correct
36 Correct 38 ms 2900 KB Output is correct
37 Correct 44 ms 3140 KB Output is correct
38 Correct 44 ms 2888 KB Output is correct
39 Correct 49 ms 3376 KB Output is correct
40 Correct 47 ms 3252 KB Output is correct
41 Correct 44 ms 3152 KB Output is correct
42 Correct 44 ms 3000 KB Output is correct
43 Correct 48 ms 3416 KB Output is correct
44 Correct 40 ms 3408 KB Output is correct
45 Correct 40 ms 3412 KB Output is correct
46 Correct 65 ms 3924 KB Output is correct
47 Correct 46 ms 3868 KB Output is correct
48 Correct 60 ms 3672 KB Output is correct
49 Correct 57 ms 3904 KB Output is correct
50 Correct 58 ms 4180 KB Output is correct
51 Correct 68 ms 3924 KB Output is correct
52 Correct 61 ms 3412 KB Output is correct
53 Correct 39 ms 3412 KB Output is correct
54 Correct 51 ms 3560 KB Output is correct
55 Correct 53 ms 3924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 38 ms 3088 KB Output is correct
3 Correct 41 ms 3052 KB Output is correct
4 Correct 41 ms 2948 KB Output is correct
5 Correct 39 ms 2900 KB Output is correct
6 Correct 41 ms 2640 KB Output is correct
7 Correct 49 ms 2764 KB Output is correct
8 Correct 40 ms 2644 KB Output is correct
9 Correct 38 ms 2644 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 39 ms 2772 KB Output is correct
12 Correct 38 ms 2896 KB Output is correct
13 Correct 46 ms 2964 KB Output is correct
14 Correct 41 ms 2868 KB Output is correct
15 Correct 42 ms 2692 KB Output is correct
16 Correct 41 ms 2640 KB Output is correct
17 Correct 45 ms 3036 KB Output is correct
18 Correct 38 ms 2616 KB Output is correct
19 Correct 41 ms 3152 KB Output is correct
20 Correct 49 ms 3048 KB Output is correct
21 Correct 63 ms 3652 KB Output is correct
22 Correct 48 ms 3156 KB Output is correct
23 Correct 44 ms 3152 KB Output is correct
24 Correct 49 ms 3100 KB Output is correct
25 Correct 46 ms 3404 KB Output is correct
26 Correct 41 ms 3372 KB Output is correct
27 Correct 42 ms 3412 KB Output is correct
28 Correct 82 ms 8076 KB Output is correct
29 Correct 83 ms 7448 KB Output is correct
30 Correct 90 ms 8132 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 72 ms 7744 KB Output is correct
33 Correct 73 ms 7152 KB Output is correct
34 Correct 79 ms 7860 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 38 ms 2728 KB Output is correct
38 Correct 39 ms 2980 KB Output is correct
39 Correct 42 ms 2904 KB Output is correct
40 Correct 46 ms 2896 KB Output is correct
41 Correct 45 ms 2644 KB Output is correct
42 Correct 40 ms 2640 KB Output is correct
43 Correct 40 ms 2640 KB Output is correct
44 Correct 39 ms 2808 KB Output is correct
45 Correct 43 ms 3180 KB Output is correct
46 Correct 44 ms 2896 KB Output is correct
47 Correct 49 ms 3424 KB Output is correct
48 Correct 44 ms 3152 KB Output is correct
49 Correct 46 ms 3196 KB Output is correct
50 Correct 44 ms 3124 KB Output is correct
51 Correct 46 ms 3400 KB Output is correct
52 Correct 40 ms 3408 KB Output is correct
53 Correct 40 ms 3412 KB Output is correct
54 Correct 0 ms 344 KB Output is correct
55 Correct 40 ms 3432 KB Output is correct
56 Correct 45 ms 3408 KB Output is correct
57 Correct 63 ms 3968 KB Output is correct
58 Correct 45 ms 3736 KB Output is correct
59 Correct 63 ms 3720 KB Output is correct
60 Correct 75 ms 7556 KB Output is correct
61 Correct 79 ms 7508 KB Output is correct
62 Correct 75 ms 7536 KB Output is correct
63 Correct 73 ms 7704 KB Output is correct
64 Correct 75 ms 7464 KB Output is correct
65 Correct 75 ms 7508 KB Output is correct
66 Correct 53 ms 3664 KB Output is correct
67 Correct 48 ms 3716 KB Output is correct
68 Correct 72 ms 7760 KB Output is correct
69 Correct 84 ms 7520 KB Output is correct
70 Correct 124 ms 7032 KB Output is correct
71 Correct 130 ms 5712 KB Output is correct
72 Correct 86 ms 8040 KB Output is correct
73 Correct 60 ms 5052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 38 ms 3088 KB Output is correct
3 Correct 41 ms 3052 KB Output is correct
4 Correct 41 ms 2948 KB Output is correct
5 Correct 39 ms 2900 KB Output is correct
6 Correct 41 ms 2640 KB Output is correct
7 Correct 49 ms 2764 KB Output is correct
8 Correct 40 ms 2644 KB Output is correct
9 Correct 38 ms 2644 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 37 ms 2604 KB Output is correct
12 Correct 42 ms 2896 KB Output is correct
13 Correct 41 ms 2896 KB Output is correct
14 Correct 42 ms 2896 KB Output is correct
15 Correct 41 ms 2868 KB Output is correct
16 Correct 45 ms 2776 KB Output is correct
17 Correct 39 ms 2820 KB Output is correct
18 Correct 38 ms 2744 KB Output is correct
19 Correct 55 ms 3992 KB Output is correct
20 Correct 459 ms 24256 KB Output is correct
21 Correct 2297 ms 91732 KB Output is correct
22 Correct 2919 ms 108412 KB Output is correct
23 Correct 1008 ms 52400 KB Output is correct
24 Correct 1315 ms 61776 KB Output is correct
25 Correct 242 ms 16464 KB Output is correct
26 Correct 89 ms 5288 KB Output is correct
27 Correct 2032 ms 80004 KB Output is correct
28 Correct 925 ms 47188 KB Output is correct
29 Correct 942 ms 48424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 38 ms 3088 KB Output is correct
3 Correct 41 ms 3052 KB Output is correct
4 Correct 41 ms 2948 KB Output is correct
5 Correct 39 ms 2900 KB Output is correct
6 Correct 41 ms 2640 KB Output is correct
7 Correct 49 ms 2764 KB Output is correct
8 Correct 40 ms 2644 KB Output is correct
9 Correct 38 ms 2644 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 39 ms 2772 KB Output is correct
12 Correct 38 ms 2896 KB Output is correct
13 Correct 46 ms 2964 KB Output is correct
14 Correct 41 ms 2868 KB Output is correct
15 Correct 42 ms 2692 KB Output is correct
16 Correct 41 ms 2640 KB Output is correct
17 Correct 45 ms 3036 KB Output is correct
18 Correct 38 ms 2616 KB Output is correct
19 Correct 41 ms 3152 KB Output is correct
20 Correct 49 ms 3048 KB Output is correct
21 Correct 63 ms 3652 KB Output is correct
22 Correct 48 ms 3156 KB Output is correct
23 Correct 44 ms 3152 KB Output is correct
24 Correct 49 ms 3100 KB Output is correct
25 Correct 46 ms 3404 KB Output is correct
26 Correct 41 ms 3372 KB Output is correct
27 Correct 42 ms 3412 KB Output is correct
28 Correct 82 ms 8076 KB Output is correct
29 Correct 83 ms 7448 KB Output is correct
30 Correct 90 ms 8132 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 43 ms 2792 KB Output is correct
34 Correct 43 ms 3076 KB Output is correct
35 Correct 58 ms 2984 KB Output is correct
36 Correct 55 ms 2904 KB Output is correct
37 Correct 48 ms 2684 KB Output is correct
38 Correct 55 ms 2796 KB Output is correct
39 Correct 54 ms 2616 KB Output is correct
40 Correct 38 ms 2900 KB Output is correct
41 Correct 44 ms 3140 KB Output is correct
42 Correct 44 ms 2888 KB Output is correct
43 Correct 49 ms 3376 KB Output is correct
44 Correct 47 ms 3252 KB Output is correct
45 Correct 44 ms 3152 KB Output is correct
46 Correct 44 ms 3000 KB Output is correct
47 Correct 48 ms 3416 KB Output is correct
48 Correct 40 ms 3408 KB Output is correct
49 Correct 40 ms 3412 KB Output is correct
50 Correct 65 ms 3924 KB Output is correct
51 Correct 46 ms 3868 KB Output is correct
52 Correct 60 ms 3672 KB Output is correct
53 Correct 57 ms 3904 KB Output is correct
54 Correct 58 ms 4180 KB Output is correct
55 Correct 68 ms 3924 KB Output is correct
56 Correct 61 ms 3412 KB Output is correct
57 Correct 39 ms 3412 KB Output is correct
58 Correct 51 ms 3560 KB Output is correct
59 Correct 53 ms 3924 KB Output is correct
60 Correct 72 ms 7744 KB Output is correct
61 Correct 73 ms 7152 KB Output is correct
62 Correct 79 ms 7860 KB Output is correct
63 Correct 0 ms 344 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 38 ms 2728 KB Output is correct
66 Correct 39 ms 2980 KB Output is correct
67 Correct 42 ms 2904 KB Output is correct
68 Correct 46 ms 2896 KB Output is correct
69 Correct 45 ms 2644 KB Output is correct
70 Correct 40 ms 2640 KB Output is correct
71 Correct 40 ms 2640 KB Output is correct
72 Correct 39 ms 2808 KB Output is correct
73 Correct 43 ms 3180 KB Output is correct
74 Correct 44 ms 2896 KB Output is correct
75 Correct 49 ms 3424 KB Output is correct
76 Correct 44 ms 3152 KB Output is correct
77 Correct 46 ms 3196 KB Output is correct
78 Correct 44 ms 3124 KB Output is correct
79 Correct 46 ms 3400 KB Output is correct
80 Correct 40 ms 3408 KB Output is correct
81 Correct 40 ms 3412 KB Output is correct
82 Correct 0 ms 344 KB Output is correct
83 Correct 40 ms 3432 KB Output is correct
84 Correct 45 ms 3408 KB Output is correct
85 Correct 63 ms 3968 KB Output is correct
86 Correct 45 ms 3736 KB Output is correct
87 Correct 63 ms 3720 KB Output is correct
88 Correct 75 ms 7556 KB Output is correct
89 Correct 79 ms 7508 KB Output is correct
90 Correct 75 ms 7536 KB Output is correct
91 Correct 73 ms 7704 KB Output is correct
92 Correct 75 ms 7464 KB Output is correct
93 Correct 75 ms 7508 KB Output is correct
94 Correct 53 ms 3664 KB Output is correct
95 Correct 48 ms 3716 KB Output is correct
96 Correct 72 ms 7760 KB Output is correct
97 Correct 84 ms 7520 KB Output is correct
98 Correct 124 ms 7032 KB Output is correct
99 Correct 130 ms 5712 KB Output is correct
100 Correct 86 ms 8040 KB Output is correct
101 Correct 60 ms 5052 KB Output is correct
102 Correct 0 ms 344 KB Output is correct
103 Correct 37 ms 2604 KB Output is correct
104 Correct 42 ms 2896 KB Output is correct
105 Correct 41 ms 2896 KB Output is correct
106 Correct 42 ms 2896 KB Output is correct
107 Correct 41 ms 2868 KB Output is correct
108 Correct 45 ms 2776 KB Output is correct
109 Correct 39 ms 2820 KB Output is correct
110 Correct 38 ms 2744 KB Output is correct
111 Correct 55 ms 3992 KB Output is correct
112 Correct 459 ms 24256 KB Output is correct
113 Correct 2297 ms 91732 KB Output is correct
114 Correct 2919 ms 108412 KB Output is correct
115 Correct 1008 ms 52400 KB Output is correct
116 Correct 1315 ms 61776 KB Output is correct
117 Correct 242 ms 16464 KB Output is correct
118 Correct 89 ms 5288 KB Output is correct
119 Correct 2032 ms 80004 KB Output is correct
120 Correct 925 ms 47188 KB Output is correct
121 Correct 942 ms 48424 KB Output is correct
122 Correct 79 ms 7764 KB Output is correct
123 Correct 69 ms 7004 KB Output is correct
124 Correct 78 ms 7792 KB Output is correct
125 Correct 0 ms 344 KB Output is correct
126 Correct 0 ms 348 KB Output is correct
127 Correct 39 ms 2704 KB Output is correct
128 Correct 38 ms 2952 KB Output is correct
129 Correct 41 ms 3060 KB Output is correct
130 Correct 39 ms 2900 KB Output is correct
131 Correct 42 ms 2816 KB Output is correct
132 Correct 39 ms 2644 KB Output is correct
133 Correct 43 ms 2648 KB Output is correct
134 Correct 38 ms 2640 KB Output is correct
135 Correct 42 ms 3156 KB Output is correct
136 Correct 45 ms 2900 KB Output is correct
137 Correct 50 ms 3412 KB Output is correct
138 Correct 55 ms 3156 KB Output is correct
139 Correct 49 ms 3232 KB Output is correct
140 Correct 47 ms 3164 KB Output is correct
141 Correct 68 ms 3408 KB Output is correct
142 Correct 41 ms 3276 KB Output is correct
143 Correct 62 ms 3316 KB Output is correct
144 Correct 0 ms 348 KB Output is correct
145 Correct 40 ms 3312 KB Output is correct
146 Correct 86 ms 3468 KB Output is correct
147 Correct 63 ms 3904 KB Output is correct
148 Correct 48 ms 3856 KB Output is correct
149 Correct 67 ms 3700 KB Output is correct
150 Correct 99 ms 7540 KB Output is correct
151 Correct 81 ms 7696 KB Output is correct
152 Correct 80 ms 7380 KB Output is correct
153 Correct 79 ms 7680 KB Output is correct
154 Correct 92 ms 7236 KB Output is correct
155 Correct 90 ms 7504 KB Output is correct
156 Correct 47 ms 3516 KB Output is correct
157 Correct 47 ms 3564 KB Output is correct
158 Correct 75 ms 7764 KB Output is correct
159 Correct 90 ms 7652 KB Output is correct
160 Correct 124 ms 7248 KB Output is correct
161 Correct 112 ms 5912 KB Output is correct
162 Correct 88 ms 8100 KB Output is correct
163 Correct 59 ms 4944 KB Output is correct
164 Correct 50 ms 3668 KB Output is correct
165 Correct 56 ms 4180 KB Output is correct
166 Correct 67 ms 3920 KB Output is correct
167 Correct 62 ms 3408 KB Output is correct
168 Correct 53 ms 3832 KB Output is correct
169 Correct 53 ms 3928 KB Output is correct
170 Correct 442 ms 24108 KB Output is correct
171 Correct 2273 ms 91728 KB Output is correct
172 Correct 2878 ms 108468 KB Output is correct
173 Correct 1056 ms 52396 KB Output is correct
174 Correct 1321 ms 61796 KB Output is correct
175 Correct 246 ms 16464 KB Output is correct
176 Correct 88 ms 5284 KB Output is correct
177 Correct 1972 ms 79904 KB Output is correct
178 Correct 928 ms 47304 KB Output is correct
179 Correct 923 ms 48352 KB Output is correct
180 Correct 83 ms 8260 KB Output is correct
181 Correct 101 ms 9688 KB Output is correct
182 Correct 225 ms 18004 KB Output is correct
183 Correct 170 ms 15236 KB Output is correct
184 Correct 147 ms 13392 KB Output is correct
185 Correct 417 ms 24404 KB Output is correct
186 Correct 1654 ms 75088 KB Output is correct
187 Correct 2795 ms 124424 KB Output is correct
188 Correct 2082 ms 100544 KB Output is correct
189 Correct 943 ms 69204 KB Output is correct
190 Correct 1375 ms 77976 KB Output is correct
191 Correct 1406 ms 77396 KB Output is correct