Submission #2380972
Source Code Expand
#include<bits/stdc++.h> #define REP(i,n) for(int i = 0;i < (n);i++) #define P pair<int,int> #define pb push_back #define mk make_pair using namespace std; const int INF = 1e9+1000; typedef long long ll; #define MAX_V 110005 struct edge { int to; int cost; }; int V; vector<edge> G[MAX_V]; int d[MAX_V]; void dijkstra(int s) { priority_queue<P, vector<P>, greater<P> > que; fill(d, d+V, INF); d[s] = 0; que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int v = p.second; if (d[v] < p.first) continue; for (int i=0; i<G[v].size(); ++i) { edge e = G[v][i]; if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.push(P(d[e.to], e.to)); } } } } int main(){ int m; int p; cin >> V >> m; REP(i,V){ int k; cin >> k; REP(j,k){ int f,t,c; cin >> t; t--; t += V; f = i; c = 1; edge e = {t,c}; G[f].pb(e); e.to = f; G[t].pb(e); } } V += m; dijkstra(0); bool f = true; REP(i,V-m){ if(d[i] == INF) f = false; } if(f) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | kodamune |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 1356 Byte |
Status | RE |
Exec Time | 98 ms |
Memory | 8308 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 0 / 200 | ||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
dataset1 | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt |
dataset2 | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 2 ms | 2816 KB |
01-02.txt | AC | 3 ms | 2816 KB |
01-03.txt | AC | 3 ms | 2944 KB |
01-04.txt | AC | 3 ms | 2944 KB |
01-05.txt | AC | 3 ms | 2944 KB |
01-06.txt | AC | 3 ms | 2816 KB |
01-07.txt | AC | 3 ms | 2816 KB |
01-08.txt | AC | 3 ms | 2816 KB |
01-09.txt | AC | 3 ms | 2816 KB |
01-10.txt | AC | 3 ms | 2944 KB |
02-01.txt | AC | 57 ms | 7168 KB |
02-02.txt | AC | 60 ms | 7936 KB |
02-03.txt | AC | 52 ms | 6400 KB |
02-04.txt | RE | 98 ms | 2816 KB |
02-05.txt | AC | 64 ms | 7424 KB |
02-06.txt | RE | 98 ms | 2816 KB |
02-07.txt | AC | 64 ms | 7424 KB |
02-08.txt | AC | 44 ms | 7920 KB |
02-09.txt | RE | 98 ms | 2816 KB |
02-10.txt | AC | 55 ms | 8308 KB |
02-11.txt | AC | 57 ms | 8308 KB |
02-12.txt | AC | 54 ms | 7220 KB |
02-13.txt | AC | 54 ms | 7296 KB |
sample-01.txt | AC | 2 ms | 2816 KB |
sample-02.txt | AC | 2 ms | 2816 KB |