結果

問題 No.1290 Addition and Subtraction Operation
ユーザー 👑 NachiaNachia
提出日時 2020-11-17 19:08:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 476 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 167,408 KB
実行使用メモリ 12,556 KB
最終ジャッジ日時 2023-09-30 14:22:17
合計ジャッジ時間 9,839 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 6 ms
10,688 KB
testcase_05 AC 4 ms
10,524 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 5 ms
10,712 KB
testcase_13 AC 5 ms
10,660 KB
testcase_14 AC 4 ms
10,572 KB
testcase_15 AC 5 ms
10,640 KB
testcase_16 AC 4 ms
10,508 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 5 ms
10,636 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 4 ms
10,728 KB
testcase_26 AC 4 ms
10,576 KB
testcase_27 WA -
testcase_28 AC 5 ms
10,508 KB
testcase_29 AC 5 ms
10,640 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 5 ms
10,756 KB
testcase_33 AC 4 ms
10,588 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 4 ms
10,768 KB
testcase_37 WA -
testcase_38 AC 4 ms
10,704 KB
testcase_39 AC 4 ms
10,720 KB
testcase_40 AC 4 ms
10,636 KB
testcase_41 AC 4 ms
10,696 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 AC 35 ms
12,328 KB
testcase_58 AC 45 ms
12,356 KB
testcase_59 AC 34 ms
12,324 KB
testcase_60 AC 75 ms
12,456 KB
testcase_61 AC 60 ms
12,340 KB
testcase_62 AC 65 ms
12,280 KB
testcase_63 AC 45 ms
12,332 KB
testcase_64 AC 23 ms
12,348 KB
testcase_65 AC 29 ms
12,340 KB
testcase_66 AC 52 ms
12,388 KB
testcase_67 AC 77 ms
12,340 KB
testcase_68 AC 62 ms
12,360 KB
testcase_69 AC 45 ms
12,544 KB
testcase_70 AC 42 ms
12,352 KB
testcase_71 AC 50 ms
12,320 KB
testcase_72 AC 30 ms
12,320 KB
testcase_73 AC 56 ms
12,320 KB
testcase_74 AC 22 ms
12,328 KB
testcase_75 AC 26 ms
12,428 KB
testcase_76 AC 42 ms
12,264 KB
testcase_77 WA -
testcase_78 AC 75 ms
12,348 KB
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 AC 67 ms
12,324 KB
testcase_83 AC 91 ms
12,360 KB
testcase_84 AC 85 ms
12,284 KB
testcase_85 AC 50 ms
12,496 KB
testcase_86 AC 41 ms
12,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define R(i,n) for(int i=0; i<(n); i++)

using V=vector<LL>;

V v(1e6);
LL rt(LL a){ return v[a]!=a?v[a]=rt(v[a]):a; }

int main(){
	LL n,q; cin>>n>>q;
	V A(n+1); R(i,n) cin>>A[i];
	R(i,n) if(i%2) A[i]*=-1;
	R(i,n) A[n-i]-=A[n-i-1];

	R(i,n) v[i]=i;
	R(i,q){ LL l,r; cin>>l>>r; v[rt(--l)]=rt(r); }

	V S(n);
	R(i,n) S[v[rt(i)]]+=A[i];
	LL ok=1;
	R(i,n) if(S[i]) ok=0;
	cout<<(ok?"YES\n":"NO\n");

	return 0;
}

0