Submission #1077443

#TimeUsernameProblemLanguageResultExecution timeMemory
1077443thelegendary08Broken Device (JOI17_broken_device)C++14
85 / 100
30 ms2884 KiB
#include "Annalib.h" #include<bits/stdc++.h> #define f0r(i,n) for(int i = 0; i<n;i++) #define pb push_back #define vb vector<bool> #define vi vector<int> using namespace std; void Anna( int n, long long x, int k, int p[] ){ vector<bool>broken(n); f0r(i, k){ broken[p[i]] = 1; } vb ret(n, 0); long long mult = 1; f0r(i,37)mult *= 3; vi v; while(x > 0){ if(x >= mult * 2)v.pb(2); else if(x >= mult)v.pb(1); else v.pb(0); x -= mult * v[v.size() - 1]; mult /= 3; } //cout<<v.size()<<'\n'; //for(auto u : v)cout<<u<<' '; //cout<<'\n'; int ptr = 0; f0r(i, 75){ if(broken[i*2] || broken[i*2+1] || ptr==v.size()){ ret[i*2] = 0; ret[i*2+1] = 0; } else if(v[ptr] == 0){ ret[i*2] = 0; ret[i*2+1] = 1; ptr++; } else if(v[ptr] == 1){ ret[i*2] = 1; ret[i*2+1] = 0; ptr++; } else { ret[i*2] = 1; ret[i*2+1] = 1; ptr++; } } f0r(i, n){ Set(i, ret[i]); } }
#include "Brunolib.h" #include<bits/stdc++.h> #define f0r(i,n) for(int i = 0; i<n;i++) #define pb push_back #define vb vector<bool> #define vi vector<int> using namespace std; long long Bruno( int n, int A[] ){ //for(int i = 0; i<N;i++)cout<<A[i]<<' '; //cout<<'\n'; long long ret = 0; long long cur = 1; f0r(i, 37)cur *= 3; f0r(i, 75){ if(A[i*2]== 1 && A[i*2+1] == 0){ ret += cur; } else if(A[i*2] == 1 && A[i*2+1] == 1){ ret += cur * 2; } if(A[i*2] != 0 || A[i*2+1] != 0)cur/=3; } //cout<<ret; return ret; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:30:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   if(broken[i*2] || broken[i*2+1] || ptr==v.size()){
      |                                      ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...