1. 程式人生 > 其它 >[考試總結]noip模擬44

[考試總結]noip模擬44

這個真的是一個 \(nb\) 題。

考試快要結束的時候,在機房中只能聽到此起彼伏的撕吼。

啊~~~~~~~~~~

然後人們預測這自己的得分。

\(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\)

\(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\)
\(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\) \(\color{red}{\huge{0}}\)

然後,沒有然後了。

一共一半左右爆 \(\color{red}{\huge{0}}\)

然後戰神直接 \(\color{gold}{\huge{260}}\)

\(\huge{\text{ % % %}}\)

Emotional Flutter

一個細節很多很多的貪心題目,然後只有一個水的一批的樣例。

然後自己用著假的暴力拍著假的正解然後使用假的資料生成器拍了一堆 \(\color{green}{\huge{Accepted}}\)

然後險些有分,反正就是這個題目抱零了。。。

貪心一下,然後注意細節就好。。



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
#define asm(i,x) for(register signed i=head[x];i;i=edge[i].next)
namespace xin_io
{
	#define sb(x) cout<<#x" = "<<x<<' '
	#define jb(x) cout<<#x" = "<<x<<endl
	#define debug cout<<"debug"<<endl
	#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
	char buf[1<<20],*p1 = buf,*p2 = buf; int ak; typedef long long ll; typedef unsigned long long ull;
	class xin_stream{public:template<typename type>inline xin_stream &operator >> (type &s)
	{
		register int f = 0;s = 0; register char ch = gc();
		while(!isdigit(ch)) {f |= ch == '-'; ch = gc();}
		while( isdigit(ch)) s = (s << 1) + (s << 3) + (ch  xor 48),ch = gc(); return s = f ? -s : s,*this;
	}}io;
}
#define int long long
using namespace xin_io; static const int maxn = 1e6+10,inf = 1e9+7; const ll llinf = 1e18+7;
namespace xin
{
	int l[maxn],r[maxn],sum[maxn];
	int T;
	class xin_data
	{
		private:
			friend bool operator < (xin_data x,xin_data y)
			{return x.l == y.l ? x.r < y.r : x.l < y.l;}
		public:
			int l,r;
			xin_data(){}
			xin_data(int l,int r):l(l),r(r){}
	}d[maxn]; int zhi = 0;
	inline short main()
	{
		io >> T;
		while(T--)
		{
			register int s,k,n,ok = 1; io >> s >> k >> n;
			zhi = 0;
			try(i,1,n)
			{
				register int x; io >> x;
				if(i & 1) x += s;
				else x -= s,x %= k;
				if(x > k) ok = 0;
				sum[i] = sum[i-1] + x;
				if(i & 1)
					l[i] = sum[i-1] + 1,r[i] = sum[i] - 1;
//				sb(l[i]); jb(r[i]);
			}
			if(!ok) {puts("NIE"); continue;}
			if(((n & 1) and sum[n] <= k) or (!(n & 1) and sum[n-1] <= k)) {puts("TAK"); continue;}
			for(register int i=1;i<=n;++i,++i)
			{
				register int temp_l = l[i] % k,temp_r = r[i] % k;
				if(temp_r < temp_l)
					d[++zhi] = xin_data(0,temp_r),d[++zhi] = xin_data(temp_l,k-1);
				else d[++zhi] = xin_data(temp_l,temp_r);
			}
			ok = 1;
			std::sort(d+1,d+zhi+1);
			if(d[1].l) {puts("TAK"); continue;}
			int maxx = 0;
			try(i,1,zhi)
			{
				if(maxx < d[i].l - 1) {puts("TAK"); ok = 0;break;}
				maxx = std::max(maxx,d[i].r);
			}
			if(!ok) continue;
			if(maxx < k - 1) puts("TAK");
			else puts("NIE");
		}
		return 0;
	}
}
signed main() {return xin::main();}

Medium Counting

這個計數題目看起來就不是很友好。。。。

我們考慮狂搜,然後抱零。

因為沒有給任何狂搜的分數。

這麼不給我 \(XIN\) 面子的嘛???

然後氣展了。。。

然後應該是用記憶化來做。。

