답안 #1059101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059101 2024-08-14T17:13:50 Z byunjaewoo Bring Down the Grading Server (CEOI23_gradingserver) C++17
100 / 100
3061 ms 132248 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>=11*S || f2>=11*S) return true;
    if(b2*max(1ll, f1)*f2>=(11*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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 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 36 ms 1072 KB Output is correct
3 Correct 37 ms 1068 KB Output is correct
4 Correct 40 ms 1104 KB Output is correct
5 Correct 37 ms 1104 KB Output is correct
6 Correct 40 ms 1116 KB Output is correct
7 Correct 39 ms 1116 KB Output is correct
8 Correct 39 ms 1172 KB Output is correct
9 Correct 35 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 36 ms 1072 KB Output is correct
3 Correct 37 ms 1068 KB Output is correct
4 Correct 40 ms 1104 KB Output is correct
5 Correct 37 ms 1104 KB Output is correct
6 Correct 40 ms 1116 KB Output is correct
7 Correct 39 ms 1116 KB Output is correct
8 Correct 39 ms 1172 KB Output is correct
9 Correct 35 ms 1108 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 39 ms 1280 KB Output is correct
12 Correct 37 ms 1212 KB Output is correct
13 Correct 45 ms 1220 KB Output is correct
14 Correct 37 ms 1116 KB Output is correct
15 Correct 40 ms 1104 KB Output is correct
16 Correct 39 ms 1112 KB Output is correct
17 Correct 38 ms 1104 KB Output is correct
18 Correct 36 ms 1104 KB Output is correct
19 Correct 40 ms 1116 KB Output is correct
20 Correct 41 ms 1108 KB Output is correct
21 Correct 48 ms 2640 KB Output is correct
22 Correct 46 ms 4764 KB Output is correct
23 Correct 42 ms 4672 KB Output is correct
24 Correct 43 ms 4440 KB Output is correct
25 Correct 53 ms 4696 KB Output is correct
26 Correct 39 ms 4688 KB Output is correct
27 Correct 45 ms 4656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 1104 KB Output is correct
2 Correct 76 ms 1236 KB Output is correct
3 Correct 70 ms 1120 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 36 ms 1072 KB Output is correct
3 Correct 37 ms 1068 KB Output is correct
4 Correct 40 ms 1104 KB Output is correct
5 Correct 37 ms 1104 KB Output is correct
6 Correct 40 ms 1116 KB Output is correct
7 Correct 39 ms 1116 KB Output is correct
8 Correct 39 ms 1172 KB Output is correct
9 Correct 35 ms 1108 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 39 ms 1280 KB Output is correct
12 Correct 37 ms 1212 KB Output is correct
13 Correct 45 ms 1220 KB Output is correct
14 Correct 37 ms 1116 KB Output is correct
15 Correct 40 ms 1104 KB Output is correct
16 Correct 39 ms 1112 KB Output is correct
17 Correct 38 ms 1104 KB Output is correct
18 Correct 36 ms 1104 KB Output is correct
19 Correct 40 ms 1116 KB Output is correct
20 Correct 41 ms 1108 KB Output is correct
21 Correct 48 ms 2640 KB Output is correct
22 Correct 46 ms 4764 KB Output is correct
23 Correct 42 ms 4672 KB Output is correct
24 Correct 43 ms 4440 KB Output is correct
25 Correct 53 ms 4696 KB Output is correct
26 Correct 39 ms 4688 KB Output is correct
27 Correct 45 ms 4656 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 38 ms 3924 KB Output is correct
30 Correct 38 ms 3920 KB Output is correct
31 Correct 40 ms 4156 KB Output is correct
32 Correct 39 ms 3924 KB Output is correct
33 Correct 41 ms 3920 KB Output is correct
34 Correct 40 ms 3920 KB Output is correct
35 Correct 39 ms 4076 KB Output is correct
36 Correct 45 ms 3920 KB Output is correct
37 Correct 50 ms 4616 KB Output is correct
38 Correct 42 ms 4436 KB Output is correct
39 Correct 49 ms 4944 KB Output is correct
40 Correct 43 ms 4692 KB Output is correct
41 Correct 42 ms 4688 KB Output is correct
42 Correct 47 ms 4432 KB Output is correct
43 Correct 45 ms 4572 KB Output is correct
44 Correct 41 ms 4688 KB Output is correct
45 Correct 40 ms 4648 KB Output is correct
46 Correct 80 ms 5712 KB Output is correct
47 Correct 46 ms 5712 KB Output is correct
48 Correct 60 ms 5540 KB Output is correct
49 Correct 48 ms 5544 KB Output is correct
50 Correct 59 ms 6224 KB Output is correct
51 Correct 70 ms 5972 KB Output is correct
52 Correct 61 ms 4944 KB Output is correct
53 Correct 41 ms 4948 KB Output is correct
54 Correct 46 ms 4944 KB Output is correct
55 Correct 52 ms 5968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 36 ms 1072 KB Output is correct
3 Correct 37 ms 1068 KB Output is correct
4 Correct 40 ms 1104 KB Output is correct
5 Correct 37 ms 1104 KB Output is correct
6 Correct 40 ms 1116 KB Output is correct
7 Correct 39 ms 1116 KB Output is correct
8 Correct 39 ms 1172 KB Output is correct
9 Correct 35 ms 1108 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 39 ms 1280 KB Output is correct
12 Correct 37 ms 1212 KB Output is correct
13 Correct 45 ms 1220 KB Output is correct
14 Correct 37 ms 1116 KB Output is correct
15 Correct 40 ms 1104 KB Output is correct
16 Correct 39 ms 1112 KB Output is correct
17 Correct 38 ms 1104 KB Output is correct
18 Correct 36 ms 1104 KB Output is correct
19 Correct 40 ms 1116 KB Output is correct
20 Correct 41 ms 1108 KB Output is correct
21 Correct 48 ms 2640 KB Output is correct
22 Correct 46 ms 4764 KB Output is correct
23 Correct 42 ms 4672 KB Output is correct
24 Correct 43 ms 4440 KB Output is correct
25 Correct 53 ms 4696 KB Output is correct
26 Correct 39 ms 4688 KB Output is correct
27 Correct 45 ms 4656 KB Output is correct
28 Correct 75 ms 1104 KB Output is correct
29 Correct 76 ms 1236 KB Output is correct
30 Correct 70 ms 1120 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 102 ms 13864 KB Output is correct
33 Correct 83 ms 12664 KB Output is correct
34 Correct 76 ms 13392 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 46 ms 4104 KB Output is correct
38 Correct 38 ms 3924 KB Output is correct
39 Correct 41 ms 3920 KB Output is correct
40 Correct 39 ms 3920 KB Output is correct
41 Correct 44 ms 3924 KB Output is correct
42 Correct 41 ms 3924 KB Output is correct
43 Correct 39 ms 3928 KB Output is correct
44 Correct 37 ms 3920 KB Output is correct
45 Correct 42 ms 4692 KB Output is correct
46 Correct 43 ms 4496 KB Output is correct
47 Correct 62 ms 4948 KB Output is correct
48 Correct 48 ms 4928 KB Output is correct
49 Correct 44 ms 4688 KB Output is correct
50 Correct 53 ms 4436 KB Output is correct
51 Correct 50 ms 4696 KB Output is correct
52 Correct 39 ms 4688 KB Output is correct
53 Correct 46 ms 4724 KB Output is correct
54 Correct 0 ms 344 KB Output is correct
55 Correct 39 ms 4852 KB Output is correct
56 Correct 48 ms 4944 KB Output is correct
57 Correct 68 ms 5716 KB Output is correct
58 Correct 54 ms 5752 KB Output is correct
59 Correct 60 ms 5612 KB Output is correct
60 Correct 76 ms 13392 KB Output is correct
61 Correct 80 ms 13392 KB Output is correct
62 Correct 75 ms 13140 KB Output is correct
63 Correct 75 ms 13240 KB Output is correct
64 Correct 76 ms 12884 KB Output is correct
65 Correct 74 ms 13392 KB Output is correct
66 Correct 48 ms 5460 KB Output is correct
67 Correct 49 ms 5456 KB Output is correct
68 Correct 73 ms 13904 KB Output is correct
69 Correct 87 ms 13140 KB Output is correct
70 Correct 127 ms 10836 KB Output is correct
71 Correct 112 ms 10152 KB Output is correct
72 Correct 88 ms 13448 KB Output is correct
73 Correct 76 ms 8260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 36 ms 1072 KB Output is correct
3 Correct 37 ms 1068 KB Output is correct
4 Correct 40 ms 1104 KB Output is correct
5 Correct 37 ms 1104 KB Output is correct
6 Correct 40 ms 1116 KB Output is correct
7 Correct 39 ms 1116 KB Output is correct
8 Correct 39 ms 1172 KB Output is correct
9 Correct 35 ms 1108 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 37 ms 1076 KB Output is correct
12 Correct 41 ms 1400 KB Output is correct
13 Correct 39 ms 1112 KB Output is correct
14 Correct 37 ms 1108 KB Output is correct
15 Correct 40 ms 1112 KB Output is correct
16 Correct 40 ms 1108 KB Output is correct
17 Correct 38 ms 1104 KB Output is correct
18 Correct 35 ms 1108 KB Output is correct
19 Correct 54 ms 6224 KB Output is correct
20 Correct 452 ms 27692 KB Output is correct
21 Correct 2461 ms 97708 KB Output is correct
22 Correct 3061 ms 115536 KB Output is correct
23 Correct 1064 ms 57528 KB Output is correct
24 Correct 1418 ms 67408 KB Output is correct
25 Correct 254 ms 20712 KB Output is correct
26 Correct 84 ms 8996 KB Output is correct
27 Correct 2156 ms 86864 KB Output is correct
28 Correct 973 ms 52224 KB Output is correct
29 Correct 978 ms 53364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 36 ms 1072 KB Output is correct
3 Correct 37 ms 1068 KB Output is correct
4 Correct 40 ms 1104 KB Output is correct
5 Correct 37 ms 1104 KB Output is correct
6 Correct 40 ms 1116 KB Output is correct
7 Correct 39 ms 1116 KB Output is correct
8 Correct 39 ms 1172 KB Output is correct
9 Correct 35 ms 1108 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 39 ms 1280 KB Output is correct
12 Correct 37 ms 1212 KB Output is correct
13 Correct 45 ms 1220 KB Output is correct
14 Correct 37 ms 1116 KB Output is correct
15 Correct 40 ms 1104 KB Output is correct
16 Correct 39 ms 1112 KB Output is correct
17 Correct 38 ms 1104 KB Output is correct
18 Correct 36 ms 1104 KB Output is correct
19 Correct 40 ms 1116 KB Output is correct
20 Correct 41 ms 1108 KB Output is correct
21 Correct 48 ms 2640 KB Output is correct
22 Correct 46 ms 4764 KB Output is correct
23 Correct 42 ms 4672 KB Output is correct
24 Correct 43 ms 4440 KB Output is correct
25 Correct 53 ms 4696 KB Output is correct
26 Correct 39 ms 4688 KB Output is correct
27 Correct 45 ms 4656 KB Output is correct
28 Correct 75 ms 1104 KB Output is correct
29 Correct 76 ms 1236 KB Output is correct
30 Correct 70 ms 1120 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 38 ms 3924 KB Output is correct
34 Correct 38 ms 3920 KB Output is correct
35 Correct 40 ms 4156 KB Output is correct
36 Correct 39 ms 3924 KB Output is correct
37 Correct 41 ms 3920 KB Output is correct
38 Correct 40 ms 3920 KB Output is correct
39 Correct 39 ms 4076 KB Output is correct
40 Correct 45 ms 3920 KB Output is correct
41 Correct 50 ms 4616 KB Output is correct
42 Correct 42 ms 4436 KB Output is correct
43 Correct 49 ms 4944 KB Output is correct
44 Correct 43 ms 4692 KB Output is correct
45 Correct 42 ms 4688 KB Output is correct
46 Correct 47 ms 4432 KB Output is correct
47 Correct 45 ms 4572 KB Output is correct
48 Correct 41 ms 4688 KB Output is correct
49 Correct 40 ms 4648 KB Output is correct
50 Correct 80 ms 5712 KB Output is correct
51 Correct 46 ms 5712 KB Output is correct
52 Correct 60 ms 5540 KB Output is correct
53 Correct 48 ms 5544 KB Output is correct
54 Correct 59 ms 6224 KB Output is correct
55 Correct 70 ms 5972 KB Output is correct
56 Correct 61 ms 4944 KB Output is correct
57 Correct 41 ms 4948 KB Output is correct
58 Correct 46 ms 4944 KB Output is correct
59 Correct 52 ms 5968 KB Output is correct
60 Correct 102 ms 13864 KB Output is correct
61 Correct 83 ms 12664 KB Output is correct
62 Correct 76 ms 13392 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 46 ms 4104 KB Output is correct
66 Correct 38 ms 3924 KB Output is correct
67 Correct 41 ms 3920 KB Output is correct
68 Correct 39 ms 3920 KB Output is correct
69 Correct 44 ms 3924 KB Output is correct
70 Correct 41 ms 3924 KB Output is correct
71 Correct 39 ms 3928 KB Output is correct
72 Correct 37 ms 3920 KB Output is correct
73 Correct 42 ms 4692 KB Output is correct
74 Correct 43 ms 4496 KB Output is correct
75 Correct 62 ms 4948 KB Output is correct
76 Correct 48 ms 4928 KB Output is correct
77 Correct 44 ms 4688 KB Output is correct
78 Correct 53 ms 4436 KB Output is correct
79 Correct 50 ms 4696 KB Output is correct
80 Correct 39 ms 4688 KB Output is correct
81 Correct 46 ms 4724 KB Output is correct
82 Correct 0 ms 344 KB Output is correct
83 Correct 39 ms 4852 KB Output is correct
84 Correct 48 ms 4944 KB Output is correct
85 Correct 68 ms 5716 KB Output is correct
86 Correct 54 ms 5752 KB Output is correct
87 Correct 60 ms 5612 KB Output is correct
88 Correct 76 ms 13392 KB Output is correct
89 Correct 80 ms 13392 KB Output is correct
90 Correct 75 ms 13140 KB Output is correct
91 Correct 75 ms 13240 KB Output is correct
92 Correct 76 ms 12884 KB Output is correct
93 Correct 74 ms 13392 KB Output is correct
94 Correct 48 ms 5460 KB Output is correct
95 Correct 49 ms 5456 KB Output is correct
96 Correct 73 ms 13904 KB Output is correct
97 Correct 87 ms 13140 KB Output is correct
98 Correct 127 ms 10836 KB Output is correct
99 Correct 112 ms 10152 KB Output is correct
100 Correct 88 ms 13448 KB Output is correct
101 Correct 76 ms 8260 KB Output is correct
102 Correct 0 ms 348 KB Output is correct
103 Correct 37 ms 1076 KB Output is correct
104 Correct 41 ms 1400 KB Output is correct
105 Correct 39 ms 1112 KB Output is correct
106 Correct 37 ms 1108 KB Output is correct
107 Correct 40 ms 1112 KB Output is correct
108 Correct 40 ms 1108 KB Output is correct
109 Correct 38 ms 1104 KB Output is correct
110 Correct 35 ms 1108 KB Output is correct
111 Correct 54 ms 6224 KB Output is correct
112 Correct 452 ms 27692 KB Output is correct
113 Correct 2461 ms 97708 KB Output is correct
114 Correct 3061 ms 115536 KB Output is correct
115 Correct 1064 ms 57528 KB Output is correct
116 Correct 1418 ms 67408 KB Output is correct
117 Correct 254 ms 20712 KB Output is correct
118 Correct 84 ms 8996 KB Output is correct
119 Correct 2156 ms 86864 KB Output is correct
120 Correct 973 ms 52224 KB Output is correct
121 Correct 978 ms 53364 KB Output is correct
122 Correct 74 ms 13892 KB Output is correct
123 Correct 70 ms 12696 KB Output is correct
124 Correct 75 ms 13348 KB Output is correct
125 Correct 0 ms 344 KB Output is correct
126 Correct 0 ms 348 KB Output is correct
127 Correct 38 ms 4088 KB Output is correct
128 Correct 38 ms 3924 KB Output is correct
129 Correct 39 ms 3924 KB Output is correct
130 Correct 45 ms 3924 KB Output is correct
131 Correct 41 ms 3996 KB Output is correct
132 Correct 40 ms 3920 KB Output is correct
133 Correct 39 ms 3900 KB Output is correct
134 Correct 36 ms 3924 KB Output is correct
135 Correct 42 ms 4640 KB Output is correct
136 Correct 42 ms 4436 KB Output is correct
137 Correct 48 ms 4780 KB Output is correct
138 Correct 44 ms 4700 KB Output is correct
139 Correct 42 ms 4764 KB Output is correct
140 Correct 44 ms 4432 KB Output is correct
141 Correct 45 ms 4700 KB Output is correct
142 Correct 39 ms 4656 KB Output is correct
143 Correct 40 ms 4696 KB Output is correct
144 Correct 0 ms 348 KB Output is correct
145 Correct 38 ms 4812 KB Output is correct
146 Correct 50 ms 4888 KB Output is correct
147 Correct 65 ms 5924 KB Output is correct
148 Correct 47 ms 5588 KB Output is correct
149 Correct 70 ms 5712 KB Output is correct
150 Correct 82 ms 13396 KB Output is correct
151 Correct 79 ms 13396 KB Output is correct
152 Correct 77 ms 13132 KB Output is correct
153 Correct 73 ms 13396 KB Output is correct
154 Correct 73 ms 12884 KB Output is correct
155 Correct 76 ms 13396 KB Output is correct
156 Correct 47 ms 5460 KB Output is correct
157 Correct 47 ms 5604 KB Output is correct
158 Correct 72 ms 13816 KB Output is correct
159 Correct 92 ms 13392 KB Output is correct
160 Correct 147 ms 10832 KB Output is correct
161 Correct 109 ms 10100 KB Output is correct
162 Correct 87 ms 13392 KB Output is correct
163 Correct 57 ms 8276 KB Output is correct
164 Correct 48 ms 5456 KB Output is correct
165 Correct 58 ms 6224 KB Output is correct
166 Correct 78 ms 5972 KB Output is correct
167 Correct 61 ms 5096 KB Output is correct
168 Correct 54 ms 5828 KB Output is correct
169 Correct 55 ms 6108 KB Output is correct
170 Correct 474 ms 27848 KB Output is correct
171 Correct 2417 ms 97812 KB Output is correct
172 Correct 3020 ms 115548 KB Output is correct
173 Correct 1128 ms 57612 KB Output is correct
174 Correct 1446 ms 67408 KB Output is correct
175 Correct 246 ms 20564 KB Output is correct
176 Correct 83 ms 9208 KB Output is correct
177 Correct 2195 ms 86800 KB Output is correct
178 Correct 977 ms 52124 KB Output is correct
179 Correct 932 ms 53332 KB Output is correct
180 Correct 81 ms 13904 KB Output is correct
181 Correct 98 ms 15696 KB Output is correct
182 Correct 233 ms 23888 KB Output is correct
183 Correct 167 ms 20816 KB Output is correct
184 Correct 146 ms 18768 KB Output is correct
185 Correct 421 ms 29268 KB Output is correct
186 Correct 1761 ms 83384 KB Output is correct
187 Correct 3008 ms 132248 KB Output is correct
188 Correct 2240 ms 108368 KB Output is correct
189 Correct 1094 ms 73556 KB Output is correct
190 Correct 1493 ms 86120 KB Output is correct
191 Correct 1484 ms 84852 KB Output is correct