Блог пользователя yshen94

Автор yshen94, история, 13 дней назад, По-английски

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");

}

}

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
13 дней назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by yshen94 (previous revision, new revision, compare).