社区讨论

为什么不全对

P9856 [CCC 2008 J3] GPS Text Entry参与者 4已保存回复 3

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
3 条
当前快照
1 份
快照标识符
@mhj3ypcv
此快照首次捕获于
2025/11/03 20:20
4 个月前
此快照最后确认于
2025/11/03 20:20
4 个月前
查看原帖
CPP
#include <bits/stdc++.h>
using namespace std ;
string s ;
int ans ;
struct node {
	char c ;
	int x , y ;
} a [ 50 ] ;
int main ( ) {
	getline ( cin , s ) ;
	for ( int i = 0 ; i < s.length ( ) ; i++ ) {
		if ( 'A' <= s [ i ] && s [ i ] <= 'Z' ) {
			a [ i + 1 ].c = s [ i ] ;
			a [ i + 1 ].x = ( s [ i ] - 'A' + 1 ) % 6 ;
			a [ i + 1 ].y = ( s [ i ] - 'A' + 1 ) / 6 + 1 ;
		}
		else {
			if ( s [ i ] == '-' ) {
				a [ i + 1 ].c = s [ i ] ;
				a [ i + 1 ].x = 4 ;
				a [ i + 1 ].y = 5 ;
			}
			else if ( s [ i ] == '.' ) {
				a [ i + 1 ].c = s [ i ] ;
				a [ i + 1 ].x = 5 ;
				a [ i + 1 ].y = 5 ;
			}
			else if ( s [ i ] == ' ' ) {
				a [ i + 1 ].c = ' ' ;
				a [ i + 1 ].x = 3 ;
				a [ i + 1 ].y = 5 ;
			}
		}
	}
	a [ 0 ].c = 'A' ;
	a [ 0 ].x = a [ 0 ].y = 1 ;
	a [ s.length ( ) + 1 ].c = 'e' ;
	a [ s.length ( ) + 1 ].x = 6 ;
	a [ s.length ( ) + 1 ].y = 5 ;
	for ( int i = 0 ; i <= s.length ( ) + 1 ; i++ ) cout << a [ i ].c << ' ' << a [ i ].x << ' ' << a [ i ].y << endl ;
	for ( int i = 1 ; i <= s.length ( ) + 1 ; i++ )  {
		int xx = abs ( a [ i ].x - a [ i - 1 ].x ) ;
		int yy = abs ( a [ i ].y - a [ i - 1 ].y ) ;
		ans += xx + yy ;
		//cout << xx << ' ' << yy << endl ;
	}
	cout << ans ;
}
关于这个程序过不了第四个测试点这件悲伤的事情 希望有大佬求助;)

回复

3 条回复,欢迎继续交流。

正在加载回复...