QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#141237 | #6515. Path Planning | cy1999 | WA | 24ms | 1768kb | C++ | 1.0kb | 2023-08-17 09:55:45 | 2023-08-17 09:55:46 |
Judging History
answer
#include <cstdio>
#include <algorithm>
using namespace std;
const int A = 1000000, N = 1000000, INF = 0x3f3f3f3f;
int r, c;
struct Node
{
int a, x, y;
bool operator < (const Node &t) const
{
return a < t.a;
}
}node[A + 5];
int cntn;
void init()
{
scanf("%d %d", &r, &c);
for(int i = 1; i <= r; i++)
{
for(int j = 1; j <= c; j++)
{
int x;
scanf("%d", &x);
node[++cntn] = (Node){x, i, j};
}
}
}
struct Rge
{
int l, r;
}rge[N + 5];
void solve()
{
sort(node + 1, node + cntn + 1);
for(int i = 1; i <= c; i++)
{
rge[i].l = INF;
rge[i].r = -INF;
}
for(int i = 1; i <= r * c; i++)
{
int x = node[i].x, y = node[i].y;
rge[y].l = min(rge[y].l, x);
rge[y].r = max(rge[y].r, x);
if((y > 1 && rge[y].l < rge[y - 1].r) || (y < c && rge[y].r > rge[y + 1].l))
{
printf("%d\n", i - 1);
return;
}
}
printf("%d\n", r * c);
}
void clr()
{
cntn = 0;
}
int main()
{
int T;
scanf("%d", &T);
while(T--)
{
init();
solve();
clr();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1768kb
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: 24ms
memory: 1760kb
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 4 6 3 5 3 14 13 5 9 6 7 6 9 7 4 6 7 13 9 11 9 8 3 11 7 10 2 10 4 18 5 12 3 7 6 9 4 1 5 6 10 8 4 2 5 3 5 7 13 6 10 2 10 3 6 9 8 7 11 4 3 6 5 8 4 7 7 7 8 8 6 6 5 5 7 7 13 3 3 7 5 4 3 10 5 12 7 2 11 6 7 6 10 9 8 3 10 2 7 3 8 7 10 7 5 10 4 6 5 10 4 12 6 3 5 4 5 7 4 8 3 13 5 5 6 8 6 8 3 7 9 3 6 12 4 6 ...
result:
wrong answer 2nd numbers differ - expected: '2', found: '4'