QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#575671#21566. 四维偏序jeffqiCompile Error//C++172.2kb2024-09-19 16:11:422024-09-19 16:11:45

Judging History

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

  • [2024-09-19 16:11:45]
  • 评测
  • [2024-09-19 16:11:42]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define ll long long
#define all(v) v.begin(),v.end()
#define sz(v) ((ll)v.size())
#define V vector
#define vi V<int>
#define vll V<ll>
#define eb emplace_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define A array
#define pb push_back
#define mset multiset
#define gpumap __gnu_pbds::gp_hash_table
#define ccumap __gnu_pbds::cc_hash_table
#define ui unsigned int
#define ull unsigned ll
#define i128 __int128
#define cerr if (test) cerr
#define freopen if (test) freopen
#define whtest if (test)
using namespace std;

const int test = 0;

namespace jhsy {
	template<class F,class Cmp>
	void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
		if (sz(vec) == 1) {
			return;
		}
		if (d == m) {
			return f(vec,cnt);
		}
		const int n = sz(vec),mid = n/2;
		span<int> vl(vec.begin(),vec.begin()+mid);
		vi vr(vec.begin()+mid,vec.end());
		solve(vl,d,cnt,m,f,cmp);
		solve(vr,d,cnt,m,f,cmp);
		vi tmp(n);
		ranges::merge(vl,vr,tmp.begin(),cmp(d));
		for (int i = 0; i < n; i++) {
			vec[i] = tmp[i];
		}
		for (auto x:vr) {
			cnt[x]++;
		}
		solve(tmp,d+1,cnt,m,f,cmp);
		for (auto x:vr) {
			cnt[x]--;
		}
	}
	template<class F,class Cmp>
	void solve(int n,int m,F &&f,Cmp &&cmp) {
		if (!n || !m) {
			return;
		}
		vi vec(n),cnt(n);
		iota(all(vec),0);
		sort(all(vec),cmp(0));
		solve(vec,1,cnt,m,f,cmp);
	}
	const int D = 4;
	void main() {
		int n;
		cin >> n;
		V<A<int,D>> a(n);
		for (auto &p:a) {
			for (auto &x:p) {
				cin >> x;
			}
		}
		ll ans = 0;
		solve(n,D,[&](span<int> vec,const vi &cnt) {
			int k = 0;
			for (auto x:vec) {
				if (!cnt[x]) {
					k++;
				}
				if (cnt[x] == D-1) {
					ans += k;
				}
			}
		},[&](int d) {
			return [&,d](int x,int y) {
				return a[x][d] < a[y][d];
			};
		});
		cout << ans << '\n';
	}
}

int main() {
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);

//	jhsy::init();

	int T = 1;
//	cin >> T;
	while (T--) {
		jhsy::main();
	}

	return 0;
}

详细

answer.code:32:14: error: variable or field ‘solve’ declared void
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |              ^~~~~
answer.code:32:20: error: ‘span’ was not declared in this scope
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |                    ^~~~
answer.code:32:20: note: ‘std::span’ is only available from C++20 onwards
answer.code:32:25: error: expected primary-expression before ‘int’
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |                         ^~~
answer.code:32:34: error: expected primary-expression before ‘int’
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |                                  ^~~
answer.code:32:43: error: expected primary-expression before ‘&’ token
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |                                           ^
answer.code:32:44: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |                                            ^~~
      |                                            int
answer.code:32:48: error: expected primary-expression before ‘int’
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |                                                ^~~
answer.code:32:56: error: expected primary-expression before ‘&&’ token
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |                                                        ^~
answer.code:32:58: error: ‘f’ was not declared in this scope
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |                                                          ^
answer.code:32:64: error: expected primary-expression before ‘&&’ token
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |                                                                ^~
answer.code:32:66: error: ‘cmp’ was not declared in this scope; did you mean ‘Cmp’?
   32 |         void solve(span<int> vec,int d,vi &cnt,int m,F &&f,Cmp &&cmp) {
      |                                                                  ^~~
      |                                                                  Cmp
answer.code: In function ‘void jhsy::main()’:
answer.code:78:31: error: ‘span’ has not been declared
   78 |                 solve(n,D,[&](span<int> vec,const vi &cnt) {
      |                               ^~~~
answer.code:78:35: error: expected ‘,’ or ‘...’ before ‘<’ token
   78 |                 solve(n,D,[&](span<int> vec,const vi &cnt) {
      |                                   ^
answer.code: In lambda function:
answer.code:80:37: error: ‘vec’ was not declared in this scope
   80 |                         for (auto x:vec) {
      |                                     ^~~
answer.code:81:38: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
   81 |                                 if (!cnt[x]) {
      |                                      ^~~
      |                                      int
answer.code:84:37: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
   84 |                                 if (cnt[x] == D-1) {
      |                                     ^~~
      |                                     int
answer.code: In instantiation of ‘void jhsy::solve(int, int, F&&, Cmp&&) [with F = main()::<lambda(int)>; Cmp = main()::<lambda(int)>]’:
answer.code:78:8:   required from here
answer.code:65:22: error: no matching function for call to ‘solve(std::vector<int>&, int, std::vector<int>&, int&, jhsy::main()::<lambda(int)>&, jhsy::main()::<lambda(int)>&)’
   65 |                 solve(vec,1,cnt,m,f,cmp);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code:58:14: note: candidate: ‘template<class F, class Cmp> void jhsy::solve(int, int, F&&, Cmp&&)’
   58 |         void solve(int n,int m,F &&f,Cmp &&cmp) {
      |              ^~~~~
answer.code:58:14: note:   template argument deduction/substitution failed:
answer.code:65:22: note:   candidate expects 4 arguments, 6 provided
   65 |                 solve(vec,1,cnt,m,f,cmp);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:98:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   98 |         freopen("test.in","r",stdin);
      |                ^
answer.code:99:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   99 |         freopen("test.out","w",stdout);
      |                ^