Submission #80302

#TimeUsernameProblemLanguageResultExecution timeMemory
80302PlurmBoard (CEOI13_board)C++11
20 / 100
4 ms2192 KiB
#include <bits/stdc++.h> using namespace std; char a[100005]; char b[100005]; inline int mmove(int x,char y){ switch(y){ case '1': x *= 2; break; case '2': x *= 2; x++; break; case 'U': x /= 2; break; case 'L': x--; break; case 'R': x++; break; } return x; } inline int glv(int x){ int l = 0; while(x > 1){ x /= 2; l++; } return l; } int mem[100005]; int main(){ gets(a); gets(b); int ma = 1; int mb = 1; for(int i = 0; a[i]; i++){ ma = mmove(ma,a[i]); } for(int i = 0; b[i]; i++){ mb = mmove(mb,b[i]); } int lla = glv(ma); int llb = glv(mb); if(lla < llb){ swap(lla,llb); swap(ma,mb); } int la = lla; int lb = llb; while(ma >= 1){ mem[la] = ma; ma /= 2; la--; } int d = 1e9; while(mb >= 1){ if(mem[lb]){ d = min(d,abs(mem[lb] - mb) + lla - lb + llb - lb); } mb /= 2; lb--; } printf("%d\n",d); }

Compilation message (stderr)

board.cpp: In function 'int main()':
board.cpp:40:8: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
  gets(a);
        ^
In file included from /usr/include/c++/7/cstdio:42:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:46,
                 from board.cpp:1:
/usr/include/stdio.h:638:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
board.cpp:41:8: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
  gets(b);
        ^
In file included from /usr/include/c++/7/cstdio:42:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:46,
                 from board.cpp:1:
/usr/include/stdio.h:638:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
board.cpp:40:6: warning: ignoring return value of 'char* gets(char*)', declared with attribute warn_unused_result [-Wunused-result]
  gets(a);
  ~~~~^~~
board.cpp:41:6: warning: ignoring return value of 'char* gets(char*)', declared with attribute warn_unused_result [-Wunused-result]
  gets(b);
  ~~~~^~~
/tmp/ccYhQ9DV.o: In function `main':
board.cpp:(.text.startup+0xa): warning: the `gets' function is dangerous and should not be used.
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...