QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#457041 | #8816. Solar Panel Grid Optimization | PhantomThreshold | WA | 0ms | 3608kb | C++17 | 2.5kb | 2024-06-28 22:44:02 | 2024-06-28 22:44:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n;
string str;
int a[50][50];
int b[50][50];
int mid[50][50];
int now[50];
int main(){
ios_base::sync_with_stdio(false);
cin >> n;
for (int i=1;i<=n;i++){
cin >> str;
for (int j=1;j<=n;j++) a[i][j]=str[j-1]-'0';
}
for (int i=1;i<=n;i++){
cin >> str;
for (int j=1;j<=n;j++) b[i][j]=str[j-1]-'0';
}
// cerr << "ok0" << endl;
vector<pair<int,int>> ans;
auto left = [&](int i){
int tmp=a[i][1];
for (int j=1;j<=n-1;j++) a[i][j]=a[i][j+1];
a[i][n]=tmp;
ans.emplace_back(0,i);
};
auto down = [&](int j){
int tmp=a[n][j];
for (int i=n;i>=2;i--) a[i][j]=a[i-1][j];
a[1][j]=tmp^1;
ans.emplace_back(1,j);
};
{
for (int i=1;i<=n;i++) now[i]=2;
for (int i=1;i<=n-1;i++)
for (int j=2;j<=n;j++) mid[i][j]=b[i][j];
for (int j=2;j<=n;j++) mid[n][j]=1;
for (;count(now+1,now+n+1,n+1)!=n;){
for (int i=1;i<=n;i++){
while (now[i]<=n && a[i][1]==mid[i][now[i]]){
now[i]++;
left(i);
}
}
for (int cc=1;cc<=n;cc++) down(1);
// cerr << "a : " << endl;
// for (int i=1;i<=n;i++){
// for (int j=1;j<=n;j++) cerr << a[i][j];
// cerr << endl;
// }
// cerr << "now : " << endl;
// for (int i=1;i<=n;i++) cerr << now[i] << " ";
// cerr << endl;
}
for (int cc=1;cc<=n-1;cc++){
left(n);
down(1);
}
for (;count(a[n]+1,a[n]+n+1,1)!=0;){
for (;a[n][1]==0;) left(n);
down(1);
}
}
// cerr << "ok1" << endl;
vector<pair<int,int>> rev;
auto right = [&](int i){
int tmp=b[i][n];
for (int j=n;j>=2;j--) b[i][j]=b[i][j-1];
b[i][1]=tmp;
rev.emplace_back(0,i);
};
auto up = [&](int j){
int tmp=b[1][j];
for (int i=1;i<=n-1;i++) b[i][j]=b[i+1][j];
b[n][j]=tmp^1;
rev.emplace_back(1,j);
};
{
while (count(b[n]+2,b[n]+n+1,1)!=n-1){
while (b[n][1]==1) right(n);
up(1);
}
for (int i=1;i<=n-1;i++){
right(n);
up(1);
}
while (count(b[n]+2,b[n]+n+1,0)!=n-1){
while (b[n][1]!=1) right(n);
up(1);
}
for (int i=1;i<=n-1;i++) up(1);
}
reverse(rev.begin(),rev.end());
for (auto e:rev) ans.emplace_back(e);
cout << ans.size() << "\n";
for (auto [x,y]:ans){
if (x==0) cout << "row ";
else cout << "col ";
cout << y << "\n";
}
//
// cerr << "a : " << endl;
// for (int i=1;i<=n;i++){
// for (int j=1;j<=n;j++) cerr << a[i][j];
// cerr << endl;
// }
// cerr << "b : " << endl;
// for (int i=1;i<=n;i++){
// for (int j=1;j<=n;j++) cerr << b[i][j];
// cerr << endl;
// }
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3608kb
input:
4 1011 1100 0100 1011 1001 0110 0110 1001
output:
51 row 2 row 2 row 2 row 4 col 1 col 1 col 1 col 1 row 1 row 1 row 1 row 3 row 3 row 3 row 4 row 4 col 1 col 1 col 1 col 1 row 4 col 1 row 4 col 1 row 4 col 1 row 4 row 4 col 1 col 1 col 1 col 1 col 1 row 4 col 1 row 4 col 1 row 4 col 1 col 1 row 4 col 1 row 4 col 1 row 4 col 1 row 4 col 1 col 1 row...
result:
wrong answer Token parameter [name=type] equals to "col", doesn't correspond to pattern "(row)|(column)"