QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#583892#9221. Missing BoundariesChief_NingCompile Error//C++982.3kb2024-09-22 23:39:402024-09-22 23:39:40

Judging History

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

  • [2024-09-22 23:39:40]
  • 评测
  • [2024-09-22 23:39:40]
  • 提交

answer

//https://contest.ucup.ac/contest/1774/problem/9221
#include<bits/stdc++.h>
using namespace std;

using u64 = unsigned long long;
using u32 = unsigned int;
using i64 = long long;

mt19937_64 rnd(random_device{}());

const int mod = 998244353;
const int N = 3e5 + 5;
const int M = 2e5 + 5;

int n, m, s, t;

struct segment {
	int l, r, min;
};

int L;

void RuinGuard(int tc)
{
	cin >> n >> L;
	
	int cnt = 0;
	
	vector<segment> seg(1, {0, 0, 0});
	for(int i = 1; i <= n; i++) {
		int ll, rr;
		cin >> ll >> rr;
		if(ll == -1 && rr == -1) {
			cnt += 1;
		} else if(ll == -1) {
			seg.push_back({ll, rr, rr});
		} else if(rr == -1) {
			seg.push_back({ll, rr, ll});
		} else {
			seg.push_back({ll, rr, min(ll, rr)});
		}
	}
	
	sort(seg.begin() + 1, seg.end(), [&](segment& a, segment& b) -> bool {
		return a.min < b.min;
	});
	
	int siz = seg.size() - 1;
	
	if(!siz) {
		if(n <= L) {
			return cout << "TAK\n", void();
		} else {
			return cout << "NIE\n", void();
		}
	}
	
	for(int i = 1; i <= siz; i++) {
		if(seg[i].l == -1 || seg[i].r == -1) continue;
		if(seg[i].l >= seg[i].r) {
			return cout << "NIE\n", void();
		}
	}
	
	int needNum = 0, canNum = 0;
	
	if(seg[1].l != 1) {
		if(seg[1].l == -1) {
			canNum += seg[1].r - 1;
		} else {
			needNum += 1;
			canNum += seg[1].l - 1;
		}
	}
	
	for(int i = 1; i < siz; i++) {
		if(seg[i].min == seg[i + 1].min) {
			return cout << "NIE\n", void();
		}
		int lft = seg[i].r, rgt = seg[i + 1].l;
		if(lft != -1 && rgt != -1) {
			if(lft >= rgt) {
				return cout << "NIE\n", void();
			}
			int dis = rgt - lft - 1;
			if(dis) {
				needNum += 1;
				canNum += dis;
			}
		} else if(lft == -1) {
			needNum += rgt - seg[i].l - 1;
		} else {
			needNum += seg[i + 1].r - lft - 1;
		} 
	}
	
	if(seg[siz].r != L) {
		if(seg[siz].r == -1) {
			canNum += L - seg[siz].l;
		} else {
			needNum += 1;
			canNum += L - seg[siz].r;
		}
	}
	
	if(cnt >= needNum && cnt <= canNum) {
		return cout << "TAK\n", void();
	} else {
		return cout << "NIE\n", void();
	}
}

signed main()
{ 
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int testcase = 1;
	cin >> testcase;
	
    for(int tc = 1; tc <= testcase; tc++) {
    	RuinGuard(tc);
	}

    return 0;
}

Details

answer.code:5:7: error: expected nested-name-specifier before ‘u64’
    5 | using u64 = unsigned long long;
      |       ^~~
answer.code:6:7: error: expected nested-name-specifier before ‘u32’
    6 | using u32 = unsigned int;
      |       ^~~
answer.code:7:7: error: expected nested-name-specifier before ‘i64’
    7 | using i64 = long long;
      |       ^~~
answer.code:9:1: error: ‘mt19937_64’ does not name a type
    9 | mt19937_64 rnd(random_device{}());
      | ^~~~~~~~~~
answer.code:9:32: error: expected unqualified-id before ‘)’ token
    9 | mt19937_64 rnd(random_device{}());
      |                                ^
answer.code: In function ‘void RuinGuard(int)’:
answer.code:29:32: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   29 |         vector<segment> seg(1, {0, 0, 0});
      |                                ^
answer.code:29:41: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   29 |         vector<segment> seg(1, {0, 0, 0});
      |                                         ^
answer.code:36:39: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   36 |                         seg.push_back({ll, rr, rr});
      |                                       ^
answer.code:36:38: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   36 |                         seg.push_back({ll, rr, rr});
      |                         ~~~~~~~~~~~~~^~~~~~~~~~~~~~
answer.code:38:39: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   38 |                         seg.push_back({ll, rr, ll});
      |                                       ^
answer.code:38:38: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   38 |                         seg.push_back({ll, rr, ll});
      |                         ~~~~~~~~~~~~~^~~~~~~~~~~~~~
answer.code:40:39: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   40 |                         seg.push_back({ll, rr, min(ll, rr)});
      |                                       ^
answer.code:40:38: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   40 |                         seg.push_back({ll, rr, min(ll, rr)});
      |                         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
answer.code:46:9: warning: lambda expressions only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   46 |         });
      |         ^
answer.code:44:13: error: no matching function for call to ‘sort(__gnu_cxx::__normal_iterator<segment*, std::vector<segment> >, std::vector<segment>::iterator, RuinGuard(int)::<lambda(segment&, segment&)>)’
   44 |         sort(seg.begin() + 1, seg.end(), [&](segment& a, segment& b) -> bool {
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   45 |                 return a.min < b.min;
      |                 ~~~~~~~~~~~~~~~~~~~~~
   46 |         });
      |         ~~   
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:2:
/usr/include/c++/13/bits/stl_algo.h:4851:5: note: candidate: ‘template<class _RAIter> void std::sort(_RAIter, _RAIter)’
 4851 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/13/bits/stl_algo.h:4851:5: note:   template argument deduction/substitution failed:
answer.code:44:13: note:   candidate expects 2 arguments, 3 provided
   44 |         sort(seg.begin() + 1, seg.end(), [&](segment& a, segment& b) -> bool {
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   45 |                 return a.min < b.min;
      |                 ~~~~~~~~~~~~~~~~~~~~~
   46 |         });
      |         ~~   
/usr/include/c++/13/bits/stl_algo.h:4882:5: note: candidate: ‘template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)’
 4882 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/13/bits/stl_algo.h:4882:5: note:   template argument deduction/substitution failed:
answer.code: In substitution of ‘template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<segment*, std::vector<segment> >; _Compare = RuinGuard(int)::<lambda(segment&, segment&)>]’:
answer.code:44:6:   required from here
answer.code:44:13: error: template argument for ‘template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)’ uses local type ‘RuinGuard(int)::<lambda(segment&, segment&)>’
   44 |         sort(seg.beg...