QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#864740 | #5650. Beppa and SwerChat | majonator# | WA | 5ms | 3712kb | C++20 | 2.4kb | 2025-01-20 22:42:42 | 2025-01-20 22:42:43 |
Judging History
answer
#include <bits/stdc++.h>
#define el '\n'
#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define rforn(i,n) for(int i =(int)(n) - 1; i>= 0; --i)
#define fora(i,x,n) for(int i=(int)x; i< (int)n; ++i)
#define rfora(i,x,n) for(int i=(int)x; i>= (int)n; --i)
#define pb push_back
#define pob pop_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) ((int)v.size())
#define CYN(x) cout << (x ? "YES" : "NO" ) <<endl;
#define cases(t) while(t--)
#define mem(v, val) memset(v, (val), sizeof(v))
#define D(x) cout << #x << ": " << x << endl;
#define precision(x) cout<<setprecision(x)<<fixed;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<char,int> pci;
// typedef tuple<int, int, int> tiii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef map<int,int> mpii;
// typedef unordered_map<int,int> umpii;
typedef set<int> seti;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pqll;
const int inf = 1e9;
const int nax = 1e5+5;
const ld pi = acos(-1);
const ld eps = 1e-9;
int dr[] = {1,-1,0,0,1,-1,-1,1};
int dc[] = {0,0,1,-1,1,1,-1,-1};
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll mod(ll a, ll b) { return (((a % b) + b) % b); }
void solve(){
int n; cin>>n;
vi v(n), a(n), pos(n);
forn(i,n){
int x; cin>>x;
--x;
v[i] = x;
pos[x] = i;
}
forn(i,n){
int x; cin>>x;
--x;
a[x] = i;
}
int ans = 0;
forn(i,n){
if(pos[v[i]] < a[v[i]]){
ans = a[v[i]];
break;
}
}
cout<<ans<<el;
}
int main(){
ios_base::sync_with_stdio(false),
cin.tie(NULL);
precision(20);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int t = 1;
cin>>t;
cases(t) solve();
return 0;
}
//Compile:
//g++ --std=c++17 B.cpp -o a
//How to run the file in any terminal
//./D
//How pass the input in the file
// Input data
//./D < input.txt
// Input data and generate output file
//./D < input.txt > output.txt
// g++ -o a -std=c++20 D.cpp
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3712kb
input:
4 5 1 4 2 5 3 4 5 1 2 3 6 1 2 3 4 5 6 1 2 3 4 5 6 8 8 2 4 7 1 6 5 3 5 6 1 4 8 2 7 3 1 1 1
output:
2 0 4 0
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 3712kb
input:
10000 2 2 1 2 1 2 2 1 1 2 3 3 1 2 3 1 2 3 2 3 1 2 1 3 3 1 3 2 3 1 2 3 1 2 3 3 1 2 3 2 3 1 3 1 2 3 3 2 1 1 2 3 4 3 2 4 1 3 2 4 1 4 1 4 2 3 1 4 3 2 4 4 2 3 1 4 3 2 1 4 4 1 2 3 4 3 1 2 4 2 1 3 4 2 3 4 1 4 3 1 2 4 3 4 2 1 4 3 4 2 1 4 3 2 1 4 3 1 4 2 1 3 2 4 4 2 4 1 3 1 2 4 3 4 4 1 3 2 2 4 1 3 4 3 1 4 2 ...
output:
0 1 0 2 1 1 2 2 0 3 2 2 3 3 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 0 4 3 3 4 4 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...
result:
wrong answer 16th lines differ - expected: '3', found: '1'