답안 #592371

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592371 2022-07-09T06:25:54 Z errorgorn 기억 압축 (JOI15_memory) C++17
10 / 100
2351 ms 284296 KB
#include "Memory_lib.h"

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ii pair<int,int>
#define fi first
#define se second

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (int x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

signed Memory(signed n, signed m){
	if (n%2==1) return -2;
	
	int curr=m&127;
	int d=(m>>7)&127;
	int pos=(m>>14)&127;
	int typ=m>>21;
	
	if (curr>=n || d>=n || pos>=n) return -2;
	
	char c=Get(pos+1);
	
	int nd=d;
	if (c=='<' || c=='[') nd++;
	else nd--;
	
	int ntyp=0;
	if (c=='[' || c==']') ntyp=1;
	
	if (nd<0) return -2;
	
	int typ2;
	if (nd==d+1){
		if (d==curr) typ2=ntyp;
	}
	else{
		if (nd==curr){
			if (typ!=ntyp) return -2;
		}
	}
	
	if (pos!=n-1){
		return curr|(nd<<7)|((pos+1)<<14)|(typ2<<21);
	}
	else if (curr!=n-1){
		if (nd!=0) return -2;
		return curr+1;
	}
	else{
		return -1;
	}
	
}

Compilation message

memory.cpp: In function 'int Memory(int, int)':
memory.cpp:56:42: warning: 'typ2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |   return curr|(nd<<7)|((pos+1)<<14)|(typ2<<21);
      |                                     ~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2209 ms 284296 KB Output is correct
2 Correct 2204 ms 284080 KB Output is correct
3 Incorrect 2320 ms 284256 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2209 ms 284296 KB Output is correct
2 Correct 2204 ms 284080 KB Output is correct
3 Incorrect 2320 ms 284256 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2209 ms 284296 KB Output is correct
2 Correct 2204 ms 284080 KB Output is correct
3 Incorrect 2320 ms 284256 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2209 ms 284296 KB Output is correct
2 Correct 2204 ms 284080 KB Output is correct
3 Incorrect 2320 ms 284256 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2351 ms 284016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2209 ms 284296 KB Output is correct
2 Correct 2204 ms 284080 KB Output is correct
3 Incorrect 2320 ms 284256 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -