Submission #470314

#TimeUsernameProblemLanguageResultExecution timeMemory
470314OmegamanBroken Device (JOI17_broken_device)C++14
Compilation error
0 ms0 KiB
#include "Annalib.h" #include <math.h> bool isInArr(int ArrLen, int Arr[], int val) { for (int i = 0; i < ArrLen; i++) if (Arr[i] == val) return 1; return 0; } void Anna(int N, long long X, int K, int P[]){ bool d[N], F[N]; long long x = X; for( int i = 0; i < N; i++ ){ d[i] = x % 2; x /= 2; F[i] = !isInArr(K, P, i); } bool M[N]; int dh = 0; for( int i = 0; i < N; i+=3) { int m = 0; if (dh < 60) { const bool d1 = d[dh + 0], d2 = dh < 59 ? d[dh + 1] : 0, f1 = F[i + 0], f2 = F[i + 1], f3 = F[i + 2]; int broken = !f1 + !f2 + !f3; int dp = d1*2+d2*1; int bp = f1*4+f2*2+f3*1; if (broken < 2 && dh < 59) { if (0) return; else if ( dp == 0 ) m = ( f2 && f3) ? 3 : 4 * f1; else if ( dp == 1 ) m = (f1 && f3) ? 5 : 2 * f2; else if ( dp == 2 ) m = (f1 && f2 && f3) ? 7 : 1 * f3; else if ( dp == 3 ) m = (f1 && f2 ) ? 6 : 1 * f3; } else if ( broken <= 2 ) { if ( d1) if (f3) m = 1 * f3; if (!d1) { if (f2) m = 2 * f2; if (f1) m = 4 * f1; } } } if(m) { dh++; } if(m>4||m==3) { dh++; } M[i + 2] = m % 2; m /= 2; M[i + 1] = m % 2; m /= 2; M[i + 0] = m % 2; } for ( int i = 0; i < N; i++ ) { Set(i, (int)M[i]); } }
#include "Brunolib.h" long long Bruno( int N, int A[] ) { int len = (N < 60 ? N : 60); bool d[len]; for(int i = 0; i < len; i++) d[i] = 0; int dh = 0; for(int i = 0; i < N; i+=3) { switch (A[i]*4 + A[i+1]*2 + A[i+2]) { case 0: break; case 1: d[dh++] = 1; break; case 2: d[dh++] = 0; break; case 3: d[dh++] = 0; d[dh++] = 0; break; case 4: d[dh++] = 0; break; case 5: d[dh++] = 0; d[dh++] = 1; break; case 6: d[dh++] = 1; d[dh++] = 1; break; case 7: d[dh++] = 1; d[dh++] = 0; break; } } long long X = 0; long long inc = 1; for (int i = 0; i < len; i++) X += inc * d[i]; inc *= 2; } return X; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:37:8: warning: unused variable 'bp' [-Wunused-variable]
   37 |    int bp = f1*4+f2*2+f3*1;
      |        ^~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:45:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   45 |  for (int i = 0; i < len; i++)
      |  ^~~
Bruno.cpp:47:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   47 |   inc *= 2;
      |   ^~~
Bruno.cpp:48:2: warning: no return statement in function returning non-void [-Wreturn-type]
   48 |  }
      |  ^
Bruno.cpp: At global scope:
Bruno.cpp:50:2: error: expected unqualified-id before 'return'
   50 |  return X;
      |  ^~~~~~
Bruno.cpp:51:1: error: expected declaration before '}' token
   51 | }
      | ^