QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#395463#7075. Let's Play Jigsaw Puzzles!suibian_xiaozhao#WA 0ms3480kbC++231.3kb2024-04-21 15:01:222024-04-21 15:01:24

Judging History

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

  • [2024-04-21 15:01:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3480kb
  • [2024-04-21 15:01:22]
  • 提交

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 != -1)
            cnt[ops[i].s]++;
        if (ops[i].e != -1)
            cnt[ops[i].e]++;
        if (ops[i].n == -1 && ops[i].w == -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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3480kb

input:

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

output:

1 2 
3 4 

result:

wrong answer 1st lines differ - expected: '1 2', found: '1 2 '