QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#121808 | #6515. Path Planning | Sorting# | RE | 1ms | 3408kb | C++20 | 1.3kb | 2023-07-08 21:24:17 | 2023-07-08 21:24:18 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <utility>
#include <array>
using namespace std;
int n, m;
vector<vector<int>> a;
vector<vector<pair<int, int>>> layers;
bool check(int mid){
vector<pair<int, int>> v;
for(int i = 0; i < n + m - 1; ++i){
for(auto [x, y]: layers[i]){
if(a[x][y] < mid){
v.push_back({x, y});
}
}
}
for(int i = 0; i < (int)v.size() - 1; ++i){
auto [x, y] = v[i];
auto [x2, y2] = v[i + 1];
if(x2 < x || y2 < y)
return false;
}
return true;
}
void solve(){
cin >> n >> m;
a.resize(n, vector<int>(m));
layers.clear();
layers.resize(n + m - 1);
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j){
cin >> a[i][j];
layers[i + j].push_back({i, j});
}
int l = 0, r = n * m;
while(l != r){
int mid = (l + r + 1) >> 1;
if(check(mid))
l = mid;
else
r = mid - 1;
}
cout << l << "\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3408kb
input:
2 2 3 1 2 4 3 0 5 1 5 1 3 0 4 2
output:
3 5
result:
ok 2 number(s): "3 5"
Test #2:
score: -100
Dangerous Syscalls
input:
10000 2 9 4 0 3 5 2 7 16 11 12 9 13 14 17 10 8 15 1 6 4 8 19 23 22 13 29 4 17 26 30 6 25 3 15 24 18 14 12 8 7 9 27 5 0 10 11 16 31 20 2 28 1 21 1 6 3 2 0 1 4 5 2 3 4 2 0 3 5 1 5 1 4 0 3 2 1 1 3 1 0 2 8 10 9 50 8 0 41 57 60 30 23 65 64 21 36 12 10 5 58 19 38 67 71 52 45 17 77 4 59 51 22 25 56 49 79 2...