답안 #1099871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099871 2024-10-12T05:40:31 Z horezushol Type Printer (IOI08_printer) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define SZ(x) int((x).size())
const char nl = '\n';
using ll = long long;
using namespace std;

const int N = 25100 * 21;
int nam = 0;
int n;
int trie[N][27];
int dp[N][27];
int dep[N][27];
bitset<N> stop[N];

void add(string s) {
	int x = 0;
	for (auto c : s) {
		if (!trie[x][c-'a']) {
			trie[x][c-'a'] = ++nam;
		}
		dep[x][c-'a'] = max(dep[x][c-'a'], SZ(s));
		x = trie[x][c-'a'];
	}
	stop[x] = 1;
}

vector<char> res;
int fine = 0;
void dfs(int x) {
	if (stop[x] == 1) {
		res.push_back('P');
		fine ++;
	}
	vector<int> topo(26, 0);
	iota(topo.begin(), topo.end(), 0);
	sort(topo.begin(), topo.end(), [&](int a, int b) {
		return dp[x][a] < dp[x][b];
	});
	for (auto c : topo) {
		if (!trie[x][c]) {
			continue;
		}
		res.push_back(c + 'a');
		dfs(trie[x][c]);
	}
	if (fine != n) {
		res.push_back('-');
	}
}

void verkefni() {
	cin >> n;
	for (int i = 0; i < n; i ++) {
		string s; cin >> s;
		add(s);
	}
	dfs(0);
	cout << SZ(res) << nl;
	for (auto el : res) {
		cout << el << nl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tst = 1;
// 	cin >> tst;
	while (tst --) {
		verkefni();
	}
}

Compilation message

/tmp/ccyue0c1.o: in function `void std::__adjust_heap<__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, long, int, __gnu_cxx::__ops::_Iter_comp_iter<dfs(int)::{lambda(int, int)#1}> >(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, long, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int, __gnu_cxx::__ops::_Iter_comp_iter<dfs(int)::{lambda(int, int)#1}>)':
printer.cpp:(.text+0x41): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccyue0c1.o
printer.cpp:(.text+0xcb): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccyue0c1.o
/tmp/ccyue0c1.o: in function `void std::__introsort_loop<__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, long, __gnu_cxx::__ops::_Iter_comp_iter<dfs(int)::{lambda(int, int)#1}> >(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__ops::_Iter_comp_iter<dfs(int)::{lambda(int, int)#1}>, long, __gnu_cxx::__ops::_Iter_comp_iter<dfs(int)::{lambda(int, int)#1}>)':
printer.cpp:(.text+0x1cd): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccyue0c1.o
/tmp/ccyue0c1.o: in function `void std::__insertion_sort<__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__ops::_Iter_comp_iter<dfs(int)::{lambda(int, int)#1}> >(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__ops::_Iter_comp_iter<dfs(int)::{lambda(int, int)#1}>, __gnu_cxx::__ops::_Iter_comp_iter<dfs(int)::{lambda(int, int)#1}>)':
printer.cpp:(.text+0x430): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccyue0c1.o
/tmp/ccyue0c1.o: in function `add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
printer.cpp:(.text+0x551): relocation truncated to fit: R_X86_64_PC32 against symbol `trie' defined in .bss section in /tmp/ccyue0c1.o
printer.cpp:(.text+0x558): relocation truncated to fit: R_X86_64_PC32 against symbol `dep' defined in .bss section in /tmp/ccyue0c1.o
printer.cpp:(.text+0x580): relocation truncated to fit: R_X86_64_PC32 against symbol `nam' defined in .bss section in /tmp/ccyue0c1.o
printer.cpp:(.text+0x589): relocation truncated to fit: R_X86_64_PC32 against symbol `nam' defined in .bss section in /tmp/ccyue0c1.o
/tmp/ccyue0c1.o: in function `dfs(int)':
printer.cpp:(.text+0x703): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccyue0c1.o
printer.cpp:(.text+0x769): relocation truncated to fit: R_X86_64_PC32 against symbol `trie' defined in .bss section in /tmp/ccyue0c1.o
printer.cpp:(.text+0x7e2): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status