QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395443#7075. Let's Play Jigsaw Puzzles!suibian_xiaozhao#TL 0ms0kbC++231.3kb2024-04-21 14:42:482024-04-21 14:42:48

Judging History

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

  • [2024-04-21 14:42:48]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-21 14:42:48]
  • 提交

answer

//
// Created by DELLPC on 24-4-21.
//
#include<bits/stdc++.h>

using namespace std;
struct op {
    int n, s, w, e;
};

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int m;
    cin >> m;
    vector<op> ops(m * m + 1);
    int st, num;
    vector<int> nn(m * m + 1), ww(m * m + 1), cnt(m * m + 1);
    for (int i = 1; i <= m * m; i++) {
        cin >> ops[i].n >> ops[i].s >> ops[i].w >> ops[i].e;
        if (ops[i].s)
            cnt[ops[i].s]++;
        if (ops[i].e)
            cnt[ops[i].e]++;
        if (ops[i].n == -1 && ops[i].s == -1)
            st = i;
        if (ops[i].n != -1)
            nn[ops[i].n] = i;
        if (ops[i].w != -1)
            ww[ops[i].w] = i;
    }
    for (int i = 1; i <= m * m; i++) {
        if (cnt[i] == 0) {
            num = i;
        }
    }
    while (1) {
        int now1 = num, now2 = st;
        while (1) {
            cout << now1 << ' ';
            int t = ops[now2].e;
            if (t == -1) {
                break;
            }
            now2 = ww[now1];
            now1 = t;
        }
        cout << "\n";
        int t = ops[st].s;
        if (t == -1) {
            break;
        }
        st = nn[num];
        num = t;
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

2
-1 3 -1 2
-1 4 1 -1
1 -1 -1 4
2 -1 3 -1

output:

1 0 
0 4 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 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 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 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 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 0 0 0 0 0 0...

result: