QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#34812#4251. Gamewe_wendys#Compile Error//C++142.6kb2022-06-12 07:58:152024-05-26 00:57:15

Judging History

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

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

answer

//https://qoj.ac/contest/948/problem/4251
//#pragma GCC optimize("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "game.h"
using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

template<class K> using sset =  tree<K, null_type, less<K>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll ceil0(ll a, ll b) {
    return a / b + ((a ^ b) > 0 && a % b);
}

int n, k;

bool to[30005][1005];
bool from[30005][1005];
vector<int> g[30005];
vector<int> g2[30005];

void dfsto(int x, int t){
    to[x][t] = true;
    for(int i : g2[x]){
        if(!to[i][t]) dfsto(i, t);
    }
}

void dfsfrom(int x, int t){
    from[x][t] = true;
    for(int i : g[x]){
        if(!from[x][t]) dfsfrom(i, x);
    }
}

void init(int n_, int k_){
    n = n_, k = k_;
    for(int i = 0; i < n; i++) g[i].clear(), g2[i].clear();
    for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) to[i][j] = from[i][j] = false;
    for(int i = 0; i < k - 1; i++) g[i].pb(i + 1), g2[i + 1].pb(i);
    for(int i = 0; i < k - 1; i++) dfsfrom(i, i);
    for(int i = 1; i < k; i++) dfsto(i, i);
}

int add_teleporter(int u, int v){
    if(u == v){
        if(u < k) return 1;
        return 0;
    }
    if(u < k && v < k){
        if(v < u) return 1;
        return 0;
    }
    if(u > k && v > k){
        g[u].pb(v);
        g2[v].pb(u);
        for(int i = 0; i < k; i++) to[u][i] |= to[v][i], from[v][i] |= from[u][i];
        for(int i = 0; i < k; i++) if(to[u][i] && from[u][i]) return 1;
        for(int i = 0; i < k; i++) if(to[v][i] && from[v][i]) return 1;
        return 0;
    }
    g[u].pb(v);
    g2[v].pb(u);
    if(v < k) dfsto(v, v);
    if(u < k) dfsfrom(u, u);
    for(int i = 0; i < k; i++) to[u][i] |= to[v][i], from[v][i] |= from[u][i];
    if(u > k) for(int i = 0; i < k; i++) if(to[u][i] && from[u][i]) return 1;
    if(v > k) for(int i = 0; i < k; i++) if(to[v][i] && from[v][i]) return 1;
    return 0;
}

int main(){
    int n, k;
    cin >> n >> k;
    init(n, k);
    int a, b;
    while(cin >> a >> b){
        cout << add_teleporter(a, b) << endl;
    }
}

詳細信息

/usr/bin/ld: /tmp/cctWsr1K.o: in function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJCPqmH.o:implementer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status