stuck in Codeforces Round 977 C1 2021C1

Правка en2, от yshen94, 2024-10-24 17:27:16

As a newbie, I am just trying to solve Codeforces Round 977 C1.

Initially, I was thinking about any effective data structure. Then I saw some solutions submitted like below, and I just find it really difficult to comprehend. What is the best way to understand what the solution is doing.

int t,n,m,q,a,to[200005],b;

int main(){

scanf("%d",&t);

while(t--){

    scanf("%d%d%d",&n,&m,&q);

    for(int i=1;i<=n;i++)scanf("%d",&a),to[a]=i;

    int ans=1,cur=0;

    for(int i=1;i<=m;i++)scanf("%d",&b),ans&=(to[b]<=cur+1),cur=max(cur,to[b]);

    puts(ans?"YA":"TIDAK");

}

}

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский yshen94 2024-10-24 17:27:16 66
en1 Английский yshen94 2024-10-24 17:26:04 667 Initial revision (published)