#include <bits/stdc++.h>
using namespace std;
int T,K1,K2, N;
int plansza[309][309];
struct pozycja
{
int x;
int y;
};
pozycja najdalsze_0()
{
pozycja poz;
for(int i=N-1;i>=0;i--)
{
for(int j=N-1;j>=0;j--)
{
if(plansza[i][j]==0)
{
poz.x = j;
poz.y = i;
return poz;
}
}
}
return poz;
}
int main()
{
cin >> T >> N >> K1 >> K2;
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
cin >> plansza[i][j];
}
}
pozycja poz;
int s=0;
for(int k=0;k<K2;k++)
{
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
if(plansza[i][j]==1)
{
s=1;
poz.x=j;
poz.y=i;
}
else
{
if(s==1)
{
swap(plansza[poz.y][poz.x],plansza[najdalsze_0().y][najdalsze_0().x]);
}
}
}
s=0;
}
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
cout << plansza[i][j] << " ";
}
cout << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
improper placement |
2 |
Incorrect |
10 ms |
360 KB |
improper placement |
3 |
Execution timed out |
2072 ms |
596 KB |
Time limit exceeded |
4 |
Execution timed out |
2081 ms |
576 KB |
Time limit exceeded |
5 |
Execution timed out |
2066 ms |
560 KB |
Time limit exceeded |
6 |
Execution timed out |
2074 ms |
596 KB |
Time limit exceeded |
7 |
Execution timed out |
2084 ms |
596 KB |
Time limit exceeded |
8 |
Execution timed out |
2049 ms |
596 KB |
Time limit exceeded |
9 |
Execution timed out |
2086 ms |
596 KB |
Time limit exceeded |
10 |
Execution timed out |
2090 ms |
596 KB |
Time limit exceeded |