# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1037153 |
2024-07-28T09:22:18 Z |
beaconmc |
None (JOI15_memory) |
C++14 |
|
1598 ms |
284152 KB |
#include "Memory_lib.h"
#include <bits/stdc++.h>
typedef int ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
int encode(int a, int b, int c, int d, int e){
return a + b*(1<<7) + c*(1<<14) + d*(1<<20) + e*(1<<21);
}
vector<int> decode(int k){
ll a,b,c,d,e;
a = k%(1<<7);
b = (k>>7)%(1<<7);
c = (k>>14)%(1<<6);
d = (k>>20)%(1<<1);
e = (k>>21);
return {a,b,c,d,e};
}
int Memory(int N, int M) {
vector<int> sus = decode(M);
ll a,b,c,d,e;
ll A,B,C,D,E;
a = sus[0];b=sus[1];c=sus[2];d=sus[3],e=sus[4];
if (c>50) return -2;
//cout << a << " " << b << " " << c << " " << d << " " << e << endl;
if (e==0){
if (c==N){
if (a!=b) return -2;
else return encode(0,0,0,0,1);
}
else{
if (!(1<= c+1 && c+1<= N)) return -2;
char temp = Get(c+1);
c++;
if (temp == '<' || temp == '[') a++;
else b++;
}
return encode(a,b,c,d,e);
}else{
if (a==b){
if (b+1 > N){
if (d==1) return -1;
return -2;
}
if (!(1<= b+1 && b+1<= N)) return -2;
char temp = Get(b+1);
if (temp == '>'){
d = 0;
b += 1;
}else if (temp == ']'){
d = 1;
b += 1;
}else{
a = b+1;
b = b+1;
d = 0;
}
}else{
if (!(1<= a && a<= N)) return -2;
char temp = Get(a);
if (temp == ']' || temp == '>'){
c += 1;
a-=1;
}
else{
if (c==0){
if (temp == '<' && d==0){
a = b;
b = b;
d = 1;
}
else if (temp == '[' && d==1){
a = b;
b = b;
d = 1;
}
else return -2;
}else{
c-=1;
a-=1;
}
}
}
if (a<=0) return -2;
if (a==b && a==N+1) return -1;
if (!(1<=encode(a,b,c,d,e) && encode(a,b,c,d,e) <= (1<<22))){
cout << a << " " << b << " " << c << " " << d << " " << e << endl;
cout << A << " "<<B<<" "<<C<<" "<<D<<" "<<E<<endl;
}
return encode(a,b,c,d,e);
}
}
Compilation message
memory.cpp: In function 'int Memory(int, int)':
memory.cpp:95:26: warning: 'A' may be used uninitialized in this function [-Wmaybe-uninitialized]
95 | cout << A << " "<<B<<" "<<C<<" "<<D<<" "<<E<<endl;
| ^~~
memory.cpp:95:34: warning: 'B' may be used uninitialized in this function [-Wmaybe-uninitialized]
95 | cout << A << " "<<B<<" "<<C<<" "<<D<<" "<<E<<endl;
| ^~~
memory.cpp:95:42: warning: 'C' may be used uninitialized in this function [-Wmaybe-uninitialized]
95 | cout << A << " "<<B<<" "<<C<<" "<<D<<" "<<E<<endl;
| ^~~
memory.cpp:95:50: warning: 'D' may be used uninitialized in this function [-Wmaybe-uninitialized]
95 | cout << A << " "<<B<<" "<<C<<" "<<D<<" "<<E<<endl;
| ^~~
memory.cpp:95:55: warning: 'E' may be used uninitialized in this function [-Wmaybe-uninitialized]
95 | cout << A << " "<<B<<" "<<C<<" "<<D<<" "<<E<<endl;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1493 ms |
283988 KB |
Output is correct |
2 |
Correct |
1534 ms |
283984 KB |
Output is correct |
3 |
Correct |
1598 ms |
284152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1493 ms |
283988 KB |
Output is correct |
2 |
Correct |
1534 ms |
283984 KB |
Output is correct |
3 |
Correct |
1598 ms |
284152 KB |
Output is correct |
4 |
Correct |
1591 ms |
283988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1493 ms |
283988 KB |
Output is correct |
2 |
Correct |
1534 ms |
283984 KB |
Output is correct |
3 |
Correct |
1598 ms |
284152 KB |
Output is correct |
4 |
Correct |
1591 ms |
283988 KB |
Output is correct |
5 |
Correct |
1534 ms |
283988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1493 ms |
283988 KB |
Output is correct |
2 |
Correct |
1534 ms |
283984 KB |
Output is correct |
3 |
Correct |
1598 ms |
284152 KB |
Output is correct |
4 |
Correct |
1591 ms |
283988 KB |
Output is correct |
5 |
Correct |
1534 ms |
283988 KB |
Output is correct |
6 |
Correct |
1544 ms |
283988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1557 ms |
283988 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1493 ms |
283988 KB |
Output is correct |
2 |
Correct |
1534 ms |
283984 KB |
Output is correct |
3 |
Correct |
1598 ms |
284152 KB |
Output is correct |
4 |
Correct |
1591 ms |
283988 KB |
Output is correct |
5 |
Correct |
1534 ms |
283988 KB |
Output is correct |
6 |
Correct |
1544 ms |
283988 KB |
Output is correct |
7 |
Incorrect |
1557 ms |
283988 KB |
Wrong Answer [6] |
8 |
Halted |
0 ms |
0 KB |
- |