QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#482988 | #1819. Cleaning Robot | UbeSnowflake | WA | 39ms | 4864kb | C++14 | 1.7kb | 2024-07-18 08:48:15 | 2024-07-18 08:48:15 |
Judging History
answer
#include <iostream>
#include <vector>
#include <map>
#include <limits.h>
#include <algorithm>
using namespace std;
int main() {
//std::cout << "Hello World!\n";
int n, m, k;
cin >> n >> m >> k;
map<int, vector<int>> xs;
map<int, vector<int>> ys;
int minx = INT_MAX;
int miny = INT_MAX;
int maxx = 0;
int maxy = 0;
for (int i = 0; i < k; i++) {
int x, y;
cin >> x >> y;
if (xs.find(x) == xs.end()) {
xs[x] = {y};
} else {
xs[x].push_back(y);
}
if (ys.find(y) == ys.end()) {
ys[y] = {x};
} else {
ys[y].push_back(x);
}
if (x!= 1 && x < minx) {
minx = x;
}
if (x!= n && x > maxx) {
maxx = x;
}
if (y!= 1 && y < miny) {
miny = y;
}
if (y!= m && y > maxy) {
maxy = y;
}
}
int maxside;
if (k == 0) {
maxside = min(n, m);
} else {
maxside = min({n - maxx, m - maxy, minx - 1, miny - 1});
}
map<int, vector<int>> ::iterator itx;
for (itx = xs.begin(); itx != xs.end(); itx++)
{
vector<int> vals = itx->second;
sort(vals.begin(), vals.end());
for (int j = 0; j < vals.size() - 1; j++) {
if (vals[j+1] - vals[j] - 1 != 0 && vals[j+1] - vals[j] - 1 < maxside) {
maxside = vals[j+1] - vals[j] - 1;
}
}
}
map<int, vector<int>> ::iterator ity;
for (ity = ys.begin(); ity != ys.end(); ity++)
{
vector<int> vals = ity->second;
sort(vals.begin(), vals.end());
for (int j = 0; j < vals.size() - 1; j++) {
if (vals[j+1] - vals[j] - 1 != 0 && vals[j+1] - vals[j] - 1 < maxside) {
maxside = vals[j+1] - vals[j] - 1;
}
}
}
cout << maxside << "\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
10 7 1 8 3
output:
2
result:
ok answer is '2'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3924kb
input:
2236 2236 2214 28 1255 389 2175 730 592 1360 977 1225 752 1403 1798 1518 1381 147 745 659 249 951 1475 1826 1951 691 1033 81 1458 1487 1946 2106 1395 1995 629 470 891 1902 822 2210 2001 441 2130 1198 1539 2027 1101 215 1149 205 420 379 2104 308 1225 859 109 1417 2078 1764 376 1772 5 335 1113 917 118...
output:
1
result:
ok answer is '1'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3864kb
input:
2236 2236 2143 228 686 129 801 1105 382 2196 1919 2082 777 1672 268 174 916 234 491 1235 274 1645 1849 1114 1173 1351 1677 1294 1365 1059 197 611 1715 1769 1395 885 1902 1190 1304 1039 779 610 124 881 662 22 1664 239 1283 2218 2031 169 1417 291 143 228 1837 1518 2013 747 359 1997 1030 73 153 614 488...
output:
3
result:
ok answer is '3'
Test #4:
score: -100
Wrong Answer
time: 39ms
memory: 4864kb
input:
2236 2236 63774 369 1861 1156 2150 1895 160 546 1944 1688 645 49 1888 430 973 1602 30 1988 971 1120 1307 322 1524 1559 1070 558 1147 973 1965 572 923 370 646 1436 1982 132 681 1410 308 1812 982 2191 2112 1311 396 1067 1330 659 477 873 881 1766 508 2091 1875 895 716 2058 1237 1374 1005 2183 1514 227 ...
output:
10
result:
wrong answer expected '8', found '10'