深圳网站建设zvge,山西省煤炭基本建设局网站,房地产推广方案和推广思路,网站界面模板下载B. The Forbidden Permutation 一定要注意题目中说的是对于all i满足才算不好的#xff0c;我们做的时候只要破坏一个i这个a就不算好的了,被这一点坑了#xff0c;没注意到all。 #include bits/stdc.husing namespace std;
typedef long long LL;
const int N 2e5 …B. The Forbidden Permutation 一定要注意题目中说的是对于all i满足才算不好的我们做的时候只要破坏一个i这个a就不算好的了,被这一点坑了没注意到all。 #include bits/stdc.husing namespace std;
typedef long long LL;
const int N 2e5 10;
int p[N], a[N]; void run()
{ memset(p, 0, sizeof p);int n, m, d; scanf(%d%d%d, n, m, d);for(int i 1; i n; i){int x; scanf(%d, x);p[x] i;}for(int i 1; i m; i) scanf(%d, a[i]);int ans 1e9;for(int i 1; i 1 m; i){if(p[a[i 1]] p[a[i]] || p[a[i 1]] p[a[i]] d){cout 0 endl;return;}if(p[a[i 1]] p[a[i]]) ans min(ans, p[a[i 1]] - p[a[i]]);if(p[a[i 1]] p[a[i]] d)if(d 2 n) ans min(ans, p[a[i]] d 1 - p[a[i 1]]);}printf(%d\n, ans);
}int main()
{
// freopen(1.in, r, stdin);int t;cin t;while(t --) run(); return 0;
}