Submission #57129879
Source Code Expand
#include<bits/stdc++.h> #ifdef xay5421 #define D(...) fprintf(stderr,__VA_ARGS__) #define DD(...) D(#__VA_ARGS__ "="),debug_helper::debug(__VA_ARGS__),D("\n") #include"/home/xay5421/debug.hpp" #else #define D(...) ((void)0) #define DD(...) ((void)0) #endif #define pb push_back #define eb emplace_back #define SZ(x) ((int)(x).size()) #define each(x,v) for(auto&x:v) #define rep(i,a,b) for(int i=(a);i<=(b);++i) #define per(i,a,b) for(int i=(a);i>=(b);--i) template<class T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;} template<class T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);} using namespace std; using LL=long long; using ULL=unsigned long long; const int N=250005; int T; int n,K,a[N],b[N]; int lst[N]; int main(){ #ifdef xay5421 freopen("a.in","r",stdin); #endif rd(T); while(T--){ rd(n),rd(K); rep(i,1,n)rd(a[i]); rep(i,1,n)rd(b[i]); if(K==1){ int pos=1; int err=0; rep(i,1,n){ while(pos<=n&&a[pos]!=b[i])++pos; if(pos>n)err=1; } puts(err?"No":"Yes"); }else{ int flag=1; rep(i,1,n)flag&=a[i]==b[i]; if(flag){ puts("Yes"); continue; } int good=0; rep(i,1,n)lst[i]=0; rep(i,1,n){ if(lst[b[i]]){ if(i-lst[b[i]]<=K){ good=1; } } lst[b[i]]=i; } rep(i,1,n)lst[a[i]]=0; int err=0; rep(i,1,n)if(lst[i]){err=1;break;} puts(err||!good?"No":"Yes"); } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Near Assignment |
User | xay5421 |
Language | C++ 20 (gcc 12.2) |
Score | 600 |
Code Size | 1574 Byte |
Status | AC |
Exec Time | 16 ms |
Memory | 6572 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-sample-001.txt |
All | 00-sample-001.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt, 01-032.txt, 01-033.txt, 01-034.txt, 01-035.txt, 01-036.txt, 01-037.txt, 01-038.txt, 01-039.txt, 01-040.txt, 01-041.txt, 01-042.txt, 01-043.txt, 01-044.txt, 01-045.txt, 01-046.txt, 01-047.txt, 01-048.txt, 01-049.txt, 01-050.txt, 01-051.txt, 01-052.txt, 01-053.txt, 01-054.txt, 01-055.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-sample-001.txt | AC | 1 ms | 3448 KiB |
01-001.txt | AC | 10 ms | 3464 KiB |
01-002.txt | AC | 9 ms | 3468 KiB |
01-003.txt | AC | 9 ms | 3568 KiB |
01-004.txt | AC | 8 ms | 3484 KiB |
01-005.txt | AC | 8 ms | 3508 KiB |
01-006.txt | AC | 8 ms | 3460 KiB |
01-007.txt | AC | 7 ms | 3480 KiB |
01-008.txt | AC | 7 ms | 3480 KiB |
01-009.txt | AC | 8 ms | 3660 KiB |
01-010.txt | AC | 8 ms | 3460 KiB |
01-011.txt | AC | 9 ms | 3476 KiB |
01-012.txt | AC | 11 ms | 3620 KiB |
01-013.txt | AC | 16 ms | 6420 KiB |
01-014.txt | AC | 14 ms | 5328 KiB |
01-015.txt | AC | 14 ms | 5416 KiB |
01-016.txt | AC | 14 ms | 5388 KiB |
01-017.txt | AC | 8 ms | 5464 KiB |
01-018.txt | AC | 9 ms | 5328 KiB |
01-019.txt | AC | 9 ms | 5444 KiB |
01-020.txt | AC | 10 ms | 5420 KiB |
01-021.txt | AC | 12 ms | 5452 KiB |
01-022.txt | AC | 12 ms | 5444 KiB |
01-023.txt | AC | 13 ms | 5448 KiB |
01-024.txt | AC | 13 ms | 5460 KiB |
01-025.txt | AC | 15 ms | 5412 KiB |
01-026.txt | AC | 15 ms | 5448 KiB |
01-027.txt | AC | 5 ms | 5388 KiB |
01-028.txt | AC | 5 ms | 5600 KiB |
01-029.txt | AC | 6 ms | 5460 KiB |
01-030.txt | AC | 6 ms | 6572 KiB |
01-031.txt | AC | 7 ms | 6424 KiB |
01-032.txt | AC | 7 ms | 6416 KiB |
01-033.txt | AC | 8 ms | 6552 KiB |
01-034.txt | AC | 8 ms | 6384 KiB |
01-035.txt | AC | 8 ms | 6500 KiB |
01-036.txt | AC | 8 ms | 6416 KiB |
01-037.txt | AC | 10 ms | 6368 KiB |
01-038.txt | AC | 10 ms | 6420 KiB |
01-039.txt | AC | 10 ms | 6436 KiB |
01-040.txt | AC | 9 ms | 6436 KiB |
01-041.txt | AC | 11 ms | 6440 KiB |
01-042.txt | AC | 11 ms | 6364 KiB |
01-043.txt | AC | 11 ms | 6392 KiB |
01-044.txt | AC | 11 ms | 6428 KiB |
01-045.txt | AC | 13 ms | 6420 KiB |
01-046.txt | AC | 13 ms | 6360 KiB |
01-047.txt | AC | 12 ms | 6380 KiB |
01-048.txt | AC | 12 ms | 6420 KiB |
01-049.txt | AC | 14 ms | 6384 KiB |
01-050.txt | AC | 14 ms | 6368 KiB |
01-051.txt | AC | 9 ms | 5328 KiB |
01-052.txt | AC | 11 ms | 6416 KiB |
01-053.txt | AC | 12 ms | 6392 KiB |
01-054.txt | AC | 13 ms | 6436 KiB |
01-055.txt | AC | 15 ms | 6572 KiB |