結果

問題 No.629 グラフの中に眠る門松列
ユーザー ixmelixmel
提出日時 2017-05-08 13:26:13
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 4,000 ms
コード長 1,328 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 88,920 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 17:39:03
合計ジャッジ時間 2,046 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<string,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	vvi fl(n,vi(2));
	bool h=false;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		if(in[a]==in[b])continue;
		int t=in[a]>in[b]?0:1;
		if(fl[a][t  ]&&fl[a][t  ]!=in[b])h=true;
		if(fl[b][t^1]&&fl[b][t^1]!=in[a])h=true;
		fl[a][t  ]=in[b];
		fl[b][t^1]=in[a];
	}
	if(h)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}




0