2020.09.12【NOIP提高A组】模拟总结

2020.09.12【NOIP提高A组】模拟总结

很久没有见到提高A组了,回来发现这不是我记忆中的提高A了。

记忆中的提高A,恐怖至极,比赛的策略就是死肝一题,肝出来一道就至少rk10,没肝出来也有人陪你一起爆零,题目特别有趣,而且特别巧妙,线段树和种种算法巧妙结合。
而现在,就是水题(bushi)大作战,显然的套路,根本没有深挖性质的必要,而且数据十分的水(doge),然后还说是2、3题的难度。

不过呢,由于我太菜了,有一题没写。由于我实在太菜了,还写挂了一个细节。

T1:GMOJ 6797. 【2014广州市选day2】hanoi

这道题真的没有什么好说的,打个表:

n ans
1 1
2 3
3 5
4 9
5 13
6 17
7 25
8 33
9 41
10 49

然后发现ans两两的差:2 2 4 4 4 8 8 8 8 16…
规律就出来了。

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

template < class T >
inline void read(T &x)
{
	char ch = getchar(); x = 0; int fg = 1;
	for(;ch < '0' || ch > '9';) ch = getchar();
	for(;ch >= '0' && ch <= '9';) x = x * 10 + (ch ^ '0'), ch = getchar();
}

typedef unsigned long long ll;

int n;
ll ans = 1;

int main()
{
	freopen("hanoi.in","r",stdin);
	freopen("hanoi.out","w",stdout);
	
	read(n); int tmp = 1; ll ret = 2ll;
	for(int i = 2;i <= n; ++ i)
		if(tmp + i >= n) { ans += ret * (n - tmp); break; }
		else ans += ret * i, tmp += i, ret = ret * 2;
	printf("%llu\n",ans);
	
	fclose(stdin); fclose(stdout);
	return 0;
}

T2:6793. 【2014广州市选day1】倒数运算
肯能是整场比赛最难写的吧,考场直接弃了。

看了题大家都会思路,但是至于写呢,只有勇士了吧。

直接贴一个代码吧

#include<cstdio>
#include<cstring>

const int N = 800;
int n, cnt, t = 0, tot, kt, p, nx[N], la[10];

int max(int a, int b){return a > b ? a : b;}
void swap(int &a, int &b){int t = a; a = b, b = t;}

struct BigInt
{
    int num[N + 10], len;
    BigInt() {memset(num, 0, sizeof num), len = 1;}

    bool operator < (const BigInt &cmp) const
	{
        if(len != cmp.len) return len < cmp.len;
        for(int i = len; i >= 1; i--)
            if(num[i] != cmp.num[i]) return num[i] < cmp.num[i];
        return false;
    }

    bool operator > (const BigInt &cmp) const {return cmp < *this;}

    BigInt operator + (const BigInt &A) const
	{
        BigInt S;
        S.len = max(len, A.len);
        for(int i = 1; i <= S.len; i++){
            S.num[i] += num[i] + A.num[i];
            if(S.num[i] >= 10){
                S.num[i] -= 10;
                S.num[i + 1]++;
            }
        }
        while(S.num[S.len + 1]) S.len++;
        return S;
    }

    BigInt operator - (const BigInt &A) const
	{
        BigInt S;
        S.len = max(len, A.len);
        for(int i = 1; i <= S.len; i++){
            S.num[i] += num[i] - A.num[i];
            if(S.num[i] < 0){
                S.num[i] += 10;
                S.num[i + 1]--;
            }
        }
        while(!S.num[S.len] && S.len > 1) S.len--;
        return S;
    }

    BigInt operator * (const BigInt &A) const
	{
        BigInt S;
        if((A.len == 1 && A.num[1] == 0) || (len == 1 && num[1] == 0)) return S;
        S.len = A.len + len - 1;
    	for(int i = 1; i <= len; i++)
            for(int j = 1; j <= A.len; j++){
                S.num[i + j - 1] += num[i] * A.num[j];
                S.num[i + j] += S.num[i + j - 1] / 10;
                S.num[i + j - 1] %= 10;
            }
        while(S.num[S.len + 1]) S.len++;
        return S;
    }
    
 	void itoBig(int x)
	{
        memset(num, 0, sizeof num), len = 1;
        while(x != 0) num[len++] = x % 10, x /= 10;
        if(len != 1) len--;
	}
	
    BigInt operator / (const BigInt &A) const
	{
        BigInt S;
        if((A.len == 1 && A.num[1] == 0) || (len == 1 && num[1] == 0)) return S;
        BigInt R, N;
        S.len = 0; 
        for(int i = len; i >= 1; i--)
		{
            N.itoBig(10);
            R = R * N;
            N.itoBig(num[i]);
            R = R + N;
            int flag = -1;
            for(int j = 1; j <= 10; j++){
                N.itoBig(j);
                if(N * A > R){
                    flag = j - 1;
                    break;
                }
            }
            S.num[++S.len] = flag;
            N.itoBig(flag);
            R = R - N * A;
        }
        for(int i = 1; i <= S.len / 2; i++) swap(S.num[i], S.num[len - i + 1]);
        while(!S.num[S.len] && S.len > 1) S.len--;
        return S;
    }
}I, A, B, Ans;