好辦的很。。。



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
#define asm(i,x) for(register signed i=head[x];i;i=edge[i].next)
namespace xin_io
{
	#define sb(x) cout<<#x" = "<<x<<' '
	#define jb(x) cout<<#x" = "<<x<<endl
	#define debug cout<<"debug"<<endl
	#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
	#define cin std::cin
	int ak; typedef long long ll; typedef unsigned long long ull;
	#define scanf ak = scanf
}
#define int long long
using namespace xin_io; static const int maxn = 1e6+10,inf = 1e9+7,mod = 990804011; const ll llinf = 1e18+7;
namespace xin
{	
	int n,m;
	int f[55][51][51][30];
	int a[51][51];
	int xin_team(int l,int r,int p,int c)
	{
		register int &temp = f[l][r][p][c];
		if(~temp) return temp; if(r < l) return temp = 1;
		if(p > m) return temp = (l == r); if(c > 26) return temp = 0;
		temp = xin_team(l,r,p,c+1);
		try(i,l,r) 
		{	
			if(!(a[i][p] == c or (a[i][p] == 27 and c))) break;
			(temp += (xin_team(l,i,p+1,0) * xin_team(i+1,r,p,c+1)) % mod) %= mod;
		}
		return temp;
	}
	char s[maxn];
	inline short main()
	{
		scanf("%lld",&n);
		memset(f,-1,sizeof(f));
		try(i,1,n)
		{
			scanf("%s",s+1);
			int len = strlen(s+1);
			m = std::max(m,len);
			try(j,1,len) a[i][j] = (s[j] == '?') ? 27 : s[j] - 'a' + 1;
		}	
		cout<<xin_team(1,n,1,0)<<endl;
		return 0;
	}
}
signed main() {return xin::main();}

Huge Counting

不會,先鴿了。。

字元消除2

題目就看了老半天。。。

我們用 \(KMP\) 求出來 \(next\) 陣列就可以開始狂跳了。。

真好



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
#define asm(i,x) for(register signed i=head[x];i;i=edge[i].next)
namespace xin_io
{
	#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
	#define debug cout<<"debug"<<endl
	#define sb(x) cout<<#x" = "<<x<<' '
	#define jb(x) cout<<#x" = "<<x<<endl
	#define scanf ak =  scanf
	typedef long long ll; typedef unsigned long long ull; int ak;
}
using namespace xin_io; static const int maxn = 1e6+10,ms = 2e5;
namespace xin
{
	char s[maxn];
	ull a[maxn],p[maxn];
	int T,n,temp;
	int next[maxn];
	int b[maxn];
	ull base = 13331;
	void kmp(int l,int r)
	{
		try(i,l+1,r)
		{
			while(temp and b[i] xor b[temp + 1]) temp = next[temp];
			if(b[i] == b[temp + 1]) temp ++;
			next[i] = temp;
		}
	}
	int q[maxn];
	inline short main()
	{
		scanf("%d",&T); p[1] = 1;
		try(i,2,ms) p[i] = p[i-1] * base;
		while(T--)
		{
			scanf("%s",s+1);
			memset(next,0,sizeof(int) * (n + 1));
			memset(b,0,sizeof(int) * (n + 1));
			q[0] = temp = 0;
			n = strlen(s+1);
			try(i,1,n) a[i] = a[i-1] * base + s[i] - 'A' + 1;
			try(i,0,n) 
				if(a[i+1] == a[n] - a[n-i-1] * p[i + 2]) q[++q[0]] = i + 1;
			if(q[1] > 1) b[q[1]] = 1; kmp(1,q[1]);
			try(i,2,q[0])
			{
				if(q[i] <= q[i-1] * 2)
				{
					try(j,q[i-1]+1,q[i])
						b[j] = b[j + q[i-1] - q[i]];
					kmp(q[i-1],q[i]);
				}
				else
				{
					kmp(q[i-1],q[i] - q[i-1] - 1);
					register int now = temp,z = 1,len =q[i] - q[i-1];
					while(now)
					{
						if(!b[now+1] and !(len % (len - now - 1))) {b[len] = 1; break;}
						now = next[now];
					}
					if(!b[now+1] and !(len % (len - now - 1))) b[len] = 1;
					kmp(len - 1,len);
					next[len] = temp;
					len = q[i] - q[i-1];
					try(j,1,q[i-1]) b[len + j] = b[j];
					kmp(len,len+q[i-1]);
				}
			}
			try(i,1,n) cout<<b[i];
			cout<<endl;
		}
		return 0;
	}
}
signed main() {return xin::main();}