QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#595493#7757. Palm Islandmhw#WA 0ms3596kbC++231.9kb2024-09-28 13:51:072024-09-28 13:51:07

Judging History

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

  • [2024-09-28 13:51:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2024-09-28 13:51:07]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define pii make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
const ll inf = 1145141919810;
using namespace std;
inline ll read() {
	ll x=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9') {
		if (c=='-')  f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
inline void print(ll x) {
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + '0');
	return ;
}
/*
deque<int> ideq
//b)增加函数
 ideq.push_front( x):双端队列头部增加一个元素X
 ideq.push_back(x):双端队列尾部增加一个元素x
//c)删除函数
ideq.pop_front():删除双端队列中最前一个元素
ideq.pop_back():删除双端队列中最后一个元素
ideq.clear():清空双端队列中元素
//d)判断函数
ideq.empty() :向量是否为空,若true,则向量中无元素
//e)大小函数
ideq.size():返回向量中元素的个数
*/
inline void pprint(ll x) {
	print(x);
	puts("");
}
void slv() {
	int n = read();
	vector<int> a(n, 0);
	vector<int> b(n, 0);
	map<int, int> mp;
	rep(i, 1, n) a[i] = read();
	rep(i, 1, n) b[i] = read();
	rep(i, 1, n) mp[b[i]] = i;
	rep(i, 1, n) a[i] = mp[a[i]];
	deque<int> q;
	rep(i, 1, n) q.push_back(a[i]);

	rep(k, 1, n) {
		rep(j, 1, n) {
			if(q.front() != k) {
				int tmp = q.front();
				q.pop_front();
				q.push_back(tmp);
				putchar('1');
			} else {
				//第一个元素是k
				if(j == n) {
					q.pop_front();
					q.push_back(k);
					putchar('1');
				} else {
					q.pop_front();//弹出k
					int tmp = q.front();
					q.pop_front();
					q.push_back(tmp);
					q.push_front(k);
					putchar('2');
				}
			}
		}
	}
}
int main() {
	int T = read();
	while(T--) {
		slv();
	}
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

1211212211221222122212221

result:

wrong answer On Case#1: The lenght of your output is 25(exceed n*n = 9). (test case 1)