제출 #1266585

#제출 시각아이디문제언어결과실행 시간메모리
1266585quangminh412Long Mansion (JOI17_long_mansion)C++17
0 / 100
2343 ms17256 KiB
/*
  Ben Watson

  Quang Minh MasterDDDDD
*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long

const string name = "test";

void solve();
signed main()
{
    if (fopen((name + ".inp").c_str(), "r"))
    {
        freopen((name + ".inp").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();

    return 0;
}

// main program
const int maxn = 5e5 + 1;

vector<int> keys[maxn];
int c[maxn], L[maxn], R[maxn];
int n, q;

bool include(int l, int r, int x)
{
    auto it = lower_bound(keys[x].begin(), keys[x].end(), l);
    if (it == keys[x].end())
        return false;
    return ((*it) <= r);
}

void solve()
{
    cin >> n;
    for (int i = 1; i < n; i++)
        cin >> c[i];
    for (int i = 1; i <= n; i++)
    {
        int b; cin >> b;
        for (int j = 0; j < b; j++)
        {
            int a; cin >> a;
            keys[a].push_back(i);
        }
    }

    for (int i = 1; i <= n; i++)
    {
        L[i] = R[i] = i;
        while (1)
        {
            if (L[i] != 1 && include(L[i], R[i], c[L[i] - 1]))
            {
                L[i] = min(L[i], L[L[i] - 1]);
                R[i] = max(R[i], R[L[i] - 1]);
                continue;
            }
            if (R[i] != n && include(L[i], R[i], c[R[i]]))
            {
                R[i]++;
                continue;
            }
            break;
        }
    }

    cin >> q;
    while (q--)
    {
        int x, y; cin >> x >> y;

        cout << (L[x] <= y && y <= R[x] ? "YES\n" : "NO\n");
    }
}

컴파일 시 표준 에러 (stderr) 메시지

long_mansion.cpp: In function 'int main()':
long_mansion.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen((name + ".inp").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
long_mansion.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...