zoukankan      html  css  js  c++  java
  • 每日算法

    每日算法

    those times when you get up early and you work hard; those times when you stay up late and you work hard; those times when don’t feel like working — you’re too tired, you don’t want to push yourself — but you do it anyway. That is actually the dream. That’s the dream. It’s not the destination, it’s the journey. And if you guys can understand that, what you’ll see happen is that you won’t accomplish your dreams, your dreams won’t come true, something greater will. mamba out


    那些你早出晚归付出的刻苦努力,你不想训练,当你觉的太累了但还是要咬牙坚持的时候,那就是在追逐梦想,不要在意终点有什么,要享受路途的过程,或许你不能成就梦想,但一定会有更伟大的事情随之而来。 mamba out~

    2020.4.1


    627Div3

    A

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cstdlib>
    
    using namespace std;
    const int N = 105;
    int t, a[N];
    int n;
    void work()
    {
    	cin >> n;
    	bool flag1 = 0, flag2 = 0;
    	for(int i = 1;i <= n ;i ++)
    	{
    		scanf("%d",&a[i]);
    		if(a[i] % 2 == 0)
    		{
    			flag1 = 1;
    		}else flag2 = 1;
    	}
    	if(flag1 && flag2){
    		cout << "NO" << endl;
    	}else cout << "YES" << endl;
    } 
    int main()
    {
    
    	cin >> t;
    	while(t--)
    	{
    		work();
    	}
    	return 0;
    }
    

    B

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cstdlib>
    
    using namespace std;
    const int N = 5005;
    int t , n;
    void work()
    {
    	int a[N] = {0};
    	cin >> n;
    	for(int i = 1;i <= n ;i ++)
    	{
    		scanf("%d",&a[i]);
    	}
    	int k = 0;
    	for(int i = 1; i <= n ;i ++)
    	{
    		for(int j = i + 1;j <= n ;j ++)
    		{
    			if(a[j] != a[i])k = 0;
    			if(a[j] == a[i] && j - i > 1 && !k)
    			{
    				cout << "YES" << endl;
    				return ;
    			}
    		}
    	}
    	cout << "NO" << endl;
    	return;
    }
    int main()
    {
    	cin >> t;
    	while(t--)
    	{
    		work();
    	}
    	return 0;
    }
    

    C

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <string>
    #include <algorithm>
    
    using namespace std;
    
    int t = 0;
    
    
    void work()
    {
    	string s;cin >> s;
    	unsigned int i = 0;
    	int minc = 0;int t = 0;
    	while(i < s.size())
    	{
    		if(s[i] == 'L'){
    			t++;
    		}
    		if(s[i] == 'R' || i == s.size() - 1){
    			minc = max(minc,t);
    			t = 0;
    		}
    		i++;
    	}
    	cout << minc + 1 << endl;
    }
    int main()
    {
    	cin >> t;
    	while(t--)
    	{
    		work();
    	}
    	return 0;
    }
    

    P1111 修复公路

    修修公路 复习复习并查集 困~~~

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    
    using namespace std;
    const int N = 1010;
    const int M = 200005;
    int f[N] , n , m;
    struct node{
    	int a , b , c;
    };
    node a[M];
    bool cmp(node a,node b)
    {
    	return a.c < b.c;
    }
    int find(int k)
    {
    	if(f[k] == k)return k;
    	else return f[k] = find(f[k]);
    }
    int main()
    {
    	cin >> n >> m;
    	for(int i = 0;i < m;i ++)
    	{
    		scanf("%d %d %d",&a[i].a,&a[i].b,&a[i].c);	
    	}
    	sort(a , a + m , cmp);
    	for(int i = 1;i <= n ;i ++)f[i] = i;
    	int cnt = 1;
    	for(int i = 0;i < m;i ++)
    	{
    		int x = find(a[i].a), y = find(a[i].b);
    		if(x != y)
    		{
    			f[x] = y;
    			cnt++;
    		}
    		if(cnt == n){
    			cout << a[i].c << endl;
    			return 0;
    		}
    	}
    	cout << -1 << endl;
    	return 0;
    }
    
  • 相关阅读:
    写商业计划书的十个要点
    this page isn't working (ERR_EMPTY_RESPONSE)
    使用meta跳转页面
    fa-list-alt
    在linux下sh批处理文件调用java的方法
    产品使用的前后台框架API-dubbo-redis-elasticsearch-jquery
    JAVA虚拟机关闭钩子(Shutdown Hook)
    xxx is not in the sudoers file.This incident will be reported.的解决方法
    ssh连接docker容器
    namenode namespaceID与datanode namespaceID 不一致导致datanode无法启动的问题
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12616866.html
Copyright © 2011-2022 走看看