Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
34396 swzzzz 【S】T1 C++ 通过 100 282 MS 10012 KB 613 2024-11-07 18:36:04

Tests(10/10):


#include<bits/stdc++.h> using namespace std; #define N 1000006 int n; bool s[N]; int r[N],t[N]; bool d[N]; char ch; long long ans; bool now; int main(){ cin>>n; cin>>ch; s[1]=(ch=='1'); for(int i=2;i<=n;i++){ ch=getchar(); s[i]=(ch=='1'); } for(int i=1;i<=n;i++){ scanf("%d",&r[i]); } for(int i=1;i<=n;i++){ scanf("%d",&t[i]); } for(int i=1;i<=n;i++){ if(now!=s[i]){ ans+=t[i]; now^=1; d[r[i]]^=1; } now^=d[i]; } cout<<ans; return 0; }


测评信息: