QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#684345#7075. Let's Play Jigsaw Puzzles!Zhi_zI#WA 0ms3800kbC++171.8kb2024-10-28 12:45:192024-10-28 12:45:21

Judging History

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

  • [2024-10-28 12:45:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3800kb
  • [2024-10-28 12:45:19]
  • 提交

answer

#include <bits/stdc++.h>

/* Orther */
#define int long long
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
using namespace std;

/* Pair */
#define x first
#define y second

/* Data type */
using ll = long long;
using ull = unsigned long long;
using PII = pair<int,int>;
using VI = vector<int>;
using VPII = vector<PII>;

/* STL */
#define eb emplace_back
#define ef emplace_front
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define all1(x) x.begin()+1,x.end()
#define sz size

/* Random */
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define random(a,b) rng()%(b-a+1)+a

/* Contest */
const int INF = 0x3f3f3f3f , LLONGMAX = 1e18 ; // 1e9
const int MOD =  998244353 ;
const int N = 1e3 + 10, M = 55;

vector<int> g[N];
void Rainbow_()
{
    int m; cin >> m ;
    VI u(m * m + 1), d(m * m + 1), l(m * m + 1), r(m * m + 1);
    for (int i = 1; i <= m * m ; i ++ ) {
    	int n, s, w, e; // bei nan xi dong
    	cin >> n >> s >> w >> e;
    	
    	u[i] = n;
    	if (n != -1) {
    		d[n] = i;
    	}
    	d[i] = s;
    	if (s != -1) {
    		u[s] = i;
    	}
    	l[i] = w;
    	if (w != -1) {
    		r[w] = i;
    	}
    	r[i] = e;
    	if ( e != -1 ) {
    		l[e] = i ;
    	}
    }
    
    int begin = -1 ;
    for (int i = 1; i <= m * m; i ++ ) {
    	if (u[i] == -1 && l[i] == - 1) {
    		begin = i;
    	}
    }
    
    for (int i = begin; i != -1; i = d[i]) {
    	for (int j = i; j != -1 ; j = r[j]) {
    		cout << j << ' ';
    	} cout << '\n';
    }
}
 
signed main()
{   
    IOS;
    int _ = 1;
    // cin >> _;
 
    while ( _ -- ) 
        Rainbow_();
 
    return 0;
}

詳細信息

Test #1:

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

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 '