B. Sonya and Exhibition codeforces1004 -csdn博客
Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition.
There are n flowers in a row in the exhibition. Sonya can put either a rose or a lily in the i-th position. Thus each of n positions should contain exactly one flower: a rose or a lily.
She knows that exactly m people will visit this exhibition. The i-th visitor will visit all flowers from li to ri inclusive. The girl knows that each segment has its own beauty that is equal to the product of the number of roses and the number of lilies.
Sonya wants her exhibition to be liked by a lot of people. That is why she wants to put the flowers in such way that the sum of beauties of all segments would be maximum possible.
Input
The first line contains two integers n and m (1≤n,m≤103) — the number of flowers and visitors respectively.
Each of the next m lines contains two integersli and ri (1≤li≤ri≤n), meaning that i-th visitor will visit all flowers from li to ri inclusive.
Output
Print the string of n characters. The i-th symbol should be ?0? if you want to put a rose in the i-th position, otherwise ?1? if you want to put a lily.
If there are multiple answers, print any.
Examples
input
5 3
1 3
2 4
2 5
output
01100
input
6 3
5 6
1 4
4 6
output
110010
- 解题思路:直接在奇数位放0,偶数位放1即可,或者反一下。
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<utility>
#define endl '\n'
#define _ ios::sync_with_stdio(false)
bool SUBMIT = 1;
typedef long long ll;
using namespace std;
int n,m;
int main()
{if(!SUBMIT)freopen("i.txt","r",stdin);else _;cin>>n>>m;for(int i=0;i<m;i++){int a,b;cin>>a>>b;}bool f=false;for(int i=0;i<n;i++){if(f)cout<<"0",f=false;elsecout<<"1",f=true;}cout<<endl;return 0;
}