zoukankan      html  css  js  c++  java
  • 2020ICPC.小米 网络选拔赛第一场

    Link:
    Nowcoder https://ac.nowcoder.com/acm/contest/7501


    剩下的题就不补了。。


    A. Intelligent Warehouse


    调和级数


    C. Smart Browser


    草草草
    在线模拟草草草

    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cmath>
    #include<cstring>
    #include<cstdlib>
    #include<map>
    using namespace std;
    #define rep(i,j,k) for (int i = j; i <= k; ++i)
    string S;
    int Ans=0;
    int main()
    {
    	ios::sync_with_stdio(false);
    	cin>>S;
    	if(S[0]=='w')++Ans;
    	for(int i=1;i<S.size();++i)
    	{
    		if(S[i]=='w')
    		{
    			++Ans;
    			if(S[i-1]=='w') ++Ans;
    		}
    	}
    	cout<<Ans;
    	return 0;
    }
    


    I. Walking Machine


    有手就能做
    反向建图然后DFS

    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<iomanip>
    #include<cctype>
    #include<cmath>
    #include<ctime>
    #include<queue>
    using namespace std;
    #define getchar() (frS==frT&&(frT=(frS=frBB)+fread(frBB,1,1<<12,stdin),frS==frT)?EOF:*frS++)
    #define ll long long
    char frBB[1<<12],*frS=frBB,*frT=frBB;
    inline void read(int&T)
    {
        int x=0;char ch=getchar();bool w=0;
        while(!isdigit(ch))w|=(ch=='-'),ch=getchar();
        while(isdigit(ch))x=x*10+(ch-48),ch=getchar();
        T=w?-x:x;
    }
    inline void write(ll T)
    {
    	if(T<0)putchar('-'),T=-T;
    	if(T>9)write(T/10);
    	putchar(T%10+48);
    }
    
    
    #define add_edge(a,b) nxt[++tot]=head[a],head[a]=tot,to[tot]=b
    int to[2000005]={},head[1000005],nxt[2000005];
    int Ans=0;
    //int s[1005][1005];
    int n, m, tot=0, N;
    string S[1010];
    void dfs(int x)
    {
    	++Ans;
    	for(int i=head[x];i;i=nxt[i])
    	{
    		dfs(to[i]);
    	}
    }
    int main()
    {
    	cin>>n>>m; N=0;
    	for(int i=1;i<=n;++i)cin>>S[i];
    	char sasa;
    	for(int pret, i=1;i<=n;++i)
    	{
    		for(int j=0;j<m;++j)
    		{
    			++N;
    			sasa = S[i][j];
    			if(sasa=='D')pret=N+1;
    			if(sasa=='W')pret=N-m;
    			if(sasa=='S')pret=N+m;
    			if(sasa=='A')pret=N-1;
    			if(sasa=='D'&&j==m-1)pret=1000001;
    			if(sasa=='W'&&i==1)pret=1000001;
    			if(sasa=='A'&&j==0)pret=1000001;
    			if(sasa=='S'&&i==n)pret=1000001;
    			add_edge(pret,N);
    		}
    	}
    	dfs(1000001);
    	cout<<Ans-1;
        return 0;
    }
    


    J. Matrix Subtraction


    二维差分模板题。
    想不出来也可以直接上二维线段树/树状数组??可能要神力卡常

    只不过用二维差分细节比较多,比较坑。

    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<iomanip>
    #include<cctype>
    #include<cmath>
    #include<ctime>
    #include<queue>
    using namespace std;
    #define rep(ii,jj,kk) for(int ii=jj;ii<=kk;++ii)
    const int MAXN = 1551;
    int n, m, a, b;
    int t;
    long long M[MAXN][MAXN];
    long long P[MAXN][MAXN];
    bool Imp;
    int main()
    {
    	scanf("%d",&t);
    	int i2, j2, c;
    	while(t--)
    	{
    		Imp = false;
    		
    		scanf("%d%d%d%d", &n ,&m, &a, &b);
    		rep(i,0,n+2)rep(j,0,m+2)M[i][j]=P[i][j]=0;
    		rep(i,1,n)rep(j,1,m)scanf("%lld", &M[i][j]);
    		
    		rep(i,1,n+1)
    		{
    			rep(j,1,m+1)
    			{
    				P[i][j]=M[i][j]-M[i-1][j]-M[i][j-1]+M[i-1][j-1];
    			}
    		}
    		
    		rep(i,1,n-a+1)
    		{
    			rep(j,1,m-b+1)
    			{
    				if(!P[i][j]) continue;
    				if(P[i][j]<0) //*****!!!!!!*!*!**!*!*!*!
    				{
    					Imp = true;break;
    				}
    				i2 = i+a, j2 = j+b;
    				c=P[i][j];
    				P[i][j]-=c;
    				P[i][j2]+=c;
    				P[i2][j]+=c;
    				P[i2][j2]-=c;
    			}if(Imp)break;
    		}
    		if(Imp)
    		{
    			puts("QAQ");
    			continue;
    		}
    		rep(i,1,n+1)
    		{
    			rep(j,1,m+1)
    			{
    				P[i][j]+=P[i-1][j]+P[i][j-1]-P[i-1][j-1];
    				if(P[i][j])
    				{
    					Imp = true;
    					break;
    				}
    			}
    			if(Imp)break;
    		}
    		puts(Imp?"QAQ":"^_^");
    	}
        return 0;
    }
    
  • 相关阅读:
    fancybox 基础 简单demo
    fancybox 最基本的使用步骤
    数组元素循环右移问题
    Python爬虫学习(8):浙大软院网络登陆保持
    Python爬虫学习(7):浙大软院网号嗅探
    Python爬虫学习(6): 爬取MM图片
    Python爬虫学习(5): 简单的爬取
    Python爬虫学习(4): python中re模块中的向后引用以及零宽断言
    Python爬虫学习(2): httplib
    Windows远程连接CentOS桌面
  • 原文地址:https://www.cnblogs.com/ccryolitecc/p/13874471.html
Copyright © 2011-2022 走看看