답안 #592387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592387 2022-07-09T06:39:22 Z errorgorn 기억 압축 (JOI15_memory) C++17
100 / 100
2360 ms 284180 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;
	
	//cout<<curr<<" "<<d<<" "<<pos<<" "<<typ<<endl;
	
	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=typ;
	if (d==curr && nd==curr+1){
		typ2=ntyp;
	}
	if (d==curr+1 && 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;
	}
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2213 ms 284072 KB Output is correct
2 Correct 2289 ms 284088 KB Output is correct
3 Correct 2251 ms 284048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2213 ms 284072 KB Output is correct
2 Correct 2289 ms 284088 KB Output is correct
3 Correct 2251 ms 284048 KB Output is correct
4 Correct 2253 ms 284180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2213 ms 284072 KB Output is correct
2 Correct 2289 ms 284088 KB Output is correct
3 Correct 2251 ms 284048 KB Output is correct
4 Correct 2253 ms 284180 KB Output is correct
5 Correct 2319 ms 284112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2213 ms 284072 KB Output is correct
2 Correct 2289 ms 284088 KB Output is correct
3 Correct 2251 ms 284048 KB Output is correct
4 Correct 2253 ms 284180 KB Output is correct
5 Correct 2319 ms 284112 KB Output is correct
6 Correct 2360 ms 284016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2321 ms 283988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2213 ms 284072 KB Output is correct
2 Correct 2289 ms 284088 KB Output is correct
3 Correct 2251 ms 284048 KB Output is correct
4 Correct 2253 ms 284180 KB Output is correct
5 Correct 2319 ms 284112 KB Output is correct
6 Correct 2360 ms 284016 KB Output is correct
7 Correct 2321 ms 283988 KB Output is correct
8 Correct 2207 ms 283996 KB Output is correct
9 Correct 2322 ms 284028 KB Output is correct