# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
95435 |
2019-02-01T07:18:42 Z |
Retro3014 |
None (JOI15_memory) |
C++17 |
|
2542 ms |
276820 KB |
#include "Memory_lib.h"
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;
int Memory(int N, int M) {
//cout<<N<<" "<<M<<endl;
if(M==0){
return (3<<20);
}
int k = (M>>20);
int t = M%(1<<20);
int a = t/10000, b = (t/100)%100, c = (t%100);
if(a>N-1 || b>N-1 || c>N-1) return -2;
char ch = Get(b+1);
//cout<<k<<" "<<a<<" "<<b<<" "<<c<<" "<<ch<<endl;
if(k==3){
if(ch=='<'){
a++;
}else if(ch=='>'){
a--;
if(a<0) return -2;
}else if(ch=='['){
c++;
}else{
c--;
if(c<0) return -2;
}
//cout<<k<<" "<<a<<" "<<b<<" "<<c<<" "<<ch<<endl;
if(b==N-1){
if(a!=0 || c!=0) return -2;
return (1<<20);
}
b++;
int K = (k<<20) + a*10000 + b*100 + c;
return K;
}
if(a==0 && b==0 && c==0 && k!=0){
k = 0;
}
if(a==0){
if(k==0){
if(ch=='<') k = 1;
else if(ch=='[') k = 2;
}else{
return -2;/*
if(k==1){
if(c!=0 || ch!='>'){
return -2;
}
}else{
if(c!=0 || ch!=']'){
return -2;
}
}
k = 0;
c = 0;*/
}
}
if(k==0){
if(ch=='<' || ch=='['){
a--;
if(a<0) return -2;
}
else{
a++;
}
}
if(k!=0){
if(ch=='<' || ch=='['){
a++;
}
else{
a--;
if(a<0) return -2;
}
if(k==1){
if(ch=='<'){
c++;
}else if(ch=='>'){
c--;
if(c<0) return -2;
}
}else{
if(ch=='['){
c++;
}else if(ch==']'){
c--;
if(c<0) return -2;
}
}
if(a==0 || c==0){
if(a!=0 || c!=0) return -2;
k = 0;
}
}
if(b==N-1){
if(k!=0) return -2;
if(a==N-1) return -1;
b = 0;
a++;
c = 0;
}else{
b++;
}
int K = (k<<20) + a*10000 + b*100 + c;
return K;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2370 ms |
276684 KB |
Output is correct |
2 |
Correct |
2371 ms |
276736 KB |
Output is correct |
3 |
Correct |
2400 ms |
276648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2370 ms |
276684 KB |
Output is correct |
2 |
Correct |
2371 ms |
276736 KB |
Output is correct |
3 |
Correct |
2400 ms |
276648 KB |
Output is correct |
4 |
Correct |
2388 ms |
276820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2370 ms |
276684 KB |
Output is correct |
2 |
Correct |
2371 ms |
276736 KB |
Output is correct |
3 |
Correct |
2400 ms |
276648 KB |
Output is correct |
4 |
Correct |
2388 ms |
276820 KB |
Output is correct |
5 |
Correct |
2373 ms |
276572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2370 ms |
276684 KB |
Output is correct |
2 |
Correct |
2371 ms |
276736 KB |
Output is correct |
3 |
Correct |
2400 ms |
276648 KB |
Output is correct |
4 |
Correct |
2388 ms |
276820 KB |
Output is correct |
5 |
Correct |
2373 ms |
276572 KB |
Output is correct |
6 |
Correct |
2397 ms |
276684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2516 ms |
276648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2370 ms |
276684 KB |
Output is correct |
2 |
Correct |
2371 ms |
276736 KB |
Output is correct |
3 |
Correct |
2400 ms |
276648 KB |
Output is correct |
4 |
Correct |
2388 ms |
276820 KB |
Output is correct |
5 |
Correct |
2373 ms |
276572 KB |
Output is correct |
6 |
Correct |
2397 ms |
276684 KB |
Output is correct |
7 |
Correct |
2516 ms |
276648 KB |
Output is correct |
8 |
Correct |
2542 ms |
276604 KB |
Output is correct |
9 |
Correct |
2538 ms |
276536 KB |
Output is correct |