QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#189041 | #2703. Knightly Knowledge | Beevo# | AC ✓ | 114ms | 3836kb | C++20 | 1.3kb | 2023-09-26 19:51:33 | 2023-09-26 19:51:35 |
Judging History
answer
#include <bits/stdc++.h>
#define el '\n'
#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
void testCase() {
int m, c;
cin >> m >> c;
int x, y;
map<int, int> freqMX, freqMY;
for (int i = 0; i < m; i++)
cin >> x >> y, freqMX[x]++, freqMY[y]++;
set<pair<int, int>> st;
map<int, int> freqCX, freqCY;
for (int i = 0; i < c; i++) {
cin >> x >> y;
if (max(freqMX[x], freqMY[y]) >= 2)
continue;
freqCX[x]++, freqCY[y]++, st.emplace(x, y);
}
x = y = 0;
int mx = 0;
for (auto &i: freqCX) {
for (auto &j: freqCY) {
int cnt = 0;
if (freqMX[i.first] >= 1)
cnt += i.second;
if (freqMY[j.first] >= 1)
cnt += j.second;
if (freqMX[i.first] >= 1 && freqMY[j.first] >= 1)
cnt -= st.count({i.first, j.first});
if (cnt > mx)
mx = cnt, x = i.first, y = j.first;
}
}
cout << x << ' ' << y << el << mx;
}
signed main() {
Beevo
int t = 1;
// cin >> t;
while (t--)
testCase();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3548kb
input:
1 3 2 0 0 1 0 2 1 1
output:
0 0 0
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
3 12 0 0 3 3 6 6 0 1 0 2 1 0 2 0 3 4 3 5 4 3 5 3 6 7 6 8 7 6 8 6
output:
0 0 4
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
3 12 0 0 2 2 4 4 0 1 0 2 1 0 2 0 2 3 2 4 3 2 4 2 4 5 4 6 5 4 6 4
output:
2 2 6
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
0 0
output:
0 0 0
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
0 5 0 0 0 1 3 6 9 12 3 119
output:
0 0 0
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
1 5 0 0 0 1 0 2 0 3 0 4 0 5
output:
0 1 5
result:
ok
Test #7:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
3 0 0 0 1 1 1 2
output:
0 0 0
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
2 5 0 0 0 1 0 2 0 3 0 4 0 5 0 6
output:
0 0 0
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3444kb
input:
6 9 0 0 1 0 2 0 3 1 3 2 3 3 0 1 0 2 0 3 1 1 1 2 1 3 2 1 2 2 2 3
output:
0 1 5
result:
ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
2 3 0 5 5 0 0 1 0 3 3 0
output:
0 0 3
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
5 15 0 3 2 3 4 3 6 3 7 0 0 0 0 1 0 2 1 0 2 0 2 1 2 2 3 0 4 1 4 2 4 -1 5 0 6 0 6 1 6 2
output:
4 0 9
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
5 15 3 0 3 2 3 4 3 6 0 7 0 0 1 0 2 0 0 1 0 2 1 2 2 2 0 3 1 4 2 4 -1 4 0 5 0 6 1 6 2 6
output:
0 4 9
result:
ok
Test #13:
score: 0
Accepted
time: 1ms
memory: 3492kb
input:
1 4 0 0 1 0 0 1 0 -1 -1 0
output:
0 0 4
result:
ok
Test #14:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
7 3 1 0 0 -1 0 -2 2 -1 3 -2 3 -4 4 -3 1 -1 1 -2 3 -3
output:
0 0 0
result:
ok
Test #15:
score: 0
Accepted
time: 114ms
memory: 3740kb
input:
1000 1000 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 5...
output:
1 1 2
result:
ok
Test #16:
score: 0
Accepted
time: 15ms
memory: 3628kb
input:
1000 1000 0 0 1 1 1000 1500 1001 1500 1002 1500 1003 1500 1004 1500 1005 1500 1006 1500 1007 1500 1008 1500 1009 1500 1010 1500 1011 1500 1012 1500 1013 1500 1014 1500 1015 1500 1016 1500 1017 1500 1018 1500 1019 1500 1020 1500 1021 1500 1022 1500 1023 1500 1024 1500 1025 1500 1026 1500 1027 1500 10...
output:
0 0 1000
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
60 900 0 -1 -1 0 1 -1 -1 1 2 -1 -1 2 3 -1 -1 3 4 -1 -1 4 5 -1 -1 5 6 -1 -1 6 7 -1 -1 7 8 -1 -1 8 9 -1 -1 9 10 -1 -1 10 11 -1 -1 11 12 -1 -1 12 13 -1 -1 13 14 -1 -1 14 15 -1 -1 15 16 -1 -1 16 17 -1 -1 17 18 -1 -1 18 19 -1 -1 19 20 -1 -1 20 21 -1 -1 21 22 -1 -1 22 23 -1 -1 23 24 -1 -1 24 25 -1 -1 25 2...
output:
0 0 59
result:
ok
Test #18:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
60 900 5 0 4 1 6 0 4 2 7 0 4 3 8 0 4 4 9 0 4 5 10 0 4 6 11 0 4 7 12 0 4 8 13 0 4 9 14 0 4 10 15 0 4 11 16 0 4 12 17 0 4 13 18 0 4 14 19 0 4 15 20 0 4 16 21 0 4 17 22 0 4 18 23 0 4 19 24 0 4 20 25 0 4 21 26 0 4 22 27 0 4 23 28 0 4 24 29 0 4 25 30 0 4 26 31 0 4 27 32 0 4 28 33 0 4 29 34 0 4 30 5 1 5 2...
output:
5 1 59
result:
ok
Test #19:
score: 0
Accepted
time: 1ms
memory: 3500kb
input:
2 4 0 2 3 0 1 2 2 2 3 2 3 1
output:
3 2 4
result:
ok
Test #20:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
2 4 2 0 0 3 2 1 2 2 2 3 1 3
output:
2 3 4
result:
ok
Test #21:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
2 1 0 0 0 2 0 1
output:
0 0 0
result:
ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
2 1 10 10 11 11 10 11
output:
10 11 1
result:
ok
Test #23:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
6 5 -6 0 -4 0 -3 0 -4 -2 -3 -2 -2 -3 -6 -1 -4 -1 -3 -1 -5 -3 0 -3
output:
-6 -3 3
result:
ok
Test #24:
score: 0
Accepted
time: 88ms
memory: 3836kb
input:
1000 1000 -656931 -158458 176786 401057 -188196 -78458 -306135 -237665 360112 625609 -679905 420196 455057 -419801 350423 -989607 -448791 -831481 739488 -214965 261540 -925109 -740914 -849645 4648 148257 703859 935406 83099 115599 -952523 -362801 -645063 690107 -543004 265770 72771 -858318 58090 -61...
output:
270563 -999995 1
result:
ok
Test #25:
score: 0
Accepted
time: 88ms
memory: 3828kb
input:
1000 1000 -255598 719221 -441142 -761933 -588283 -65308 404135 -391435 126514 980488 822373 -632295 268742 987704 -96676 -28655 -642568 -432220 91146 -392843 -178743 62451 -793730 482897 312323 788070 578554 -628 -890542 476165 -976692 588429 279227 -181576 837199 352574 240238 -846180 -219540 -8883...
output:
377790 -999016 1
result:
ok
Test #26:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
5 5 573731 686574 600114 906950 -539611 -15165 832215 -203722 -810807 438139 -909846 400928 -225550 681750 -822377 -356815 -419691 273640 537430 -999990
output:
0 0 0
result:
ok
Test #27:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
5 5 373882 41785 416889 750855 -635392 -254902 852735 -75202 789305 -467961 952818 680651 -332044 896785 112072 270528 -6715 -748445 -639347 -97773
output:
0 0 0
result:
ok
Test #28:
score: 0
Accepted
time: 45ms
memory: 3688kb
input:
1000 1000 -239 -291 199 80 -29 -301 -467 823 -184 -320 -812 -974 654 597 417 -850 916 -590 911 -763 664 58 581 -490 268 235 -231 -103 -994 773 591 -151 -899 -787 399 -757 104 976 -387 -501 218 651 143 -303 242 870 -418 128 389 888 -789 -573 -909 381 -170 -576 338 -512 794 560 -856 268 -933 -241 -169...
output:
-948 202 7
result:
ok
Test #29:
score: 0
Accepted
time: 49ms
memory: 3680kb
input:
1000 1000 -883 -415 665 -2 67 -431 -445 -646 179 139 671 33 -844 377 189 -257 -731 783 -727 -982 -982 234 -957 370 -433 -848 126 821 816 812 -71 831 -570 -253 -581 -3 22 -192 -861 -109 -581 330 -148 -824 -680 289 772 531 -958 -262 -626 560 128 289 -7 951 -183 53 832 454 -918 -592 -975 -866 881 -799 ...
output:
-493 -996 6
result:
ok
Test #30:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
1000 1000 -157 -141 -144 -52 146 148 54 -29 34 -48 34 18 37 -55 65 126 60 152 -189 16 -128 -3 -152 141 102 -75 -146 102 123 187 -93 104 172 26 -184 48 -74 -80 -37 153 53 -178 80 75 -169 121 180 85 8 165 -180 197 -149 -19 -100 -97 -190 -136 -18 136 -40 -195 103 -190 107 172 -11 -200 190 -10 -174 85 1...
output:
-67 -85 7
result:
ok
Test #31:
score: 0
Accepted
time: 2ms
memory: 3516kb
input:
1000 1000 -122 -53 199 -78 15 -95 -167 -28 -36 -96 -27 42 -140 9 -109 66 -130 -181 -85 -35 141 162 -10 119 138 -30 -91 36 70 165 160 115 94 -52 8 55 -117 -165 -164 -154 -126 24 -162 47 102 52 -170 -127 108 73 14 -56 -167 87 133 27 50 199 6 139 194 -105 144 152 -64 -192 -25 148 62 114 10 -136 -72 36 ...
output:
157 123 7
result:
ok
Test #32:
score: 0
Accepted
time: 11ms
memory: 3660kb
input:
5 1000 196 -181 197 -112 -162 -137 84 -84 165 -61 112 138 -179 -164 -118 -43 -10 141 74 -153 -156 192 -87 84 65 155 43 -5 -121 -82 -46 -38 193 -155 182 -94 -193 100 -188 -93 15 124 116 -84 -153 135 -64 -33 -85 -97 159 106 46 -120 62 17 10 -68 -55 -64 85 -152 43 12 -8 -164 57 -143 -145 76 132 -39 -12...
output:
165 -84 7
result:
ok
Test #33:
score: 0
Accepted
time: 10ms
memory: 3616kb
input:
5 1000 -141 108 190 -128 94 -197 -34 -118 69 105 -116 -58 -168 41 5 -44 38 59 99 18 -22 -164 140 -93 159 -158 -65 109 -115 90 9 -184 -144 15 94 185 -47 64 95 200 -54 -132 180 38 -30 -159 59 -12 104 -75 138 79 -182 -191 -147 -43 140 178 -164 102 89 -10 -122 -23 80 137 -30 -129 172 -190 -7 146 158 -22...
output:
-141 -197 7
result:
ok
Test #34:
score: 0
Accepted
time: 1ms
memory: 3480kb
input:
1000 5 85 137 -173 70 48 -63 -160 114 132 88 193 -115 -118 -199 -87 107 39 -163 -156 -18 -100 -41 -143 166 -146 192 -54 104 -109 199 -166 123 54 103 90 -158 104 -190 184 123 -88 -71 -5 -128 153 141 -122 36 9 -36 34 -96 -140 41 125 -98 -196 179 -102 -118 68 -183 -187 -109 183 -30 -141 -93 18 -111 -23...
output:
0 0 0
result:
ok
Test #35:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
1000 5 28 135 27 -127 126 121 172 -47 18 126 192 -20 101 6 121 94 177 -26 -66 4 -100 -143 35 -100 -2 26 -178 128 -121 52 107 -22 114 -49 -135 -17 -119 95 72 -36 196 65 164 193 -127 -49 114 130 93 187 153 106 164 151 -68 67 -13 -188 -137 -143 -158 85 186 58 147 18 -161 153 -141 -96 -119 -28 144 146 3...
output:
145 6 1
result:
ok
Test #36:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
5 5 -64 -137 -129 -87 13 -140 -185 -8 -20 150 -185 60 160 -162 -32 97 17 -176 -151 -99
output:
-185 -176 1
result:
ok
Test #37:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
10 10 76 -182 -125 129 194 -87 -71 192 153 187 4 -67 84 138 -124 97 46 -137 -27 -172 -55 68 65 177 158 39 61 -146 -103 -135 102 -51 112 -15 121 39 127 140 128 -91
output:
0 0 0
result:
ok
Test #38:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
50 50 151 108 -53 59 10 -77 -3 -145 -165 42 -135 111 -64 100 87 146 83 64 -68 -159 -186 185 177 -117 65 32 52 -150 69 -152 -128 -195 -137 -159 42 79 4 155 -108 60 -153 197 134 -140 170 110 78 -62 134 30 -195 173 -90 -192 -171 -67 59 -50 137 -191 -139 -49 33 -50 -50 151 -77 -60 -138 -50 -96 16 -6 84 ...
output:
-165 -137 3
result:
ok
Test #39:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
1 2 0 0 1 0 0 1
output:
0 0 2
result:
ok