Skip to content

Commit dc01939

Browse files
committed
delete and change dir
1 parent 45493bc commit dc01939

251 files changed

Lines changed: 237 additions & 3586 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BOJ/BOJ_3197/BOJ_3197

99.3 KB
Binary file not shown.

BOJ/BOJ_3197/BOJ_3197.cpp

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int r,c;
5+
vector<pair<int, int> > delvec;
6+
char lake[1502][1502];
7+
int visited[1502][1502];
8+
int checked[1502][1502];
9+
int meeting[1502][1502];
10+
vector<pair<int, int> > birld;
11+
12+
const int dx[] = {-1, 0, 1, 0};
13+
const int dy[] = {0, 1, 0, -1};
14+
15+
void searchIce(int x, int y){
16+
queue<pair<int, int> > q;
17+
18+
q.push({x,y});
19+
checked[x][y] = 1;
20+
21+
while(!q.empty()){
22+
int now_r = q.front().first;
23+
int now_c = q.front().second;
24+
q.pop();
25+
26+
for(int i = 0; i < 4; i++){
27+
int next_r = now_r + dx[i];
28+
int next_c = now_c + dy[i];
29+
if(lake[next_r][next_c] == 'L' || checked[next_r][next_c] || next_r < 0 || next_r >= r || next_c < 0 || next_c > c) continue;
30+
if(lake[next_r][next_c] == 'X'){
31+
delvec.push_back({next_r, next_c});
32+
checked[next_r][next_c] = 1;
33+
continue;
34+
}
35+
if(lake[next_r][next_c] == '.'){
36+
q.push({next_r, next_c});
37+
checked[next_r][next_c] = 1;
38+
}
39+
}
40+
}
41+
42+
}
43+
44+
void meltingIce(){
45+
for(int i = 0; i < delvec.size(); i++){
46+
int rr = delvec[i].first;
47+
int cc = delvec[i].second;
48+
49+
lake[rr][cc] = '.';
50+
}
51+
}
52+
53+
bool canMeet(){
54+
queue<pair<int, int> > q;
55+
56+
int stx = birld[0].first;
57+
int sty = birld[0].second;
58+
59+
q.push({stx, sty});
60+
meeting[stx][sty] = 1;
61+
62+
while(!q.empty()){
63+
int xx = q.front().first;
64+
int yy = q.front().second;
65+
q.pop();
66+
67+
for(int i = 0; i < 4; i++){
68+
int nxx = xx + dx[i];
69+
int nyy = yy + dy[i];
70+
71+
if(lake[nxx][nyy] == 'X' || meeting[nxx][nyy] || nxx < 0 || nxx > r || nyy < 0 || nyy > c) continue;
72+
if(lake[nxx][nyy] == 'L'){
73+
return true;
74+
}
75+
if(lake[nxx][nyy] == '.'){
76+
meeting[nxx][nyy]=1;
77+
q.push({nxx,nyy});
78+
}
79+
80+
}
81+
82+
}
83+
84+
return false;
85+
86+
}
87+
88+
int main(){
89+
ios_base::sync_with_stdio(0), cin.tie(NULL);
90+
91+
cin>>r>>c;
92+
for(int i = 0; i < r; i++){
93+
for(int j = 0; j < c; j++){
94+
cin>>lake[i][j];
95+
if(lake[i][j] == 'L'){
96+
birld.push_back({i,j});
97+
}
98+
}
99+
}
100+
101+
int day = 0;
102+
103+
while(!canMeet()){
104+
memset(visited, 0, sizeof(visited));
105+
memset(checked, 0, sizeof(checked));
106+
memset(meeting, 0, sizeof(meeting));
107+
108+
for(int i = 0; i < r; i++){
109+
for(int j = 0; j < c; j++){
110+
if(lake[i][j] == '.' && visited[i][j] == 0){
111+
searchIce(i,j);
112+
}
113+
}
114+
}
115+
116+
meltingIce();
117+
118+
day++;
119+
}
120+
121+
cout<<day<<"\n";
122+
123+
return 0;
124+
}

BOJ/sample/sample2.cpp

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
string ltrim(const string &);
6+
string rtrim(const string &);
7+
8+
9+
/*
10+
* Complete the 'solution' function below.
11+
*
12+
* The function is expected to return an INTEGER.
13+
* The function accepts following parameters:
14+
* 1. INTEGER_ARRAY cost
15+
* 2. INTEGER x
16+
*/
17+
int MOD = 1e9+7;
18+
19+
int solution(vector<int> cost, int x) {
20+
int ans = -987654321;
21+
int _len = cost.size();
22+
vector<int> presum(cost.size());
23+
24+
presum[0] = cost[0];
25+
for(int i = 1; i < _len; i++){
26+
presum[i] = cost[i] + presum[i-1];
27+
}
28+
29+
// for(int i = 0; i < cost.size(); i++){
30+
// cout<<presum[i]<<" ";
31+
// }
32+
33+
int p=0,q=1;
34+
int tmp = 0;
35+
36+
while(true){
37+
if(p==q) break;
38+
39+
if(presum[q] <= x){
40+
for(int i = 0; i <= q; i++){
41+
tmp += (1<<i);
42+
}
43+
ans = max(ans, tmp%MOD);
44+
q++;
45+
}else{
46+
if((presum[q] - presum[p]) <= x){
47+
48+
}else{
49+
if((presum[q] - presum[q-1] + presum[p]) <= x){
50+
tmp += (1<<p) + (1<<q);
51+
}
52+
}
53+
}
54+
}
55+
56+
57+
return ans %= MOD;
58+
}
59+
int main()
60+
{
61+
ofstream fout(getenv("OUTPUT_PATH"));
62+
63+
string cost_count_temp;
64+
getline(cin, cost_count_temp);
65+
66+
int cost_count = stoi(ltrim(rtrim(cost_count_temp)));
67+
68+
vector<int> cost(cost_count);
69+
70+
for (int i = 0; i < cost_count; i++) {
71+
string cost_item_temp;
72+
getline(cin, cost_item_temp);
73+
74+
int cost_item = stoi(ltrim(rtrim(cost_item_temp)));
75+
76+
cost[i] = cost_item;
77+
}
78+
79+
string x_temp;
80+
getline(cin, x_temp);
81+
82+
int x = stoi(ltrim(rtrim(x_temp)));
83+
84+
int result = solution(cost, x);
85+
86+
fout << result << "\n";
87+
88+
fout.close();
89+
90+
return 0;
91+
}
92+
93+
string ltrim(const string &str) {
94+
string s(str);
95+
96+
s.erase(
97+
s.begin(),
98+
find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace)))
99+
);
100+
101+
return s;
102+
}
103+
104+
string rtrim(const string &str) {
105+
string s(str);
106+
107+
s.erase(
108+
find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(),
109+
s.end()
110+
);
111+
112+
return s;
113+
}

Codeforce/799_div4/a.cpp

Lines changed: 0 additions & 25 deletions
This file was deleted.

Codeforce/799_div4/b.cpp

Lines changed: 0 additions & 26 deletions
This file was deleted.

Codeforce/799_div4/b_promo.cpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)