QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#872995#8621. Knapsackucup-team3099#Compile Error//C++205.9kb2025-01-26 06:57:452025-01-26 06:58:07

Judging History

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

  • [2025-01-26 06:58:07]
  • 评测
  • [2025-01-26 06:57:45]
  • 提交

answer

#ifdef LOCAL
#define _GLIBCXX_DEBUG 1
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

#if 0
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
 
    template<class T>
    using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag,
        __gnu_pbds::tree_order_statistics_node_update>;
#endif

#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <queue>
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <ctime> 
#include <cstring>
#include <random>
#include <chrono>
#include <cassert>

using namespace std;
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)

#define each(a,x) for (auto& a: x)
#define tcT template<class T
#define tcTU tcT, class U
#define tcTUU tcT, class ...U
template<class T> using V = vector<T>; 
template<class T, size_t SZ> using AR = array<T,SZ>;

typedef string str;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
 
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
 
mt19937 rng((unsigned)chrono::steady_clock::now().time_since_epoch().count());
 
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(bool b) { return b ? "true" : "false"; }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(vector<bool> v) { str res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) { str res = ""; F0R(i,SZ) res += char('0'+b[i]); return res; }
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v) { bool fst = 1; str res = "{"; for (const auto& x: v) {if (!fst) res += ", ";	fst = 0; res += ts(x);}	res += "}"; return res;}
template<class A, class B> str ts(pair<A,B> p) {return "("+ts(p.first)+", "+ts(p.second)+")"; }
 
template<class A> void pr(A x) { cout << ts(x); }
template<class H, class... T> void pr(const H& h, const T&... t) { pr(h); pr(t...); }
void ps() { pr("\n"); }
template<class H, class... T> void ps(const H& h, const T&... t) { pr(h); if (sizeof...(t)) pr(" "); ps(t...); }
 
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {cerr << ts(h); if (sizeof...(t)) cerr << ", ";	DBG(t...); }

tcTU> void re(pair<T,U>& p);
tcT> void re(V<T>& v);
tcT, size_t SZ> void re(AR<T,SZ>& a);

tcT> void re(T& x) { cin >> x; }
void re(double& d) { str t; re(t); d = stod(t); }
void re(long double& d) { str t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }

tcTU> void re(pair<T,U>& p) { re(p.first,p.second); }
tcT> void re(V<T>& x) { each(a,x) re(a); }
tcT, size_t SZ> void re(AR<T,SZ>& x) { each(a,x) re(a); }
tcT> void rv(int n, V<T>& x) { x.rsz(n); re(x); }

constexpr bool multitest() {return 0;}
void solve();
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int t = 1;
	if (multitest()) cin >> t;
	for (; t; t--) solve();
}





















#define SZ 3

void solve() {
	int n; 

#ifdef LOCAL
	n=10000;
#else 
	re(n);
#endif

	if (n == 6) {
		ps("ABC.BA");
		return;
	}

	//const ll LIM = 1000000000000ll;
	const ll LIM = 1000000000000ll;
	
	vector<ll> v(n);
#ifdef LOCAL
	mt19937_64 rng6((unsigned)chrono::steady_clock::now().time_since_epoch().count());
	for (int i = 0; i < n; i++) v[i] = uniform_int_distribution(1ll, LIM)(rng6);
#else 
	re(v);
#endif

	sort(all(v));

	int pv = 3000;

	int bst = 0;
	for (int i = 0; i+pv-1 < n; i++) {
		if (v[i+pv-1] - v[i] < v[bst+pv-1] - v[bst]) bst = i;
	}
	dbg(v[bst+pv-1]-v[bst]);

	n = pv;
	v.erase(v.begin(), v.begin()+bst);
	v.erase(v.begin()+n, v.end());

	unordered_map<ll, array<ll, 2>> seen;

	vi loc(n,-1);

	int cnt = 0;
	array<int, SZ> arr;
	while (1) {
		//if ( (sz(gen) + cnt) % 2000000 == 0) dbg(sz(gen), cnt);

		int t = 0;
		for (int i = 0; i < SZ-1; i++) {
			arr[i] = uniform_int_distribution(0, n-i-1)(rng);
		}
		for (int i = SZ-2; i >= 0; i--) {
			for (int j = i+1; j < SZ; j++) if (arr[j] >= arr[i]) arr[j]++;
		}
		for (int i = 0; i <SZ-1; i++) t += arr[i];

		int wa = n/2 * SZ - t;
		arr[SZ-1] = uniform_int_distribution(min(n-1, max(0, wa - 30)), max(0, min(n-1, wa+30)))(rng);

		sort(all(arr));
		for (int i = 0; i < SZ-1; i++) if (arr[i]==arr[i+1]) { cnt++; continue; }

		ll arr_i = arr[0]*1ll*n*n + arr[1]*1ll*n + arr[2];

		ll tot = 0;
		for (int x : arr) tot += v[x];
		
		auto it = seen.insert({tot, {-1, -1}}).first;

		auto mark = [&](ll arr, int x) {
			int a = arr / n / n;
			loc[a]=x;
			a = (arr/n)%n;
			loc[a]=x;
			a = (arr%n);
			loc[a]=x;
		};

		if (it->second[0] != -1) if (it->second[0] == arr_i) { cnt++; continue; }
		if (it->second[1] != -1) {
			if (it->second[1] == arr_i) { cnt++; continue; }

			dbg(it->second);
			mark(it->second[0],0);
			mark(it->second[1],1);
			mark(arr_i,2);

			for (int i = 0; i < bst; i++) pr('.');
			for (int i = 0; i < n; i++) {
				if (loc[i]==-1)pr('.');
				else pr((char)('A'+loc[i]));
			}
			for (int i = 0; i < 10000-n-bst; i++) pr('.');
			ps();

			//dbg(sz(gen), cnt);
			return;
		}

		if (it->second[0] == -1) it->second[0] = arr_i;
		else it->second[1] = arr_i;
	}
}


















































	







Details

answer.code: In function ‘void solve()’:
answer.code:169:9: error: ‘unordered_map’ was not declared in this scope
  169 |         unordered_map<ll, array<ll, 2>> seen;
      |         ^~~~~~~~~~~~~
answer.code:38:1: note: ‘std::unordered_map’ is defined in header ‘<unordered_map>’; this is probably fixable by adding ‘#include <unordered_map>’
   37 | #include <cassert>
  +++ |+#include <unordered_map>
   38 | 
answer.code:169:25: error: expected primary-expression before ‘,’ token
  169 |         unordered_map<ll, array<ll, 2>> seen;
      |                         ^
answer.code:169:38: error: expected primary-expression before ‘>’ token
  169 |         unordered_map<ll, array<ll, 2>> seen;
      |                                      ^~
answer.code:169:41: error: ‘seen’ was not declared in this scope
  169 |         unordered_map<ll, array<ll, 2>> seen;
      |                                         ^~~~