-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathp5.cpp
More file actions
45 lines (35 loc) · 787 Bytes
/
Copy pathp5.cpp
File metadata and controls
45 lines (35 loc) · 787 Bytes
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
#include<iostream>
#include<set>
using namespace std;
int grip[20][10];
int main(){
for(int i=14;i>=0;i--)
for(int j=0;j<10;j++)
cin>>grip[i][j];
set<pair<int,int>>s,t;
for(int i=3;i>=0;i--)
for(int j=0,x;j<4;j++){
cin>>x;
if(x==1)
s.insert({i,j});
}
int d; cin>>d;
for(auto [y,x]:s)
t.insert({y+15,x+d-1});
int i=0; bool ok=0;
while(1){
for(auto [y,x]:t)
if(y-(i+1)<0 || grip[y-(i+1)][x])
ok=1;
if(ok) break;
++i;
}
for(auto [y,x]:t)
grip[y-i][x]=1;
for(int i=14;i>=0;i--){
for(int j=0;j<10;j++)
cout<<grip[i][j]<<" ";
cout<<endl;
}
return 0;
}