这个真的是一个 \(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();}