# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
345842 | kshitij_sodani | Broken Device (JOI17_broken_device) | C++14 | 48 ms | 2848 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.
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
#include "Annalib.h"
int vis[151];
int ans[151];
void Anna( int n, long long x, int k, int pp[] ){
for(int i=0;i<n;i++){
vis[i]=0;
ans[i]=0;
}
for(int i=0;i<k;i++){
vis[pp[i]]=1;
}
int cur=-1;
int la=-1;
for(int i=0;i<n;i++){
if(cur==60){
break;
}
if(vis[i]==0){
if(cur==-1){
ans[i]=1;
cur++;
la=i;
continue;
/*if(i%2==0){
ans[i]=1;
cur++;
}*/
continue;
}
if(x&(1LL<<cur)){
if((i-la)%2==0){
ans[i]=1;
cur++;
la=i;
}
}
else{
if((i-la)%2==1){
ans[i]=1;
cur++;
la=i;
}
}
}
}
//if(cur==60){
for( int i = 0; i < n; i++ ){
Set( i, ans[i] );
}
return;
//}
cur=-1;
for(int i=0;i<n;i++){
ans[i]=0;
}
for(int i=0;i<n;i++){
if(cur==60){
break;
}
if(vis[i]==0){
if(cur==-1){
if(i%2==1){
cur++;
ans[i]=1;
}
continue;
}
if(x&(1LL<<cur)){
if(i%2==0){
ans[i]=1;
cur++;
}
}
else{
if(i%2==1){
ans[i]=1;
cur++;
}
}
}
}
for( int i = 0; i < n; i++ ){
Set( i, ans[i] );
}
}
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
#include "Brunolib.h"
long long Bruno( int n, int aa[] ){
vector<int> ss;
llo ans=0;
int x=-1;
for(int i=0;i<n;i++){
if(aa[i]==1){
/*if(x==-1){
x=i;
continue;
}*/
ss.pb(i);
}
}
for(int i=1;i<ss.size();i++){
if((ss[i]-ss[i-1])%2==0){
ans+=(1LL<<(i-1));
}
}
return ans;
if(x%2==0){
for(int i=0;i<ss.size();i++){
if((ss[i]%2==1)){
ans+=(1LL<<i);
}
}
}
else{
for(int i=0;i<ss.size();i++){
if((ss[i]%2==0)){
ans+=(1LL<<i);
}
}
}
return ans;
}
//g++ -std=c++14 -O2 -o aa grader.cpp Anna.cpp Bruno.cpp
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |