# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
592526 |
2022-07-09T09:30:36 Z |
tqbfjotld |
None (JOI15_memory) |
C++14 |
|
2480 ms |
284084 KB |
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;
int Memory(int N, int M) {
if (N>30){
int loc = M%(N+1);
int rem = M/(N+1);
if (loc==N) return rem==0?-1:-2;
int res = Get(loc+1);
if (res=='>'){
if (rem==0) return -2;
rem--;
}
else{
rem++;
}
if ((rem*(N+1)+loc+1)>=(1<<22)) return -2;
return rem*(N+1)+loc+1;
}
int loc = M%(N+1);
int rem = M/(N+1);
if (loc==0) rem = 1<<15;
int rems = 15-__builtin_ctz(rem);
if (rems<0) return -2;
int remm = rem>>(15-rems+1);
if (loc==N){
return rems==0?-1:-2;
}
int res = Get(loc+1);
//printf("loc %d rems = %d remm = %x\n",loc,rems,remm);
if (res==']' || res=='>'){
if (rems==0) return -2;
if ((remm&1)==(res==']')){
rems--;
remm>>=1;
}
else{
return -2;
}
}
else{
if (rems==15){
return -2;
}
rems++;
remm<<=1;
remm += (res=='[');
}
if ((((remm<<((15-rems)+1))+(1<<(15-rems)))*(N+1)+(loc+1))>=(1<<22))
return -2;
//printf("rems = %d, remm = %x\n",rems,remm);
return ((remm<<((15-rems)+1))+(1<<(15-rems)))*(N+1)+(loc+1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2171 ms |
284072 KB |
Output is correct |
2 |
Correct |
2192 ms |
283984 KB |
Output is correct |
3 |
Correct |
2480 ms |
283996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2171 ms |
284072 KB |
Output is correct |
2 |
Correct |
2192 ms |
283984 KB |
Output is correct |
3 |
Correct |
2480 ms |
283996 KB |
Output is correct |
4 |
Correct |
2228 ms |
283912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2171 ms |
284072 KB |
Output is correct |
2 |
Correct |
2192 ms |
283984 KB |
Output is correct |
3 |
Correct |
2480 ms |
283996 KB |
Output is correct |
4 |
Correct |
2228 ms |
283912 KB |
Output is correct |
5 |
Correct |
2158 ms |
284084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2171 ms |
284072 KB |
Output is correct |
2 |
Correct |
2192 ms |
283984 KB |
Output is correct |
3 |
Correct |
2480 ms |
283996 KB |
Output is correct |
4 |
Correct |
2228 ms |
283912 KB |
Output is correct |
5 |
Correct |
2158 ms |
284084 KB |
Output is correct |
6 |
Correct |
2154 ms |
283976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2033 ms |
283960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2171 ms |
284072 KB |
Output is correct |
2 |
Correct |
2192 ms |
283984 KB |
Output is correct |
3 |
Correct |
2480 ms |
283996 KB |
Output is correct |
4 |
Correct |
2228 ms |
283912 KB |
Output is correct |
5 |
Correct |
2158 ms |
284084 KB |
Output is correct |
6 |
Correct |
2154 ms |
283976 KB |
Output is correct |
7 |
Correct |
2033 ms |
283960 KB |
Output is correct |
8 |
Correct |
2037 ms |
283960 KB |
Output is correct |
9 |
Incorrect |
2203 ms |
283892 KB |
Wrong Answer [6] |
10 |
Halted |
0 ms |
0 KB |
- |