QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#24107 | #2956. Statues | maze# | WA | 1ms | 3268kb | C++ | 2.7kb | 2022-03-26 14:50:08 | 2022-04-30 04:57:01 |
Judging History
answer
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
int p = 0;
int n, m, mp[60][60], ss[3000];
set<int> s;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
scanf("%d", &mp[i][j]);
if (mp[i][j] != -1)
ss[++p] = mp[i][j];
}
}
sort(ss + 1, ss + 1 + p);
int t = 0, rm1 = 0, rm2 = 0, rm3 = 0, rm4 = 0;
for (int i = 2; i <= n + m; i++) {
int op = max(1, i - m), cnt = 0;
for (int j = op; j > 0 && j <= n && i - j <= m && i - j > 0; j++) {
if (mp[j][i - j] != -1)
cnt++;
}
for (int j = 1; j <= cnt; j++) {
s.insert(ss[t + j]);
}
t += cnt;
for (int j = op; j > 0 && j <= n && i - j <= m && i - j > 0; j++) {
if (mp[j][i - j] != -1 && !s.count(mp[j][i - j]))
rm1++;
}
s.clear();
}
t = 0;
for (int i = 1 - m; i <= n - 1; i++) {
int op = max(1, i + 1), cnt = 0;
for (int j = op; j > 0 && j <= n && j - i <= m && j - i > 0; j++) {
if (mp[j][j - i] != -1)
cnt++;
}
for (int j = 1; j <= cnt; j++) {
s.insert(ss[t + j]);
}
t += cnt;
for (int j = op; j > 0 && j <= n && j - i <= m && j - i > 0; j++) {
if (mp[j][j - i] != -1 && !s.count(mp[j][j - i]))
rm2++;
}
s.clear();
}
t = 0;
for (int i = n - 1; i >= 1 - m; i--) {
int op = max(1, i + 1), cnt = 0;
for (int j = op; j > 0 && j <= n && j - i <= m && j - i > 0; j++) {
if (mp[j][j - i] != -1)
cnt++;
}
for (int j = 1; j <= cnt; j++) {
s.insert(ss[t + j]);
}
t += cnt;
for (int j = op; j > 0 && j <= n && j - i <= m && j - i > 0; j++) {
if (mp[j][j - i] != -1 && !s.count(mp[j][j - i]))
rm3++;
}
s.clear();
}
t = 0;
for (int i = n + m; i >= 2; i--) {
int op = max(1, i - m), cnt = 0;
for (int j = op; j > 0 && j <= n && i - j <= m && i - j > 0; j++) {
if (mp[j][i - j] != -1)
cnt++;
}
for (int j = 1; j <= cnt; j++) {
s.insert(ss[t + j]);
}
t += cnt;
for (int j = op; j > 0 && j <= n && j - i <= m && j - i > 0; j++) {
if (mp[j][i - j] != -1 && !s.count(mp[j][i - j]))
rm4++;
}
s.clear();
}
printf("%d\n", min({rm1, rm2, rm3, rm4}));
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3268kb
input:
50 50 9946 213 7427 7298 9772 2466 4890 2062 2490 1538 5605 4546 5426 2974 7693 5133 206 1329 7853 5669 8991 8828 1006 808 2227 1878 8900 8948 2755 8784 2564 5954 348 1718 2880 5820 7112 8161 4337 7247 5447 7465 1280 7708 1567 6280 129 9961 5758 9546 6412 3445 7559 7648 3160 3649 2388 7527 1800 4392...
output:
0
result:
wrong answer 1st lines differ - expected: '2466', found: '0'