답안 #47749

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47749 2018-05-07T04:29:40 Z Just_Solve_The_Problem Bitaro’s Party (JOI18_bitaro) C++11
0 / 100
7 ms 5260 KB
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");
#define random (rand() ^ (rand() << 15))

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;

int n, m, q, t, y;
vector < int > gr[N];
vector < int > revgr[N];
int used[N], h[N], deg[N];

void dfs(int v) {
  if (v == t) {
    h[v] = 0;
    return ;
  }
  h[v] = -inf;
  for (int to : gr[v]) {
    dfs(to);
    h[v] = max(h[to] + 1, h[v]);
  }
}

main() {
  scanf("%d %d %d", &n, &m, &q);
//  if (q != 1) return 0;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    gr[u].pb(v);
    deg[v]++;
    revgr[v].pb(u);
  }
  int asd;
  for (int i = 1; i <= n; i++) {
    if (!deg[i]) asd = i;
  }

  while (q--) {
    scanf("%d %d", &t, &y);
    for (int i = 1; i <= y; i++) {
      int x;
      scanf("%d", &x);
      used[x] = 1;
    }
  }
  dfs(asd);
  int mx = -1;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      mx = max(mx, h[i]);
    }
  }
  cout << mx << endl;
}

Compilation message

bitaro.cpp:39:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
bitaro.cpp: In function 'int main()':
bitaro.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &n, &m, &q);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &u, &v);
     ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:55:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &t, &y);
     ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:58:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d", &x);
       ~~~~~^~~~~~~~~~
bitaro.cpp:49:7: warning: 'asd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int asd;
       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 7 ms 5108 KB Output is correct
3 Correct 6 ms 5184 KB Output is correct
4 Incorrect 6 ms 5260 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 7 ms 5108 KB Output is correct
3 Correct 6 ms 5184 KB Output is correct
4 Incorrect 6 ms 5260 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 7 ms 5108 KB Output is correct
3 Correct 6 ms 5184 KB Output is correct
4 Incorrect 6 ms 5260 KB Output isn't correct
5 Halted 0 ms 0 KB -