BigInt itoBig(int x)
{
    BigInt a;
	while(x != 0) a.num[a.len++] = x % 10, x /= 10;
    if(a.len != 1) a.len--;
    return a;
}

bool pd(int a, int b)
{
	for(int i = 0; i <= a - b; i++)
		if(Ans.num[a - i] != Ans.num[b - i]) return 0;
	return 1;
}

int main()
{
	freopen("numdiv.in","r",stdin);
	freopen("numdiv.out","w",stdout);
	
	I.num[I.len = 400] = 1; char c;
	while(c != EOF)
	{
		c = getchar();
		if(c == '.') t++;
		else if(c == '(') t++;
		else if(c == ')') break;
		else if(c >= '0' && c <= '9')
		{
			A = A * itoBig(10) + itoBig(c - '0');
			if(!t) kt++; else if(t == 1) cnt++; else if(t == 2) tot++, B = B * itoBig(10) + itoBig(c - '0');
		}
	}
	if(!tot) for(int i = tot + cnt + 2; i <= 200; i++) A = A * itoBig(10);
	else
	{
		for(int i = tot + cnt + 2; i <= 200; i++)
			A = A * itoBig(10) + itoBig(B.num[tot - p]), p++, p %= tot;
	}
	Ans = I / A;
	for(int i = Ans.len; i > 201; i--) printf("%d", Ans.num[i]);
	bool flag = 0; int jies = 0, jiet = 0;
	for(int i = 200, t; i >= 100; i--)
	{
		t = la[Ans.num[i]];
		while(t)
		{
			if(pd(t, i)) {flag = 1, jies = t, jiet = i + 1; break;}
			t = nx[t];
		}
		if(flag) break;
		nx[i] = la[Ans.num[i]], la[Ans.num[i]] = i;
	}
	if(jies == jiet)
	{
		if(Ans.num[jies] == 9)
		{
			Ans.num[jies + 1]++;
			for(int i = 201; i > jies; i--) printf("%d", Ans.num[i]);
		}
		else
		if(!Ans.num[jies])
		{
			if(Ans.len >= 201)
			{
				printf("%d", Ans.num[201]);
				if(jies < 200) {printf("."); for(int i = 200; i > jies; i--) printf("%d", Ans.num[i]);}
			}
			else printf("0");
		}
		else
		{
			if(Ans.len >= 201) printf("%d.", Ans.num[201]); else printf("0.");
			for(int i = 200; i > jies; i--) printf("%d", Ans.num[i]);
			printf("(%d)", Ans.num[jies]);
		}
	}
	else
	{
		printf("%d.", Ans.num[201]);
		for(int i = 200; i > jies; i--) printf("%d", Ans.num[i]);
		printf("(");
		for(int i = jies; i >= jiet; i--) printf("%d", Ans.num[i]);
		printf(")");
	}
	
	fclose(stdin); fclose(stdout);
	return 0;
}

很好的一道消磨时间的题目。。。

T3:6798. 【2014广州市选day2】regions

这道应该是原题吧,很显然的套路。
离散化,然后每个矩形给个2的次幂值覆盖一下就好了。
然后联通块跑一下就好了。

注意一个细节,这道题是平面,不是第一象限。我也不知道为什么考场理解成了第一象限。

#include <map>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

template < class T >
inline void read(T &x)
{
	char ch = getchar(); x = 0; int fg = 1;
	for(;ch < '0' || ch > '9';) fg = ch == '-' ? -1 : 1, ch = getchar();
	for(;ch >= '0' && ch <= '9';) x = x * 10 + (ch ^ '0'), ch = getchar(); x *= fg;
}

const int N = 1000010,M = 55;
const int P = 1e9 + 7,mod = 998244353;
const int fx[] = { 0,0,1,-1 };
const int fy[] = { 1,-1,0,0 };

map< pair< long,long >, int > vis;
struct node{ int l,t,r,b; } q[N];
int n,buc[N],buc2[N],a[M << 1],b[M << 1],cnt,ans,tag[M << 1][M << 1],num;
long long g[M << 1][M << 1],f[M << 1][M << 1];

void go(int x,int y,pair< long,long > k)
{
	for(int i = 0;i < 4; ++ i)
	{
		int xx = x + fx[i],yy = y + fy[i];
		if((xx < M * 2 && yy < M * 2 && 0 <= xx && 0 <= yy) && g[xx][yy] == k.first && f[xx][yy] == k.second && !tag[xx][yy])
			tag[xx][yy] = num, go(xx,yy,k);
	}
}

