QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#109929 | #6515. Path Planning | yomapeed | WA | 21ms | 3540kb | C++14 | 2.2kb | 2023-05-31 00:17:06 | 2023-05-31 00:17:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
/*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")*/
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define INF 999999999999999999
#define pb push_back
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
#define ff first
#define ss second
#define printclock cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll B) { return (unsigned ll)rng() % B;}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
fast;
ll _T = 1;
cin >> _T;
while (_T--) {
ll n, m;
cin >> n >> m;
vector<vector<ll>> v(n, vector<ll>(m));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
ll x;
cin >> x;
v[i][j] = x;
}
}
ll lo = 0, hi = n + m - 2;
ll ans = 0;
while(lo <= hi){
ll mid = (lo + hi) / 2;
bool flag = true;
ll y = -1, cnt = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(v[i][j] <= lo){
if(y > j){
flag = false;
}
else{
y = j;
}
}
}
}
if(flag){
lo = mid + 1;
ans = mid + 1;
}
else{
hi = mid - 1;
}
}
cout << ans << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3400kb
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
Wrong Answer
time: 21ms
memory: 3540kb
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...
output:
9 6 6 3 5 3 15 14 5 9 5 7 6 11 7 7 6 7 13 9 12 12 8 6 9 7 7 4 10 9 18 8 12 9 7 7 9 6 1 5 6 12 8 5 4 6 5 5 7 13 9 10 2 10 3 6 9 9 8 11 4 3 7 6 8 4 7 7 7 10 8 6 6 5 7 7 7 14 9 5 7 5 9 3 11 5 12 7 2 14 10 7 6 13 9 5 7 11 2 6 3 8 9 10 8 8 10 4 6 6 10 5 11 7 3 5 5 7 7 7 8 4 13 6 4 8 8 7 8 4 7 12 3 7 15 4...
result:
wrong answer 2nd numbers differ - expected: '2', found: '6'