Submission #1037232

# Submission time Handle Problem Language Result Execution time Memory
1037232 2024-07-28T11:12:07 Z DeathIsAwe None (JOI15_memory) C++14
0 / 100
1455 ms 284220 KB
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;

int Memory(int n, int m) {
  if (n % 2 == 1) {
    return -2;
  }
  if (n > 14) {
    return 0;
  }
  
  int states = m;
  int pos = states % 16; states /= 16;
  int type = states % 4; states /= 4;
  vector<int> statesvec;
  for (int i=0;i<n;i++) {
    statesvec.push_back(states % 2);
    states /= 2;
  }
  char current;
  int prevpos = pos - 1, returnval = 0;



  while (pos <= n-1 && statesvec[pos] == 1) {
    pos++;
  }
  if (pos > n-1) {
    return -2;
  } else {
    current = Get(pos + 1);
    if (current == '[') {
      type = 1;
      pos++;
    } else if (current == '<') {
      type = 2;
      pos++;
    } else if ((current == ']' && type == 1) || (current == '>' && type == 2)) {
      statesvec[prevpos] = 1;
      statesvec[pos] = 1;
      pos = 0;
      type = 0;
    } else {
      type = 0;
      pos++;
    }
  } 

  if (pos > n-1) {
    return -2;
  }
  if (count(statesvec.begin(), statesvec.end(), 1) == statesvec.size()) {
    return -1;
  }
  for (int i=0;i<n;i++) {
    //cout << statesvec[i] << ' ';
    if (statesvec[i] == 1) {
      returnval += pow(2, i);
    }
  }
  //cout << '\n';
  returnval *= 64;
  returnval += type * 16;
  returnval += pos;
  //cout << returnval << '\n';
  return returnval;
}

/*
int Memory(int n, int m) {
  if (n % 2 == 1) {
    return -2;
  }
  int bruh = 0, val;
  if (m % 100 + 1 > n) {
    return 0;
  }
  char now = Get(m % 100 + 1);
  if (now == '<') {
    bruh++;
  }
  bruh += (m / 100);
  if (bruh > 201) {
    return 0;
  }
  if (2 * bruh < (m % 100 + 1)) {
    return -2;
  }
  if (m % 100 == n - 1) {
    if (2 * bruh == n) {
      return -1;
    } else {
      return -2;
    }
  }
  val = (m % 100) + (bruh * 100) + 1;
  return val;
}
*/

Compilation message

memory.cpp: In function 'int Memory(int, int)':
memory.cpp:53:52: warning: comparison of integer expressions of different signedness: 'std::__iterator_traits<__gnu_cxx::__normal_iterator<int*, std::vector<int> >, void>::difference_type' {aka 'long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |   if (count(statesvec.begin(), statesvec.end(), 1) == statesvec.size()) {
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1309 ms 283988 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1309 ms 283988 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1309 ms 283988 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1309 ms 283988 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1455 ms 284220 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1309 ms 283988 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -