QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#342215 | #8278. Secret Poems | Gen1us | Compile Error | / | / | C++14 | 3.4kb | 2024-03-01 09:48:41 | 2024-03-01 09:48:41 |
Judging History
answer
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;
int main() {
int n;
int s=0;
cin >> n;
char a[n+1][n+1];
vector<char> b(n*n+1);
for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) {
cin >> a[i][j];
}
}
for(int i=0; i<=n+1; i++) {
a[0][i]=' ';
a[n+1][i]=' ';
a[i][0]=' ';
a[i][n+1]=' ';
}
bool right=true, bottom_left=false, bottom=false, top_right=false;
int i=1, j=1;
b[1]=a[1][1];
int element=2;
while(element<=(n*(n+1)/2)) {
if(right) j++;
if(bottom_left) {
i++;
j--;
}
if(bottom) i++;
if(top_right) {
i--;
j++;
}
b[element]=a[i][j];
element++;
if(right) {
right=false;
bottom_left=true;
goto next;
}
if(bottom_left && a[i+1][j-1]==' ') {
bottom_left=false;
bottom=true;
goto next;
}
if(bottom) {
bottom=false;
top_right=true;
goto next;
}
if(top_right && a[i-1][j+1]==' ') {
top_right=false;
right=true;
goto next;
}
next:
s++;
}
if(n%2) {
right=false;
bottom=true;
}
if(n%2==0) {
bottom=false;
right=true;
}
while(element<=n*n) {
if(right) j++;
if(bottom_left) {
i++;
j--;
}
if(bottom) i++;
if(top_right) {
i--;
j++;
}
b[element]=a[i][j];
element++;
if(right) {
right=false;
top_right=true;
goto end;
}
if(bottom_left && a[i+1][j-1]==' ') {
bottom_left=false;
right=true;
goto end;
}
if(bottom) {
bottom=false;
bottom_left=true;
goto end;
}
if(top_right && a[i-1][j+1]==' ') {
top_right=false;
bottom=true;
goto end;
}
end:
s++;
}
for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) {
a[i][j]=0;
}
}
for(int i=0; i<=n+1; i++) {
a[0][i]=1;
a[n+1][i]=1;
a[i][0]=1;
a[i][n+1]=1;
}
right=true;
bool left=false;
bottom=false;
bool top=false;
i=1, j=0;
element=1;
while(element<=n*n) {
if(right) j++;
if(left) j--;
if(bottom) i++;
if(top) i--;
a[i][j]=b[element];
element++;
if(right && a[i][j+1]) {
right=false;
bottom=true;
goto hi;
}
if(left && a[i][j-1]) {
left=false;
top=true;
goto hi;
}
if(bottom && a[i+1][j]) {
bottom=false;
left=true;
goto hi;
}
if(top && a[i-1][j]) {
top=false;
right=true;
goto hi;
}
hi:
s++;
}
for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) {
cout << a[i][j];
}
cout << "\n";
}
b.clear();
return 0;
}
详细
answer.code: In function ‘int main()’: answer.code:9:5: error: ‘vector’ was not declared in this scope 9 | vector<char> b(n*n+1); | ^~~~~~ answer.code:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’? 2 | #include <iostream> +++ |+#include <vector> 3 | using namespace std; answer.code:9:12: error: expected primary-expression before ‘char’ 9 | vector<char> b(n*n+1); | ^~~~ answer.code:23:5: error: ‘b’ was not declared in this scope 23 | b[1]=a[1][1]; | ^