比赛 |
树立信心的模拟赛 |
评测结果 |
RRRRRRRRRR |
题目名称 |
凯伦和超市 |
最终得分 |
0 |
用户昵称 |
@@@ |
运行时间 |
0.001 s |
代码语言 |
C++ |
内存使用 |
0.36 MiB |
提交时间 |
2017-09-01 21:56:21 |
显示代码纯文本
#include <fstream>
#include <vector>
// #include "iostream"
using namespace std;
ifstream cin("games.in");
ofstream cout("games.out");
int e[105][105],m,n,Sum,s;
int ans_row[105],ans_col[105],K;
int cyf()
{
int i,j,k;
cin >> n >> m;
if(n<=m){
for (i = 1; i <= n; ++i)
{
//int mi = 999999999;
for (j = 1; j <= m; ++j)
{
cin >> e[i][j];
Sum+=e[i][j];
// mi = min(mi,e[i][j]);
/* code */
}
//e[i][0] = mi;
/* code */
}
for (i = 1; i <= n; ++i)
{
int mi = 999999999;
for (j = 1; j <= m; ++j)
{
// cin >> e[i][j];
// Sum+=e[i][j];
mi = min(mi,e[i][j]);
/* code */
}
e[i][0] = mi;
/* code */
}
for ( i = 1; i <= n; ++i)
{
if (e[i][0])
{
ans_row[i] = e[i][0];
K += e[i][0];
//for(k = 1;k <= e[i][0];k++)
//{
// cout << "row " << i << endl;
//}
for (k = 1; k <= m; ++k)
{
e[i][k] -= e[i][0];
/* code */
}
s += e[i][0]*m;
}
}
if (s < Sum)
{
for (i = 1; i <= m; ++i)
{
int mi = 999999999;
for (j = 1; j <= n; ++j)
{
mi = min(mi,e[j][i]);
/* code */
}
e[0][i] = mi;
}
for ( j = 1; j <= m; ++j)
{
if (e[0][j])
{
ans_col[j] = e[0][j];
K += e[0][j];
//for(k = 1;k <= e[0][j];k++)
//{
// cout << "col " << j << endl;
//}
s += e[0][j]*n;
}
}
/* code */
}
if (s != Sum)
{
cout << -1 << endl;
/* code */
}
else
{
cout << K << endl;
for(i = 1;i <= n;i++)
{
if(ans_row[i])
{
for(k = 1;k <= ans_row[i];k++)
{
cout << "row " << i << endl;
}
}
}
for(i = 1;i <= m;i++)
{
if(ans_col[i])
{
for(k = 1;k <= ans_col[i];k++)
{
cout << "col " << i << endl;
}
}
}
}
}
else
{
for (i = 1; i <= n; ++i)
{
//int mi = 999999999;
for (j = 1; j <= m; ++j)
{
cin >> e[i][j];
Sum+=e[i][j];
// mi = min(mi,e[i][j]);
/* code */
}
//e[i][0] = mi;
/* code */
}
for (i = 1; i <= m; ++i)
{
int mi = 999999999;
for (j = 1; j <= n; ++j)
{
mi = min(mi,e[j][i]);
/* code */
}
e[0][i] = mi;
}
for ( j = 1; j <= m; ++j)
{
if (e[0][j])
{
ans_col[j] = e[0][j];
K += e[0][j];
//for(k = 1;k <= e[0][j];k++)
//{
// cout << "col " << j << endl;
//}
s += e[0][j]*n;
}
}
/* code */
if (s < Sum)
{
for (i = 1; i <= n; ++i)
{
int mi = 999999999;
for (j = 1; j <= m; ++j)
{
// cin >> e[i][j];
// Sum+=e[i][j];
mi = min(mi,e[i][j]);
/* code */
}
e[i][0] = mi;
/* code */
}
for ( i = 1; i <= n; ++i)
{
if (e[i][0])
{
ans_row[i] = e[i][0];
K += e[i][0];
//for(k = 1;k <= e[i][0];k++)
//{
// cout << "row " << i << endl;
//}
for (k = 1; k <= m; ++k)
{
e[i][k] -= e[i][0];
/* code */
}
s += e[i][0]*m;
}
}
}
if (s != Sum)
{
cout << -1 << endl;
/* code */
}
else
{
cout << K << endl;
for(i = 1;i <= n;i++)
{
if(ans_row[i])
{
for(k = 1;k <= ans_row[i];k++)
{
cout << "row " << i << endl;
}
}
}
for(i = 1;i <= m;i++)
{
if(ans_col[i])
{
for(k = 1;k <= ans_col[i];k++)
{
cout << "col " << i << endl;
}
}
}
}
}
cin.close();
cout.close();
return 0;
}
int hhhh = cyf();
int main() {;}