QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#326669 | #1214. Limited Memory | bachbeo2007 | 100 ✓ | 210ms | 86060kb | C++20 | 1.3kb | 2024-02-13 18:14:34 | 2024-02-13 18:14:35 |
Judging History
answer
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;
int f(int N,int col,int pos,int lst,int val){
return col*(N+2)*(N+2)*(N+2)+val*(N+2)*(N+2)+lst*(N+2)+pos;
}
int Memory(int N, int M) {
if(M==0) return f(N,0,1,1,0);
int pos=M%(N+2);M/=(N+2);
int lst=M%(N+2);M/=(N+2);
int val=M%(N+2);M/=(N+2);
//cout << pos << ' ' << lst << ' ' << val << ' ' << M << '\n';
if(M>=2 || pos==0) return 0;
if(pos==N+1) return -1;
if(pos==lst){
if(val!=0 || M!=0) return 0;
char c=Get(lst);
if(c=='>' || c==']') return f(N,(c=='>'),pos,pos-1,1);
else return f(N,(c=='<'),pos,pos+1,1);
}
else if(pos<lst){
if(lst==N+1) return -2;
char c=Get(lst);
if(c=='<' || c=='[') val++;
else val--;
if(val<0) return 0;
else if(val==0){
if(M!=(c=='>')) return -2;
else return f(N,0,pos+1,pos+1,0);
}
else return f(N,M,pos,lst+1,val);
}
else{
if(lst==0) return -2;
char c=Get(lst);
if(c=='>' || c==']') val++;
else val--;
if(val<0) return 0;
else if(val==0){
if(M!=(c=='<')) return -2;
else return f(N,0,pos+1,pos+1,0);
}
else return f(N,M,pos,lst-1,val);
}
}
Details
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 79ms
memory: 85960kb
Test #2:
score: 0
Accepted
time: 89ms
memory: 85752kb
Test #3:
score: 0
Accepted
time: 100ms
memory: 85832kb
Subtask #2:
score: 10
Accepted
Test #4:
score: 10
Accepted
time: 90ms
memory: 85804kb
Subtask #3:
score: 5
Accepted
Test #5:
score: 5
Accepted
time: 86ms
memory: 86060kb
Subtask #4:
score: 5
Accepted
Test #6:
score: 5
Accepted
time: 95ms
memory: 85796kb
Subtask #5:
score: 10
Accepted
Test #7:
score: 10
Accepted
time: 181ms
memory: 86056kb
Subtask #6:
score: 60
Accepted
Test #8:
score: 60
Accepted
time: 177ms
memory: 85788kb
Test #9:
score: 0
Accepted
time: 210ms
memory: 85788kb
Extra Test:
score: 0
Extra Test Passed