답안 #87757

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87757 2018-12-02T10:16:38 Z win11905 Bitaro’s Party (JOI18_bitaro) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
 
const int N = 1e5+5;
const int INF = 1e9;
const int sz = 10;
 
int n, m, q;
vector<int> g[N], topo;
vector<pii> block[N];
int pos[N], deg[N];
int d[N];
map<int, int> tod[N];
bool mark[N];
 
int getInt() {
  int num = 0;
  register int x = -1;
  while(x < '0' || x > '9') x = getchar_unlock();
  for(; x >= '0' && x <= '9'; x = getchar_unlock()) num = (num << 1) + (num << 3) + x - '0';
  return num;
}
int main() {
    n = getInt(); m = getInt(); q = getInt();
    for(int i = 0, u, v; i < m; ++i) {
        u = getInt(); v = getInt();
        if(u > v) swap(u, v);
        g[u].emplace_back(v);
        deg[v]++;
    }
    queue<int> Q;
    for(int i = 1; i <= n; ++i) if(!deg[i]) Q.emplace(i);
    while(!Q.empty()) {
        int u = Q.front(); Q.pop();
        topo.emplace_back(u);
        for(auto x : tod[u]) block[u].emplace_back(x);
        block[u].emplace_back(u, 0);
        sort(all(block[u]), [&](const pii &a, const pii &b) { return a.y > b.y; });
        if(block[u].size() > sz) block[u].resize(sz);
        for(int v : g[u]) {
            for(pii x : block[u]) tod[v][x.x] = max(tod[v][x.x], x.y + 1);
            if(!--deg[v]) Q.emplace(v);
        }    
    }
    for(int i = 0, u, t; i < q; ++i) {
        scanf("%d %d", &u, &t);
        vector<int> vec;
        for(int i = 0, v; i < t; ++i) scanf("%d", &v), vec.emplace_back(v);
        if(t < sz) {
            for(int v : vec) mark[v] ^= 1;
            bool st = true;
            for(pii v : block[u]) if(!mark[v.x]) {
                printf("%d\n", v.y), st = false;
                break;
            }
            if(st) puts("-1");
            for(int v : vec) mark[v] ^= 1;
        } else {
            memset(d, 0, sizeof d);
            for(int v : vec) d[v] = -INF;
            for(int i = 0; i < n; ++i) {
                int u = topo[i];
                for(int v : g[u]) d[v] = max(d[v], d[u] + 1);
            }
            printf("%d\n", d[u] < 0 ? -1 : d[u]);
        }
    } 
}

Compilation message

bitaro.cpp: In function 'int getInt()':
bitaro.cpp:23:33: error: 'getchar_unlock' was not declared in this scope
   while(x < '0' || x > '9') x = getchar_unlock();
                                 ^~~~~~~~~~~~~~
bitaro.cpp:23:33: note: suggested alternative: 'getchar_unlocked'
   while(x < '0' || x > '9') x = getchar_unlock();
                                 ^~~~~~~~~~~~~~
                                 getchar_unlocked
bitaro.cpp:24:35: error: 'getchar_unlock' was not declared in this scope
   for(; x >= '0' && x <= '9'; x = getchar_unlock()) num = (num << 1) + (num << 3) + x - '0';
                                   ^~~~~~~~~~~~~~
bitaro.cpp:24:35: note: suggested alternative: 'getchar_unlocked'
   for(; x >= '0' && x <= '9'; x = getchar_unlock()) num = (num << 1) + (num << 3) + x - '0';
                                   ^~~~~~~~~~~~~~
                                   getchar_unlocked
bitaro.cpp: In function 'int main()':
bitaro.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &u, &t);
         ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:52:54: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for(int i = 0, v; i < t; ++i) scanf("%d", &v), vec.emplace_back(v);
                                       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~