QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#57969 | #3892. Efficiently Elevated | Beevo# | WA | 3ms | 3744kb | C++23 | 1.2kb | 2022-10-24 01:00:17 | 2022-10-24 01:00:17 |
Judging History
answer
#include <bits/stdc++.h>
#define el '\n'
#define ll long long
#define ld long double
#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int h, w;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
bool valid(int x, int y) {
return x >= 0 && x < h && y >= 0 && y < w;
}
void testCase() {
cin >> h >> w;
int g[h][w];
vector<pair<int, pair<int, int>>> v;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> g[i][j];
if (g[i][j] > 1)
v.push_back({g[i][j], {i, j}});
}
}
sort(v.rbegin(), v.rend());
bool b[h][w];
memset(b, 0, sizeof b);
int sol = 0;
for (auto &e: v) {
int i = e.second.first, j = e.second.second;
if (!b[i][j])
b[i][j] = 1, sol++;
for (int k = 0; k < 4; k++) {
int x = i + dx[k], y = j + dy[k];
if (valid(x, y) && g[x][y] <= g[i][j])
b[x][y] = 1;
}
}
cout << sol;
}
signed main() {
Beevo
int T = 1;
// cin >> T;
while (T--)
testCase();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3644kb
input:
3 3 1 2 3 0 0 4 7 6 5
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3716kb
input:
6 7 0 0 0 0 0 0 0 0 1 2 3 2 1 0 0 1 2 3 2 1 0 0 0 0 0 0 0 0 0 1 0 5 0 0 0 0 0 0 0 0 0 0
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3732kb
input:
4 4 1 1 2 1 2 2 1 2 1 2 2 1 2 1 2 2
output:
4
result:
ok single line: '4'
Test #4:
score: -100
Wrong Answer
time: 2ms
memory: 3744kb
input:
50 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 10 10 0 10 10 0 10 11 0 10 10 0 0 0 0 0 0 0 0 0 4 0 0 0 0 10 0 0 0 10 0 10 0 0 0 11 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 4 3 0 3 4 5 0 10 0 0 0 10 0 11 0 0 0 10 0 0 0 0 0 0 0 0 0 3 0 0 0 0 10 10 0 10 1...
output:
34
result:
wrong answer 1st lines differ - expected: '28', found: '34'