답안 #365490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
365490 2021-02-11T18:10:02 Z tfg popa (BOI18_popa) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include "popa.h"
#include <stack>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

// query(a, b, c, d) gcd[a, b] == gcd[c, d]

const int ms = 1010;

int liml[ms], limr[ms];

int solve(int l, int r, int* Left, int* Right) {
	if(l >= r) {
		return -1;
	}
	for(int i = l; i < r; i++) {
		if(liml[i] <= l && r <= limr[i]) {
			Left[i] = solve(l, i, Left, Right);
			Right[i] = solve(i+1, r, Left, Right);
			return i;
		}
	}
	assert(0);
}

int solve(int n, int *l, int *r) {
	for(int i = 0; i < n; i++) {
		l[i] = r[i] = -1;
	}
	std::vector<int> st;
	for(int i = 0; i < n; i++) {
		while(!st.empty() && query(st.back(), st.back(), st.back(), i) != 0) {
			// [st.back(), i] isn't good for st.back
			limr[st.back()] = i;
			st.pop_back();
		}
		liml[i] = st.empty() ? 0 : st.back() + 1;
	}
	assert(!st.empty());
	for(auto val : st) {
		limr[val] = n;
	}
	solve(0, n, l, r);
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
}

Compilation message

popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:35:19: warning: control reaches end of non-void function [-Wreturn-type]
   35 |  std::vector<int> st;
      |                   ^~
/tmp/ccjefib6.o: In function `main':
popa.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccLYRmwB.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status