zoukankan      html  css  js  c++  java
  • [洛谷] P1276 校门外的树(增强版)

    暴力模拟

    //#pragma GCC optimize(2)
    #include <cstdio>
    #include <iostream>
    #include <cstdlib>
    #include <cmath>
    #include <cctype>
    #include <string>
    #include <cstring>
    #include <algorithm>
    #include <stack>
    #include <queue>
    #include <set>
    #include <map>
    #include <ctime>
    #include <vector>
    #include <fstream>
    #include <list>
    #include <iomanip>
    #include <numeric>
    using namespace std;
    typedef long long ll;
     
    const int MAXN = 1e6 + 10;
    
    int arr[MAXN] = {0};
    
    bool rein[MAXN] = {0};
    
    int main()
    {
    	int n, t, retin = 0;
    	
        cin>>n>>t;
    
        for(int i = 0; i <= n; i++)
        	arr[i] = 1;
    
        while(t--)
        {
            int mode, a, b;
    
            cin>>mode>>a>>b;
    
            if(mode == 0)
            {
                for(int i = a; i <= b; i++)
                {
                    if(rein[i] == true && arr[i] == 1)
                        retin++;
                    else
                        rein[i] = true;
    					
    				arr[i] = 0;
                }
            }
    
            else
            {
                for(int i = a; i <= b; i++)
                {
                    arr[i] = 1;
                }
            }
        }
            
        ll sum = 0;
    
        for(int i = 0; i <= n; i++)
        {
        	if(rein[i] && arr[i])
            	sum ++;
        }
    
        cout<<sum<<endl;
        cout<<retin<<endl;
        
        return 0;
    }
  • 相关阅读:
    socket通信简介
    存储过程多次遍历
    js动态表格笔记
    Java excel导出笔记
    Eclipse快捷键
    oracle表,视图,存储过程,函数,序列.....查询
    Java基础笔记
    Active MQ学习笔记
    linux svn
    html中submit和button的区别
  • 原文地址:https://www.cnblogs.com/zeolim/p/12270454.html
Copyright © 2011-2022 走看看