Submission #44283


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <bits/stdc++.h>
using namespace std;
/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sort(v) sort(all(v))
/* constant */
const int inf = 100100100100100100;
const int mod = 1000000007;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};
/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
/* math_library */
/* main */
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
char arr[h][w];
rep(i,0,h){
rep(j,0,w){
cin >> arr[i][j];
}
}
int dp[h][w];
memset(dp, -1, sizeof(dp));
rep(i,0,h){
if(arr[i][0] == '.'){
dp[i][0] = -1;
}else{
dp[i][0] = 0;
}
}
rep(i,0,h){
rep(j,1,w){
if(dp[i][j-1] == -1){
dp[i][j] = -1;
}
if(dp[i][j-1] > -1){
dp[i][j] = dp[i][j-1] + 1;
}
if(arr[i][j] == 'c'){
dp[i][j] = 0;
}
}
}
rep(i,0,h){
rep(j,0,w){
printx(dp[i][j]); if(j != w-1) printx(" ");
}
print("");
}
}

ステータス

項目 データ
問題 0205 - 気象予報士 (Weather Forecaster)
ユーザー名 daleksprinter
投稿日時 2018-10-07 17:36:12
言語 C++11
状態 Accepted
得点 5
ソースコード長 2569 Byte
最大実行時間 42 ms
最大メモリ使用量 768 KB

セット

セット 得点 Cases
1 IN1 1 / 1 *2015-yo-t3-in1.txt
2 IN2 1 / 1 *2015-yo-t3-in2.txt
3 IN3 1 / 1 *2015-yo-t3-in3.txt
4 IN4 1 / 1 *2015-yo-t3-in4.txt
5 IN5 1 / 1 *2015-yo-t3-in5.txt

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2015-yo-t3-in1.txt AC 42 ms 608 KB
1
2015-yo-t3-in2.txt AC 26 ms 700 KB
2
2015-yo-t3-in3.txt AC 19 ms 628 KB
3
2015-yo-t3-in4.txt AC 23 ms 768 KB
4
2015-yo-t3-in5.txt AC 24 ms 768 KB
5