답안 #80305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
80305 2018-10-19T22:42:20 Z Plurm 게임판 (CEOI13_board) C++11
20 / 100
4 ms 764 KB
#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++){
		if(ma <= 1e8)
		ma = mmove(ma,a[i]);
	}
	for(int i = 0; b[i]; i++){
		if(mb <= 1e8)
		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

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/ccBgZfGF.o: In function `main':
board.cpp:(.text.startup+0xa): warning: the `gets' function is dangerous and should not be used.
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 624 KB Output is correct
2 Correct 3 ms 700 KB Output is correct
3 Correct 4 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 764 KB Output isn't correct
2 Halted 0 ms 0 KB -