Submission #345963

#TimeUsernameProblemLanguageResultExecution timeMemory
345963kshitij_sodaniBroken Device (JOI17_broken_device)C++14
8 / 100
53 ms2992 KiB
//#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]; /*vector<llo> yy={0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 1,1,1,1,1,1, 1,1,1,1,1,1, 1,1,1,1,1,1, 1,1,1,1,1,1};*/ 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; } vector<int> kk; for(int i=0;i<n;i++){ if(vis[i]==0){ kk.pb(i); } } int cot=0; llo mm=0; for(int i=0;i<60;i++){ if((1LL<<i)&x){ } else{ mm+=1; } } llo st=0; if(mm<30){ st=1; x=(1LL<<60)-x-1; } //while(cot<kk.size()){ int cur=-1; int la=-1; for(int i=0;i<n;i++){ ans[i]=0; } llo le=x; int kkc=0; for(int i=0;i<n;i++){ if(kkc==1){ kkc=0; continue; } kkc=0; if(cur==60){ break; } /* if(i<kk[cot]){ continue; }*/ if(vis[i]==0){ if(cur==-1){ if(i%2==st){ continue; } ans[i]=1; cur++; la=i; continue; /*if(i%2==0){ ans[i]=1; cur++; }*/ continue; } /*llo xx=0; if(cur>=40){ xx=1; }*/ if(x&(1LL<<cur)){ if(i<n-1){ if(vis[i]==0 and vis[i+1]==0){ ans[i]=1; ans[i+1]=1; kkc=1; le-=(1LL<<cur); ans[i]=1; cur++; la=i; } } /*if((i-la)%2==1){ le-=(1LL<<cur); ans[i]=1; cur++; la=i; }*/ } else{ //if((i-la)%2==0){ ans[i]=1; cur++; kkc=1; la=i; //} } } } //cout<<cur<<":"<<endl; /* if(le==0){ break; }*/ cot++; //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" /*vector<llo> yy2={0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 1,1,1,1,1,1, 1,1,1,1,1,1, 1,1,1,1,1,1, 1,1,1,1,1,1};*/ 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); } } int ind=1; llo cot=0; while(ind<ss.size()){ if(ind+1==ss.size()){ break; } if(ss[ind+1]==ss[ind]+1){ ans+=(1LL<<cot); cot++; ind+=2; } else{ cot++; ind+=1; } } /*for(int i=1;i<ss.size();i++){ if((ss[i]-ss[i-1])%2==1){ ans+=(1LL<<(i-1)); } }*/ if(ss[0]%2==0){ ans=(1LL<<60)-ans-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)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:55:7: warning: variable 'la' set but not used [-Wunused-but-set-variable]
   55 |   int la=-1;
      |       ^~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:40:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  while(ind<ss.size()){
      |        ~~~^~~~~~~~~~
Bruno.cpp:41:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   if(ind+1==ss.size()){
      |      ~~~~~^~~~~~~~~~~
Bruno.cpp:65:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |   for(int i=0;i<ss.size();i++){
      |               ~^~~~~~~~~~
Bruno.cpp:72:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |   for(int i=0;i<ss.size();i++){
      |               ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...