QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#265659 | #5650. Beppa and SwerChat | BitsPlease# | WA | 6ms | 3776kb | C++20 | 796b | 2023-11-25 20:09:32 | 2023-11-25 20:09:32 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cout << vars << " = ";
string delim = "";
(..., (cout << delim << values, delim = ", "));
cout << '\n';
}
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int &x : a) cin >> x, --x;
vector<int> w(n);
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
--x;
w[x] = i;
}
int mx = 0;
int ans = 0;
for (int x : a) {
if (mx > w[x]) ++ans;
mx = max(mx, w[x]);
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while(t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
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: 6ms
memory: 3776kb
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 1 1 1 2 2 0 1 1 1 2 2 1 2 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 0 1 1 1 2 2 1 2 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 1 2 2 2 3 3 1 2 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 2 3 2 2 3 3 2 3 2 2 3 3 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 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 4th lines differ - expected: '2', found: '1'