QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#35096#4251. Gamewe_wendysCompile Error//C++142.1kb2022-06-13 09:05:412022-06-13 09:05:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-13 09:05:42]
  • 评测
  • [2022-06-13 09:05:41]
  • 提交

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>
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;
//lowest it can get to, highest it can come from
int l[300005], r[300005];
vector<int> g1[300005];
vector<int> g2[300005];

void init(int n_, int k_){
	n = n_, k = k_;
	for(int i = 0; i < k; i++) l[i] = i, r[i] = i;
	for(int i = k; i < n; i++) l[i] = k, r[i] = -1;
}

bool found = false;

void dfs(int x){
	if(found) return;
	for(int i : g1[x]){
		if(r[x] >= l[i]){
			found = true;
			return;
		}
		if(l[x] == l[i] && r[x] == r[i]) continue;
		if(r[x] >= (r[i] + l[i])/2) r[i] = (r[i] + l[i])/2;
		if(l[i] <= (r[x] + l[x])/2) l[x] = (r[x] + l[x])/2;
		if(r[i] <= r[x]) dfs(i);
	}
	for(int i : g2[x]){
		if(r[i] >= l[x]){
			found = true;
			return;
		}
		if(l[x] == l[i] && r[x] == r[i]) continue;
		if(l[x] <= (l[i] + r[i])/2) l[i] = (l[i] + r[i])/2;	
		if(r[i] >= (r[x] + l[x])/2) r[x] = (r[x] + l[x])/2;
		if(l[i] >= l[x]) dfs(i);
	}
}

int add_teleporter(int u, int v){
	if(u < k && v < k) return u >= v;
	g1[u].pb(v);
	g2[v].pb(u);
	for(int i = 0; i < n; i++) dfs(i);
	for(int i = 0; i < n; i++) dfs(i);
	return found;
}

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

詳細信息

/tmp/ccfitQ47.o: In function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'
/tmp/ccupIMDn.o:implementer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status