QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#474#267401#7626. Quake and Rebuildship2077cmk666Failed.2023-12-04 09:22:142023-12-04 09:22:14

詳細信息

Extra Test:

Invalid Input

input:

200000 200000
1 1 1 4 1 6 5 5 6 5 10 3 7 1 14 2 8 7 1 20 18 17 2 19 9 5 27 13 9 28 21 20 5 31 15 33 32 28 1 9 31 18 38 29 41 24 12 46 8 27 38 36 18 46 50 38 31 28 26 15 34 62 2 38 12 20 19 13 46 24 39 55 24 57 54 69 11 24 48 39 38 35 72 26 15 85 49 33 23 31 29 45 13 47 1 81 9 16 37 49 60 71 38 29 50...

output:


result:

FAIL Integer parameter [name=l] equals to 1, violates the range [2, 200000] (stdin, line 3)

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#267401#7626. Quake and Rebuildcmk666RE 1235ms16504kbC++238.9kb2023-11-27 11:09:572023-12-04 09:33:42

answer

/*
 * @Author:             cmk666
 * @Created time:       2023-11-27 10:08:11
 * @Last Modified time: 2023-11-27 11:09:41
 */
#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
#ifdef LOCAL
#include"debug.h"
#else
#define D(...) ((void)0)
#endif
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
namespace FastIO
{
// ------------------------------
// #define IN_HAS_NEG
// #define OUT_HAS_NEG
// #define CHK_EOF
// #define DISABLE_MMAP
// ------------------------------
#if __cplusplus < 201400
#error Please use C++14 or higher.
#endif
#if __cplusplus > 201700
#define INLINE_V inline
#else
#define INLINE_V
#endif
#if ( defined(LOCAL) || defined(_WIN32) ) && !defined(DISABLE_MMAP)
#define DISABLE_MMAP
#endif
#ifndef DISABLE_MMAP
#include<sys/mman.h>
#endif
#ifdef LOCAL
	inline char gc() { return getchar(); }
	inline void pc(char c) { putchar(c); }
#else
#ifdef DISABLE_MMAP
	INLINE_V constexpr int _READ_SIZE = 1 << 18;
	INLINE_V static char _read_buffer[_READ_SIZE], *_read_ptr = nullptr, *_read_ptr_end = nullptr;
	inline char gc()
	{
		if ( __builtin_expect(_read_ptr == _read_ptr_end, false) )
		{
			_read_ptr = _read_buffer;
			_read_ptr_end = _read_buffer + fread(_read_buffer, 1, _READ_SIZE, stdin);
#ifdef CHK_EOF
			if ( __builtin_expect(_read_ptr == _read_ptr_end, false) ) return EOF;
#endif
		}
		return *_read_ptr++;
	}
#else
	INLINE_V static const char *_read_ptr = (const char *)mmap(nullptr, INT_MAX, 1, 2, 0, 0);
	inline char gc() { return *_read_ptr++; }
#endif
	INLINE_V constexpr int _WRITE_SIZE = 1 << 18;
	INLINE_V static char _write_buffer[_WRITE_SIZE], *_write_ptr = _write_buffer;
	inline void pc(char c)
	{
		*_write_ptr++ = c;
		if ( __builtin_expect(_write_buffer + _WRITE_SIZE == _write_ptr, false) )
		{
			fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout);
			_write_ptr = _write_buffer;
		}
	}
	INLINE_V struct _auto_flush
	{
		inline ~_auto_flush() { fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout); }
	}	_auto_flush;
#endif
#ifdef CHK_EOF
	inline constexpr bool _isdigit(char c) { return ( c & 16 ) && c != EOF; }
	inline constexpr bool _isgraph(char c) { return c > 32 && c != EOF; }
#else
	inline constexpr bool _isdigit(char c) { return c & 16; }
	inline constexpr bool _isgraph(char c) { return c > 32; }
#endif
	template < class T >
	INLINE_V constexpr bool _is_integer = numeric_limits < T >::is_integer;
	template < class T >
	INLINE_V constexpr bool _is_signed = numeric_limits < T >::is_signed;
	template < class T >
	INLINE_V constexpr bool _is_unsigned = _is_integer < T > && !_is_signed < T >;
	template <> INLINE_V constexpr bool _is_integer < __int128 > = true;
	template <> INLINE_V constexpr bool _is_integer < __uint128_t > = true;
	template <> INLINE_V constexpr bool _is_signed < __int128 > = true;
	template <> INLINE_V constexpr bool _is_unsigned < __uint128_t > = true;
#undef INLINE_V
	inline void read(char &c) { do c = gc(); while ( !_isgraph(c) ); }
	inline void read_cstr(char *s)
	{
		char c = gc(); while ( !_isgraph(c) ) c = gc();
		while ( _isgraph(c) ) *s++ = c, c = gc();
		*s = 0;
	}
	inline void read(string &s)
	{
		char c = gc(); s.clear(); while ( !_isgraph(c) ) c = gc();
		while ( _isgraph(c) ) s.push_back(c), c = gc();
	}
#ifdef IN_HAS_NEG
	template < class T, enable_if_t < _is_signed < T >, int > = 0 >
	inline void read(T &x)
	{
		char c = gc(); bool f = true; x = 0;
		while ( !_isdigit(c) ) { if ( c == 45 ) f = false; c = gc(); }
		if ( f ) while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
		else     while ( _isdigit(c) ) x = x * 10 - ( c & 15 ), c = gc();
	}
	template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
	template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
	inline void read(T &x)
	{
		char c = gc(); while ( !_isdigit(c) ) c = gc();
		x = 0; while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
	}
	inline void write(char c) { pc(c); }
	inline void write_cstr(const char *s) { while ( *s ) pc(*s++); }
	inline void write(const string &s) { for ( char c : s ) pc(c); }
