字符串的题真尼玛恶心;
最讨厌写模拟题了(菠萝买募集) = =
不想找bug了 = =
非AC代码(90分)
代码:
/* 这题写坐标写的我头疼。。。。真的感觉恶心炸 */
/* 填充用DFS + 标记数组 + 坐标运算 */
/* 划线就是坐标运算(最主要就是这个!!!!) */
#include <iostream>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
int n , m , k , L;
char mpt[1050][1050] ;
int vis[1050][1050] ;
int dx[] = {0 , 0 , 1 , -1} ;
int dy[] = {1 , -1 , 0 ,0 } ;
void init(){
for(int i = 0 ; i <=n ; i++){
for(int j = 0 ; j <= m ; j++){
mpt[i][j] = '.' ;
}
}
}
//4 2 == 11 4
void text2(int x , int y , char ch){ /// DFS
mpt[x][y] = ch ;
vis[x][y] = 1 ;
for(int i = 0 ; i < 4 ; i++){
if( x + dx[i] < n && x + dx[i] >=0 && y + dy[i] < m && y + dy[i] >= 0 && (mpt[x + dx[i]][y + dy[i]] != '-' && mpt[x+dx[i]][ y + dy[i]] != '|' && mpt[x+dx[i]][ y + dy[i]] != '+' ) && vis[x + dx[i]][y+dy[i]] == 0 )
{ mpt[x + dx[i]][y + dy[i]] = ch ; vis[x + dx[i]][y+dy[i]] == 0 ; text2(x+ dx[i] , y + dy[i] , ch ) ; }
}
}
void output(){
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m ; j++){
cout << mpt[i][j] ;
}
cout << endl ;
}
}
void anss( int posx , int posy , int posx1 ,int posy1){
if (posx == posx1)
{
if (posy > posy1){ k = posy; posy = posy1; posy1 = k; }
for (int i = posy; i <= posy1; i++)
{
if (mpt[n - 1 - i][posx] == '-' || mpt[n - 1 - i][posx] == '+')mpt[n - 1 - i][posx] = '+';
else mpt[n - 1 - i][posx] = '|';
}
}
else if (posy==posy1)
{
if (posx > posx1){ k = posx; posx = posx1; posx1 = k; }
for (int i = posx; i <= posx1; i++)
{
if (mpt[n - 1 - posy][i] == '|' || mpt[n - 1 - posy][i] == '+')mpt[n - 1 - posy][i] = '+';
else mpt[n - 1 - posy][i] = '-';
}
}
}
// 3 1 == 12 3
int main(){
cin >> m >> n >> L ;
init() ;
int coun ;
int cnt = 0 ;
for(int i = 0 ; i < L ; i++){
cin >> coun ;
if(coun == 0){
int x , y , x1 , y1 ;
cin >> x >> y >> x1>> y1 ;
anss(x , y , x1 , y1) ;
cnt++ ;
if(cnt == L) break ;
// cout << cnt << " " << L << " " <<i << endl ;
}
else {
int x , y ;
char ch ;
scanf("%d %d %c", &x , &y , &ch) ;
// getchar() ;
int x1 = n - y -1 ;
int y1 = x ;
text2(x1 , y1 ,ch) ;
cnt++ ;
if(cnt == L) break ;
// cout << cnt << " " << L << " " <<i << endl ;
}
}
output() ;
return 0 ;
}