답안 #282221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282221 2020-08-24T07:08:16 Z 임성재(#5755) 기억 압축 (JOI15_memory) C++17
30 / 100
3373 ms 284084 KB
#include "Memory_lib.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9 + 7;
const ll INF = 1e18;

int Memory(int N, int M) {
  if(N & 1) return -2;

  int h = M % N;
  M /= N;
  int p = M % N + 1;
  M /= N;
  int cnt = M % N;
  M /= N;
  int c = M % 5;

  char x = Get(p);
  if(x == '<') x = 1;
  if(x == '>') x = 2;
  if(x == '[') x = 3;
  if(x == ']') x = 4;

  if(cnt == h && (x % 2 == 1)) {
    c = x;
  }
  
  if(x == 1 || x == 3) cnt++;
  else cnt--;

  if(cnt < 0) return -2;
  if(cnt > N/2) return -2;

  if(cnt == h && (x % 2 == 0)) {
    if(c != x-1) {
      return -2;
    }
  }

  p++;
  if(p > N) {
    if(cnt != 0) return -2;
    
    p = 1;
    h++;
  }

  if(h >= N/2+1) {
    return -1;
  }

  int ret = 0;
  ret += c;
  ret *= N;
  ret += cnt;
  ret *= N;
  ret += p-1;
  ret *= N;
  ret += h;

  return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2896 ms 283972 KB Output is correct
2 Correct 3373 ms 283752 KB Output is correct
3 Correct 3321 ms 283840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2896 ms 283972 KB Output is correct
2 Correct 3373 ms 283752 KB Output is correct
3 Correct 3321 ms 283840 KB Output is correct
4 Correct 3317 ms 283776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2896 ms 283972 KB Output is correct
2 Correct 3373 ms 283752 KB Output is correct
3 Correct 3321 ms 283840 KB Output is correct
4 Correct 3317 ms 283776 KB Output is correct
5 Correct 3266 ms 284084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2896 ms 283972 KB Output is correct
2 Correct 3373 ms 283752 KB Output is correct
3 Correct 3321 ms 283840 KB Output is correct
4 Correct 3317 ms 283776 KB Output is correct
5 Correct 3266 ms 284084 KB Output is correct
6 Correct 3256 ms 283948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Wrong Answer [1]
# 결과 실행 시간 메모리 Grader output
1 Correct 2896 ms 283972 KB Output is correct
2 Correct 3373 ms 283752 KB Output is correct
3 Correct 3321 ms 283840 KB Output is correct
4 Correct 3317 ms 283776 KB Output is correct
5 Correct 3266 ms 284084 KB Output is correct
6 Correct 3256 ms 283948 KB Output is correct
7 Incorrect 1 ms 384 KB Wrong Answer [1]