Submission #592387

#TimeUsernameProblemLanguageResultExecution timeMemory
592387errorgorn기억 압축 (JOI15_memory)C++17
100 / 100
2360 ms284180 KiB
#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; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...