QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#547513#6515. Path PlanningzzisjtuWA 26ms3812kbC++233.7kb2024-09-04 22:15:462024-09-04 22:15:47

Judging History

你现在查看的是最新测评结果

  • [2024-09-04 22:15:47]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:3812kb
  • [2024-09-04 22:15:46]
  • 提交

answer

// #include<bits/stdc++.h>
// using namespace std;
// #define endl '\n'
// #define int long long
// int n, m, ans;
// int deg[200001], u[200001], v[200001];
// int edgeId[200001], cnt[200001];

// struct Edge {
//   int to, nxt;
// } edge[200001];

// int cntEdge, head[100001];

// void addEdge(int u, int v) {
//   edge[++cntEdge] = {v, head[u]}, head[u] = cntEdge;
// }

// void solve() {
//     cin >> n >> m;
//     cntEdge = ans = 0;
//     memset(deg, 0, sizeof deg);
//     memset(head, 0, sizeof head);
//     for (int i = 1; i <= m; i++) {
//         cin >> u[i] >> v[i];
//         deg[u[i]]++;
//         deg[v[i]]++;
//     }
//     for(int i = 1; i <= m; i++) {
//         if((deg[u[i]] == deg[v[i]] && u[i] > v[i]) || deg[u[i]] < deg[v[i]]) {
//             swap(u[i], v[i]);
//         }
//         addEdge(u[i], v[i]);
//     }
//     for(int u = 1; u <= n; u++) {
//         for(int i = head[u]; i; i = edge[i].nxt) {
//             edgeId[edge[i].to] = i;
//         }
//         for(int i = head[u]; i; i = edge[i].nxt) {
//             int v = edge[i].to;
//             for(int j = head[v]; j; j = edge[j].nxt) {
//                 int w = edge[j].to;
//                 if(edgeId[w]) {
//                     cnt[i]++;
//                     cnt[j]++;
//                     cnt[edgeId[w]]++;
//                 }
//             }
//         }
//         for(int i = head[u]; i; i = edge[i].nxt) {
//             edgeId[edge[i].to] = 0;
//         }
//     }
//     for(int i = 1; i <= m; i++) {
//         ans += cnt[i];
//         cnt[i] = 0;
//     }
//     if(ans >= m) {
//         cout << "Yes\n";
//     }
//     else cout << "No\n";
// }

// #undef int
// int main() {
//     int t = 1;
//     cin >> t;
//     while(t--) {
//         solve();
//     }
// }
#include"bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define rpe(i,a,n) for(int i=a;i>=n;i--)
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long ll;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') w = -1; for (; isdigit(ch); ch = getchar())    s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[40]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-');    int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';        tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;    while (b) { if (b & 1)    ans *= a;        b >>= 1;        a *= a; }    return ans; }    ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
typedef pair<int, int> pii;


#define int long long
const int N = 2e6 + 9;
pii a[N];
int n, m;
bool ck(int x) {
    vector<pii> p;
    for (int i = 0; i < x; i++) {
        p.push_back({ a[i] });
    }
    sort(p.begin(), p.end());
    int k = 0;
    for (int i = 0; i < x; i++) {
        if (p[i].second < k) {
            return false;
        }
        k = p[i].second;
    }
    return true;
}
void slove() {
    cin >> n >> m;
    rep(i, 1, n) {
        rep(j, 1, m) {
            int x;
            cin >> x;
            a[x] = {i,j};
        }
    }
    int l = 0, r = n + m;
    int ans = 0;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (ck(mid)) {
            ans = mid;
            l = mid + 1;
        }
        else {
            r = mid - 1;
        }
    }
    cout << ans << endl;
}

signed main() {
    js;
    int t = 1;
    cin>>t;
    while (t--)slove();
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

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: 26ms
memory: 3812kb

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
2
6
3
5
3
14
13
5
9
5
7
6
9
7
4
7
7
13
9
10
9
6
1
5
7
4
2
10
4
18
5
12
3
7
6
9
2
2
5
6
10
8
4
2
5
2
5
7
13
6
10
3
10
3
6
9
8
3
10
2
3
3
5
8
4
7
7
7
8
8
6
6
5
3
7
8
13
3
3
6
5
4
4
10
5
12
7
2
11
6
7
5
10
9
5
3
10
3
5
3
8
7
10
5
4
10
4
6
5
9
4
10
6
3
5
4
4
7
4
8
3
12
5
4
5
8
6
8
3
7
9
3
6
12
5
6
6
6...

result:

wrong answer 17th numbers differ - expected: '6', found: '7'