int main()
{
	freopen("regions.in","r",stdin);
	freopen("regions.out","w",stdout);
	
	read(n);
	for(int i = 1;i <= n; ++ i)
		read(q[i].l), read(q[i].t), read(q[i].r), read(q[i].b),
		a[++cnt] = q[i].l, b[cnt] = q[i].t, a[++cnt] = q[i].r, b[cnt] = q[i].b;
	sort(a + 1,a + 1 + cnt), sort(b + 1,b + 1 + cnt);
	
	buc[a[1]] = 1; int cur = a[1],now = 1;
	for(int i = 2;i <= cnt; ++ i)
		if(a[i] != cur) now++, buc[a[i]] = now, cur = a[i];
	buc2[cur = b[1]], now = 1;
	for(int i = 2;i <= cnt; ++ i)
		if(b[i] != cur) now++, buc2[b[i]] = now, cur = b[i];
	
	for(int i = 1;i <= n; ++ i)
		q[i].l = buc[q[i].l] + 1, q[i].r = buc[q[i].r],
		q[i].b = buc2[q[i].b] + 1, q[i].t = buc2[q[i].t];
	long long ret = 1,res = 1;
	for(int k = 1;k <= n; ++ k)
	{
		ret = ret * 2 % P, res = res * 2 % mod;
		for(int i = q[k].l;i <= q[k].r; ++ i)
			for(int j = q[k].b;j <= q[k].t; ++ j)
				g[i][j] = (g[i][j] + ret) % P, f[i][j] = (f[i][j] + res) % mod;
	}
	for(int i = 0;i < M * 2 - 5; ++ i)
		for(int j = 0;j < M * 2 - 5; ++ j)
			if(!tag[i][j]) tag[i][j] = ++num, go(i,j,make_pair(g[i][j],f[i][j]));
	
	printf("%d\n",num);
	fclose(stdin); fclose(stdout);
	return 0;
}

T4:6799. 【2014广州市选day2】game

这题应该是过不了,只可惜我搜索之主附身,还有水数据加持,暴力过了。

但是理解错题意四次,浪费了1.5h?!

附上一位dalao的hack数据:

30 30
*.............................
..*...........................
....*.........................
.......*......................
.........*....................
...........*..................
.............*................
...............*..............
.................*............
...................*..........
.....................*........
.......................*......
.........................*....
...........................*..
.............................*
..............................
............................*.
..........................*...
........................*.....
......................*.......
....................*.........
..................*...........
................*.............
..............*...............
............*.................
..........*...................
........*.....................
......*.......................
....*.........................
..*...........................
output:
-1

很快乐,大家一起超时了。
正解还待更,至于水法嘛,安排。

#include <cstdio>
#include <cstring>
#include <algorithm>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC diagnostic error "-std=c++14"
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC optimize("fast-math","unroll-loops","no-stack-protector")
using namespace std;

template < class T >
inline void read(T &x)
{
	char ch = getchar(); x = 0; int fg = 1;
	for(;ch < '0' || ch > '9';) fg = ch == '-' ? -1 : 1, ch = getchar();
	for(;ch >= '0' && ch <= '9';) x = x * 10 + (ch ^ '0'), ch = getchar(); x *= fg;
}

const int N = 35,INF = 0x3f3f3f3f;
const int fx[] = { 0,0,1,-1 };
const int fy[] = { 1,-1,0,0 };

char s[N];
int n,m,a[N][N],vis[N][N],ans = INF,tot,stk[N],g[N][N];

void dfs(int x,int y,int dep,int num)
{
	if(dep > ans) return;
	if(num == 0) { ans = min(ans,dep); return; }
	for(int i = 0;i < 4; ++ i)
	{
		int t = 0,x1 = x + fx[i],y1 = y + fy[i],fg = 0;
		for(int xx = x + fx[i],yy = y + fy[i];0 < xx && xx <= n && 0 < yy && yy <= m;xx += fx[i],yy += fy[i])
			if(vis[xx][yy] || a[xx][yy]) break;
			else fg = 1, vis[xx][yy] = 1, ++t, x1 = xx, y1 = yy;
		if(fg) dfs(x1,y1,dep + 1,num - t);
		if(fg) for(int xx = x + fx[i],yy = y + fy[i];0 < xx && xx <= n && 0 < yy && yy <= m;xx += fx[i],yy += fy[i])
			{ vis[xx][yy] = 0; if(xx == x1 && yy == y1) break; }
	}
}

int main()
{
	freopen("game.in","r",stdin);
	freopen("game.out","w",stdout);
	
	read(n), read(m);
	for(int i = 1;i <= n; ++ i)
	{
		scanf(" %s",s + 1);
		for(int j = 1;j <= m; ++ j) a[i][j] = s[j] == '*', tot += a[i][j] == 0;
	}
		
	for(int i = 1;i <= n; ++ i)
		for(int j = 1;j <= m; ++ j) 
			if(!a[i][j]) memset(vis,0,sizeof vis), vis[i][j] = 1, dfs(i,j,0,tot - 1);
	
	if(ans != INF) printf("%d\n",ans); else puts("-1");
	fclose(stdin); fclose(stdout);
	return 0;
}

这是一篇全是代码的傻逼题解,dalao们不要喷。

但我也不想全部写代码,但是这题。。。我也不知道该怎么说才好。

真心希望以前的提高A能回来。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值