QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#117859 | #5800. Crazy Rows | AE_12 | 16 ✓ | 1ms | 3488kb | C++14 | 1.0kb | 2023-07-02 11:38:25 | 2023-07-02 11:38:27 |
Judging History
answer
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define x first
#define y second
//#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
const int mod = 1e9 + 7;
const int N = 1e6+ 10;
int n, m, o[N], x, cnt;
inline void sovle()
{
cin >> n;
vector<int> o;
for(int i = 1; i <= n; i ++)
{
int s = 0;
char a;
for(int j = 0; j < n; j ++)
{
cin >> a;
if(a == '1') s = 0;
else s ++;
}
o.push_back(s);
}
int sum = 0, x = n - 1;
for(int i = 0; i < n; i ++)
{
if(o[i] < x)
{
int a;
for(int j = i + 1; j < n; j ++)
{
if(o[j] >= x)
{
a = o[j];
sum += j - i;
o.erase(o.begin() + j);
break;
}
}
o.insert(o.begin() + i + 1, o[i]);
}
x --;
}
cout << "Case #" << ++ cnt << ": " << sum << endl;
}
signed main(void)
{
IOS;
int t = 1;
cin >> t;
while(t --) sovle();
return 0;
}
详细
Subtask #1:
score: 6
Accepted
Test #1:
score: 6
Accepted
time: 1ms
memory: 3488kb
input:
60 2 10 11 3 001 100 010 4 1110 1100 1100 1000 1 1 7 1000000 0000000 0110000 0001000 1010000 1000000 0100000 8 10000000 01000000 01000000 10000000 10000000 00001000 00100100 10011000 2 01 10 8 01000000 10000000 10100000 01100000 10000000 00100000 00000000 00100000 4 0000 0000 0000 0000 1 1 2 10 01 4...
output:
Case #1: 0 Case #2: 2 Case #3: 4 Case #4: 0 Case #5: 0 Case #6: 0 Case #7: 1 Case #8: 1 Case #9: 0 Case #10: 0 Case #11: 0 Case #12: 0 Case #13: 0 Case #14: 0 Case #15: 8 Case #16: 14 Case #17: 12 Case #18: 10 Case #19: 4 Case #20: 9 Case #21: 3 Case #22: 7 Case #23: 14 Case #24: 13 Case #25: 10 Cas...
result:
ok 60 lines
Subtask #2:
score: 10
Accepted
Test #2:
score: 10
Accepted
time: 0ms
memory: 3460kb
input:
60 2 10 11 3 001 100 010 4 1110 1100 1100 1000 1 1 39 100000000000000000000000000000000000000 000000000000000000000000000000000000000 001000000000000000000000000000000000000 000100000000000000000000000000000000000 011000000000000000000000000000000000000 100000000000000000000000000000000000000 010000...
output:
Case #1: 0 Case #2: 2 Case #3: 4 Case #4: 0 Case #5: 0 Case #6: 0 Case #7: 1 Case #8: 1 Case #9: 0 Case #10: 0 Case #11: 0 Case #12: 0 Case #13: 0 Case #14: 0 Case #15: 163 Case #16: 148 Case #17: 127 Case #18: 100 Case #19: 95 Case #20: 114 Case #21: 140 Case #22: 140 Case #23: 105 Case #24: 82 Cas...
result:
ok 60 lines
Extra Test:
score: 0
Extra Test Passed