#ifdef OUT_HAS_NEG
	template < class T, enable_if_t < _is_signed < T >, int > = 0 >
	inline void write(T x)
	{
		char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
		if ( x >= 0 )  do buffer[digits++] =  ( x % 10 ) | 48, x /= 10; while ( x );
		else { pc(45); do buffer[digits++] = -( x % 10 ) | 48, x /= 10; while ( x ); }
		while ( digits ) pc(buffer[--digits]);
	}
	template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
	template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
	inline void write(T x)
	{
		char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
		do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
		while ( digits ) pc(buffer[--digits]);
	}
	template < int N > struct _tuple_io_helper
	{
		template < class ...T >
		static inline void _read(tuple < T... > &x)
		{ _tuple_io_helper < N - 1 >::_read(x), read(get < N - 1 > (x)); }
		template < class ...T >
		static inline void _write(const tuple < T... > &x)
		{ _tuple_io_helper < N - 1 >::_write(x), pc(32), write(get < N - 1 > (x)); }
	};
	template <> struct _tuple_io_helper < 1 >
	{
		template < class ...T >
		static inline void _read(tuple < T... > &x) { read(get < 0 > (x)); }
		template < class ...T >
		static inline void _write(const tuple < T... > &x) { write(get < 0 > (x)); }
	};
	template < class ...T >
	inline void read(tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_read(x); }
	template < class ...T >
	inline void write(const tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_write(x); }
	template < class T1, class T2 >
	inline void read(pair < T1, T2 > &x) { read(x.first), read(x.second); }
	template < class T1, class T2 >
	inline void write(const pair < T1, T2 > &x) { write(x.first), pc(32), write(x.second); }
	template < class T1, class ...T2 >
	inline void read(T1 &x, T2 &...y) { read(x), read(y...); }
	template < class ...T >
	inline void read_cstr(char *x, T *...y) { read_cstr(x), read_cstr(y...); }
	template < class T1, class ...T2 >
	inline void write(const T1 &x, const T2 &...y) { write(x), write(y...); }
	template < class ...T >
	inline void write_cstr(const char *x, const T *...y) { write_cstr(x), write_cstr(y...); }
	template < class T >
	inline void print(const T &x) { write(x); }
	inline void print_cstr(const char *x) { write_cstr(x); }
	template < class T1, class ...T2 >
	inline void print(const T1 &x, const T2 &...y) { print(x), pc(32), print(y...); }
	template < class ...T >
	inline void print_cstr(const char *x, const T *...y) { print_cstr(x), pc(32), print_cstr(y...); }
	inline void println() { pc(10); }
	inline void println_cstr() { pc(10); }
	template < class ...T >
	inline void println(const T &...x) { print(x...), pc(10); }
	template < class ...T >
	inline void println_cstr(const T *...x) { print_cstr(x...), pc(10); }
}
using namespace FastIO;
int n, m, op, l, r, v, fa[200009], d[200009], tp[200009], qwq, mn, ans;
int b, bl[200009], lp[509], rp[509], tag[509]; bool ok[509], flg, used[200009], vis[200009];
vector < int > ad[509];
inline void build(int id)
{
	if ( ok[id] ) return;
	ok[id] = true;
	For(i, lp[id], rp[id])
	{
		qwq = max(1, fa[i] - tag[id]);
		if ( qwq < lp[id] ) tp[i] = i, d[i] = 1;
		else tp[i] = tp[qwq], d[i] = d[qwq] + 1, ok[id] = false;
	}
}
inline void add(int x)
{
	if ( used[x] ) return;
	used[x] = true, mn = min(mn, x), ad[bl[x]].push_back(x);
}
int main()
{
	read(n, m), b = sqrtl(n);
	For(i, 2, n) read(fa[i]);
	For(i, 1, n) bl[i] = ( i - 1 ) / b + 1;
	For(i, 1, bl[n]) lp[i] = i * b - b + 1, rp[i] = min(n, i * b), build(i);
	For(_, 1, m)
	{
		read(op);
		if ( op == 1 )
		{
			read(l, r, v);
			if ( bl[l] == bl[r] ) { For(i, l, r) fa[i] -= v; build(bl[l]); }
			else
			{
				For(i, l, rp[bl[l]]) fa[i] -= v; build(bl[l]);
				For(i, bl[l] + 1, bl[r] - 1) tag[i] += v, build(i);
				For(i, lp[bl[r]], r) fa[i] -= v; build(bl[r]);
			}
		}
		if ( op == 2 )
		{
			read(l), ans = 1, mn = n + 1;
			For(i, 1, bl[n]) ad[i].clear();
			For(i, 1, l) read(v), add(v);
			Fol(i, bl[n], 1) if ( ad[i].size() )
			{
				flg = false;
				for ( int j : ad[i] ) flg |= vis[tp[j]], vis[tp[j]] = true;
				for ( int j : ad[i] ) vis[tp[j]] = false;
				if ( flg )
				{
					Fol(j, rp[i], lp[i]) if ( used[j] )
					{
						used[j] = false;
						if ( j == mn ) break;
						ans++, add(max(1, fa[j] - tag[i]));
					}
				}
				else
				{
					if ( (int)ad[i].size() == 1 && ad[i][0] == mn ) { used[mn] = false; break; }
					for ( int j : ad[i] ) used[j] = false, ans += d[j], add(max(1, fa[tp[j]] - tag[i]));
				}
			}
			println(ans);
		}
	}
	return 0;
}
// 想上GM捏 想上GM捏 想上GM捏 想上GM捏 想上GM捏
// 伊娜可爱捏 伊娜贴贴捏