답안 #70678

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70678 2018-08-23T08:26:17 Z Just_Solve_The_Problem Long Mansion (JOI17_long_mansion) C++11
0 / 100
3000 ms 9676 KB
#include <bits/stdc++.h>

using namespace std;

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

int n;
int c[N];
vector < int > keys[N];
pair < int, int > lr[N];
int has[N];

main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d", &c[i]);
  }
  for (int i = 1; i <= n; i++) {
    int siz;
    scanf("%d", &siz);
    for (int j = 0; j < siz; j++) {
      int x;
      scanf("%d", &x);
      keys[i].push_back(x);
    }
    lr[i] = {i, i};
  }
  for (int i = 1; i <= n; i++) {
    int ok = 1;
    for (int to : keys[i]) {
      has[to] = i;
    }
    while (ok) {
      ok = 0;
      while (has[c[lr[i].second]] == i) {
        lr[i].second++;
        for (int to : keys[lr[i].second]) {
          has[to] = i;
        }
        ok = 1;
      }
      while (has[c[lr[i].first - 1]] == i) {
        lr[i].first--;
        for (int to : keys[lr[i].first]) {
          has[to] = i;
        }
        ok = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d %d\n", lr[i].first, lr[i].second);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r;
    scanf("%d %d", &l, &r);
    if (lr[l].first <= r && r <= lr[l].second) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
}

Compilation message

long_mansion.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
long_mansion.cpp: In function 'int main()':
long_mansion.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
long_mansion.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &c[i]);
     ~~~~~^~~~~~~~~~~~~
long_mansion.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &siz);
     ~~~~~^~~~~~~~~~~~
long_mansion.cpp:23:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d", &x);
       ~~~~~^~~~~~~~~~
long_mansion.cpp:55:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
   ~~~~~^~~~~~~~~~
long_mansion.cpp:58:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &l, &r);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3027 ms 9676 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2904 KB Output isn't correct
2 Halted 0 ms 0 KB -