编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#46104 | #1153. wch和zxh的游♂戏 | Compile Error | 0 | 0 ms | 0 K | C++ (NOI) / 1.1 K | 233nihao | 2020-08-17 11:13:48 |
#include <iostream>
#include <math.h>
using namespace std;
int a[4][4];
int temps[10000];
int coun = 0;
int dfs(int x, int m, int count) {
int temp = 0;
temp = count;
cout << temp << endl;
if (m == 0) {
temps[coun] = temp;
coun++;
return temp;
}
if (m > 0) {
for (int i = 0; i < 9; i++) {
temp += left(i);
dfs(i, m - 1, temp);
temp -= right(i);
}
}
}
int left(int x2) {
int xx = x2 % 3;
int yy = x2 / 3;
int temp = a[xx][yy];
a[xx][yy] = a[xx + 1][yy];
a[xx + 1][yy] = a[xx + 1][yy + 1];
a[xx + 1][yy + 1] = a[xx][yy + 1];
a[xx][yy + 1] = temp;
int u = (a[xx][yy] + a[xx + 1][yy] + a[xx][yy + 1] + a[xx + 1][yy + 1]);
return u;
}
int right(int x) {
int xx = x % 3;
int yy = x / 3;
int temp = a[xx][yy];
a[xx][yy] = a[xx][yy + 1];
a[xx][yy + 1] = a[xx + 1][yy + 1];
a[xx + 1][yy + 1] = a[xx + 1][yy];
a[xx + 1][yy] = temp;
return (a[xx][yy] + a[xx + 1][yy] + a[xx][yy + 1] + a[xx + 1][yy + 1]);
}
int main() {
int n, m;
cin >> n;
while (n--) {
cin >> m;
coun = 0;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
cin >> a[i][j];
}
}
dfs(0, 2 * m, 0);
for (int p = 0; p < pow(9, 2 * m); p++) cout << temps[p] << " ";
}
}
编译信息
/sandbox/1/a.cpp: In function 'int dfs(int, int, int)':
/sandbox/1/a.cpp:22:16: error: invalid initialization of reference of type 'std::ios_base&' from expression of type 'int'
temp+=left(i);
^
In file included from /opt/noilinux/usr/include/c++/4.8/ios:42:0,
from /opt/noilinux/usr/include/c++/4.8/ostream:38,
from /opt/noilinux/usr/include/c++/4.8/iostream:39,
from /sandbox/1/a.cpp:1:
/opt/noilinux/usr/include/c++/4.8/bits/ios_base.h:916:3: error: in passing argument 1 of 'std::ios_base& std::left(std::ios_base&)'
left(ios_base& __base)
^
/sandbox/1/a.cpp:24:17: error: invalid initialization of reference of type 'std::ios_base&' from expression of type 'int'
temp-=right(i);
^
In file included from /opt/noilinux/usr/include/c++/4.8/ios:42:0,
from /opt/noilinux/usr/include/c++/4.8/ostream:38,
from /opt/noilinux/usr/include/c++/4.8/iostream:39,
from /sandbox/1/a.cpp:1:
/opt/noilinux/usr/include/c++/4.8/bits/ios_base.h:924:3: error: in passing argument 1 of 'std::ios_base& std::right(std::ios_base&)'
right(ios_base& __base)
^