QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#34654#4251. Gamejli505#Compile Error//C++201.7kb2022-06-12 03:53:432024-05-26 00:09:30

Judging History

你现在查看的是最新测评结果

  • [2024-05-26 00:09:30]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-12 03:53:43]
  • 提交

answer

#include "game.h"
using namespace std;

void fastIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

int N, M, K;


vector<int> adj[100100];
 
stack<int> S;
 
int cnt = 0;
int dfn[100100], low[100100];
bool in_stack[100100];
int time_in = 0;
int kingdom[100100];

void init(int n, int k){
    N = n;
    K = k;
    for (int i = 0; i < k-1; i++){
        adj[i].push_back(i+1);
    }
}

void dfs(int node){
    dfn[node] = ++time_in;
    low[node] = dfn[node];
    S.push(node);
    in_stack[node] = true;
    for (int nx : adj[node]){
        if (!dfn[nx]){
            dfs(nx);
            low[node] = min(low[node], low[nx]);
        } else if (in_stack[nx]){
            low[node] = min(low[node], dfn[nx]);
        }
    }
    if (low[node] == dfn[node]){
        ++cnt;
        while (S.top() != node){
            kingdom[S.top()] = cnt;
            in_stack[S.top()] = false;
            S.pop();
        }
        kingdom[S.top()] = cnt;
        in_stack[S.top()] = false;
        S.pop();
    }
}

int kcnt[100100];

int add_teleporter(int u, int v){
    adj[u].push_back(v);
    time_in = 0;
    cnt = 0;
    for (int i = 0; i < N; i++){
        dfn[i] = low[i] = in_stack[i] = kcnt[i] = kingdom[i] = 0;
    }
    while (!S.empty()){
        S.pop();
    }
    for (int i = 0; i < N; i++){
        if (!dfn[i]){
            dfs(i);
        }
    }
    /*for (int i = 0; i < N; i++){
        cout << kingdom[i] << " ";
    }
    cout << "\n";*/
    for (int i = 0; i < N; i++){
        kcnt[kingdom[i]]++;
    }
    bool work = false;
    for (int i = 0; i < K; i++){
        if (kcnt[kingdom[i]] > 1){
            work = true;
        }
    }
    return work;
}

Details

answer.code: In function ‘void fastIO()’:
answer.code:5:5: error: ‘ios_base’ has not been declared
    5 |     ios_base::sync_with_stdio(false);
      |     ^~~~~~~~
answer.code:6:5: error: ‘cin’ was not declared in this scope
    6 |     cin.tie(0);
      |     ^~~
answer.code:2:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
    1 | #include "game.h"
  +++ |+#include <iostream>
    2 | using namespace std;
answer.code: At global scope:
answer.code:12:1: error: ‘vector’ does not name a type
   12 | vector<int> adj[100100];
      | ^~~~~~
answer.code:14:1: error: ‘stack’ does not name a type
   14 | stack<int> S;
      | ^~~~~
answer.code: In function ‘void init(int, int)’:
answer.code:26:9: error: ‘adj’ was not declared in this scope
   26 |         adj[i].push_back(i+1);
      |         ^~~
answer.code: In function ‘void dfs(int)’:
answer.code:33:5: error: ‘S’ was not declared in this scope
   33 |     S.push(node);
      |     ^
answer.code:35:19: error: ‘adj’ was not declared in this scope
   35 |     for (int nx : adj[node]){
      |                   ^~~
answer.code:38:25: error: ‘min’ was not declared in this scope
   38 |             low[node] = min(low[node], low[nx]);
      |                         ^~~
answer.code:40:25: error: ‘min’ was not declared in this scope
   40 |             low[node] = min(low[node], dfn[nx]);
      |                         ^~~
answer.code: In function ‘int add_teleporter(int, int)’:
answer.code:59:5: error: ‘adj’ was not declared in this scope
   59 |     adj[u].push_back(v);
      |     ^~~
answer.code:65:13: error: ‘S’ was not declared in this scope
   65 |     while (!S.empty()){
      |             ^