QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#595504 | #7757. Palm Island | mhw# | RE | 1ms | 3596kb | C++23 | 1.9kb | 2024-09-28 13:52:09 | 2024-09-28 13:52:10 |
Judging History
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');
}
}
}
}
cout << '\n';
}
int main() {
int T = read();
while(T--) {
slv();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
121121221 1221222122212221
result:
ok Correct. (2 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
200 3 3 1 2 2 3 1 4 2 4 1 3 2 1 4 3 4 1 4 2 3 2 1 3 4 5 4 3 2 1 5 2 4 5 3 1 5 2 1 5 4 3 5 2 4 1 3 4 4 3 1 2 1 2 4 3 3 1 2 3 3 1 2 4 1 4 2 3 2 1 4 3 4 1 3 2 4 1 4 3 2 3 3 2 1 1 3 2 3 2 3 1 1 3 2 4 1 4 3 2 3 1 2 4 3 1 2 3 1 3 2 3 3 2 1 2 3 1 5 5 1 3 2 4 2 4 5 1 3 4 4 3 1 2 1 4 3 2 4 1 3 4 2 2 4 3 1 3 ...
output:
111221221 2221122122212221 1121222112212221 1122122221112212222122221 1122122221122212222122221 1121112122212221 111221221 1121222122212221 2221112122212221 111221221 111121221 1121222112212221 221121221 121221221 1112111121222212222122221 1121222122212221 1111112112212221 121121221 2221222122212221...
result:
ok Correct. (200 test cases)
Test #3:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
200 5 5 1 3 4 2 5 3 2 4 1 5 5 1 2 4 3 3 5 4 1 2 5 1 4 5 3 2 2 5 4 3 1 5 1 5 4 3 2 4 5 2 3 1 5 2 3 4 5 1 5 4 3 2 1 5 1 5 2 4 3 5 3 1 2 4 5 1 2 4 3 5 4 2 3 5 1 5 3 2 1 4 5 4 2 3 1 5 5 3 1 2 5 4 2 4 1 3 5 5 5 3 1 4 2 2 5 4 1 3 5 5 4 3 1 2 2 5 4 1 3 5 3 4 5 2 1 3 5 1 4 2 5 4 5 1 3 2 4 2 3 1 5 5 1 3 4 5 ...
output:
2222112221112211222122221 1111122221112212222122221 1111111221122211222122221 1122112221112211222122221 1112111221122212222122221 1222111121222212222122221 1122112221122211222122221 1112112221222212222122221 1122111121122212222122221 1111122221112211222122221 1111122221222211222122221 22221122211122...
result:
ok Correct. (200 test cases)
Test #4:
score: -100
Runtime Error
input:
100 5 1 2 5 4 3 2 4 5 3 1 6 6 1 5 2 4 3 1 4 5 6 2 3 3 2 1 3 1 2 3 5 5 3 4 2 1 1 2 3 5 4 10 5 9 4 2 6 10 7 8 3 1 1 3 4 10 5 7 2 9 8 6 10 5 9 10 7 8 3 4 6 2 1 2 7 4 3 10 9 5 8 1 6 8 1 7 4 6 3 5 2 8 3 5 1 4 6 8 7 2 4 2 3 4 1 1 4 2 3 7 3 7 4 6 2 1 5 5 6 7 3 4 1 2 8 2 1 4 7 8 3 6 5 5 2 7 4 3 1 8 6 4 3 2 ...