Submission #2380968


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;

typedef long long ll;

#define MAX_V 100005

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 0
Code Size 1351 Byte
Status RE
Exec Time 100 ms
Memory 8052 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 0 / 200 0 / 200
Status
WA × 2
WA × 12
WA × 23
RE × 4
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 WA 2 ms 2560 KB
01-02.txt WA 3 ms 2688 KB
01-03.txt WA 3 ms 2688 KB
01-04.txt WA 3 ms 2688 KB
01-05.txt WA 3 ms 2688 KB
01-06.txt WA 3 ms 2688 KB
01-07.txt WA 3 ms 2688 KB
01-08.txt WA 3 ms 2688 KB
01-09.txt WA 3 ms 2688 KB
01-10.txt WA 3 ms 2688 KB
02-01.txt RE 98 ms 2560 KB
02-02.txt WA 59 ms 7680 KB
02-03.txt WA 52 ms 6144 KB
02-04.txt RE 100 ms 2560 KB
02-05.txt WA 64 ms 7168 KB
02-06.txt RE 99 ms 2560 KB
02-07.txt WA 66 ms 7168 KB
02-08.txt WA 44 ms 7664 KB
02-09.txt RE 98 ms 2560 KB
02-10.txt WA 54 ms 8052 KB
02-11.txt WA 54 ms 8052 KB
02-12.txt WA 54 ms 7040 KB
02-13.txt WA 55 ms 7040 KB
sample-01.txt WA 2 ms 2560 KB
sample-02.txt WA 2 ms 2560 KB