Submission #1037142

#TimeUsernameProblemLanguageResultExecution timeMemory
1037142beaconmc기억 압축 (JOI15_memory)C++14
0 / 100
0 ms348 KiB
#include "Memory_lib.h" #include <bits/stdc++.h> typedef long long 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){ return a + b*(1<<7) + c*(1<<14) + d*(1<<21); } vector<int> decode(int k){ ll a,b,c,d; a = k%(1<<7); b = (k>>7)%(1<<7); c = (k>>14)%(1<<7); d = (k>>21); return {a,b,c,d}; } int Memory(int N, int M) { vector<int> sus = decode(M); ll a,b,c,d; a = sus[0];b=sus[1];c=sus[2];d=sus[3]; //cout << a << " " << b << " " << c << " " << d << endl; if (a==b){ 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; } }else{ char temp = Get(a); if (temp == ']' || temp == '>'){ c += 1; a-=1; } else{ if (c==0){ if (temp == '<' && d==0){ a = b+1; b = b+1; } else if (temp == '[' && d==1){ a = b+1; b = b+1; } else return -2; }else{ c-=1; a-=1; } } } if (a<=0) return -2; if (a==b && a==N+1) return -1; else return encode(a,b,c,d); }

Compilation message (stderr)

memory.cpp: In function 'std::vector<int> decode(int)':
memory.cpp:19:13: warning: narrowing conversion of 'a' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   19 |     return {a,b,c,d};
      |             ^
memory.cpp:19:13: warning: narrowing conversion of 'a' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
memory.cpp:19:15: warning: narrowing conversion of 'b' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   19 |     return {a,b,c,d};
      |               ^
memory.cpp:19:15: warning: narrowing conversion of 'b' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
memory.cpp:19:17: warning: narrowing conversion of 'c' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   19 |     return {a,b,c,d};
      |                 ^
memory.cpp:19:17: warning: narrowing conversion of 'c' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
memory.cpp:19:19: warning: narrowing conversion of 'd' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   19 |     return {a,b,c,d};
      |                   ^
memory.cpp:19:19: warning: narrowing conversion of 'd' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
#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...