# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
226109 | MKopchev | Alternating Current (BOI18_alternating) | C++14 | 2805 ms | 3388 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int nmax=1e5+42;
const double TL=2.8;
int sz,n;
pair<int,int> inp[nmax];
double start;
int type[nmax];
int pref[2][nmax];
mt19937 rng(42);
void test()
{
for(int i=1;i<=sz;i++)
{
pref[0][i]=0;
pref[1][i]=0;
}
for(int i=1;i<=n;i++)
if(inp[i].first<=inp[i].second)
{
pref[type[i]][inp[i].first]++;
pref[type[i]][inp[i].second+1]--;
}
else
{
pref[type[i]][inp[i].first]++;
pref[type[i]][sz+1]--;
pref[type[i]][1]++;
pref[type[i]][inp[i].second+1]--;
}
for(int i=1;i<=sz;i++)
{
pref[0][i]+=pref[0][i-1];
if(pref[0][i]==0)return;
pref[1][i]+=pref[1][i-1];
if(pref[1][i]==0)return;
}
for(int i=1;i<=n;i++)
printf("%i",type[i]);
printf("\n");
exit(0);
}
int main()
{
start=clock();
scanf("%i%i",&sz,&n);
for(int i=1;i<=n;i++)
scanf("%i%i",&inp[i].first,&inp[i].second);
while(1.0*(clock()-start)/CLOCKS_PER_SEC<TL)
{
for(int i=1;i<=n;i++)
type[i]=rng()%2;
test();
}
printf("impossible\n");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |