Submission #959244

# Submission time Handle Problem Language Result Execution time Memory
959244 2024-04-07T18:06:52 Z d4xn Parrots (IOI11_parrots) C++17
29 / 100
8 ms 1392 KB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
 
void encode(int n, int m[]) {
  pair<int, int> a[256];
  
  int curr = 0;
  for (int i = 0; i < 64; i++) {
    a[curr++] = make_pair(i, -1);
    for (int j = 0; j < 3; j++) {
      a[curr++] = make_pair(i, j);
    }
  }
 
  for(int i = 0; i < n; i++) {
    vector<int> b(3, 0);
 
    for (int j = 0; j < 3; j++) {
      b[j] = m[i] % 7;
      m[i] /= 7;
    }
 
    int sum = b[0] + b[1] + b[2];
    if (sum <= 10 - sum) {
      int y = 0;
      while (a[y].first != i || a[y].second != 0) y++;
 
      for (int j = 0; j < b[0]; j++) send(y);
      for (int j = 0; j < b[1]; j++) send(y+1);
      for (int j = 0; j < b[2]; j++) send(y+2);
    }
    else {
      int y = 0;
      while (a[y].first != i || a[y].second != -1) y++;
      send(y);
 
      for (int j = 0; j < 6-b[0]; j++) send(y+1);
      for (int j = 0; j < 6-b[1]; j++) send(y+2);
      for (int j = 0; j < 5-b[2]; j++) send(y+3);
    }
  }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
 
void decode(int N, int L, int X[]) {
  pair<int, int> a[256];
 
  int curr = 0;
  for (int i = 0; i < 64; i++) {
    a[curr++] = make_pair(i, -1);
    for (int j = 0; j < 3; j++) {
      a[curr++] = make_pair(i, j);
    }
  }
 
  int pw[3];
  pw[0] = 1;
  for (int i = 1; i < 3; i++) {
    pw[i] = pw[i-1]*7;
  }
 
  vector<int> ans(N, 0), rev(N, 0); 
 
  for (int i = 0; i < L; i++) {
    int x = X[i];
    if (a[x].second == -1) {
      rev[a[x].first] = 1;
      ans[a[x].first] = pw[0]*6 + pw[1]*6 + pw[2]*5;
    }
  }
 
  for (int i = 0; i < L; i++) {
    int x = X[i];
    if (a[x].second == -1) continue;
 
    ans[a[x].first] += (rev[a[x].first] ? -pw[a[x].second] : pw[a[x].second]);
  }
 
  for (int i = 0; i < N; i++) {
    output(ans[i]);
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1040 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1040 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1052 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 1312 KB partially correct P=9.500000
2 Partially correct 4 ms 1344 KB partially correct P=9.000000
3 Partially correct 4 ms 1344 KB partially correct P=9.000000
4 Partially correct 7 ms 1376 KB partially correct P=9.000000
5 Partially correct 8 ms 1380 KB partially correct P=9.000000
6 Partially correct 8 ms 1388 KB partially correct P=9.000000
7 Partially correct 8 ms 1392 KB partially correct P=9.000000