QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#773700#5800. Crazy RowsKavenSky16 ✓1ms3928kbC++231.3kb2024-11-23 09:56:572024-11-23 09:56:58

Judging History

你现在查看的是最新测评结果

  • [2024-11-23 09:56:58]
  • 评测
  • 测评结果:16
  • 用时:1ms
  • 内存:3928kb
  • [2024-11-23 09:56:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define MAX 300015
#define INF 1e8
#define none -1145141919810
const int N=3e5+5;
typedef pair<int,int> P;
typedef long long ll;
typedef __int128 i128;
const ll mod= 998244353;
typedef unsigned long long ull;
typedef long double db;
typedef pair<ll,ll>Pll;
const db pi=acosl(-1.0);
mt19937_64 rnd(time(0));
int cnt=0;
char a[50][50];
void solve(){
    cnt++;
    int n;
    cin >> n;
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> a[i][j];
        }
    }
    vector<int>arr(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i][j]=='1') arr[i]=j;
        }
    }
    //for(int i=0;i<n;i++) cerr << arr[i] << " ";
    for(int i=0;i<n;i++){
        int pos=-1;
        for(int j=i;j<n;j++){
            if(arr[j]<=i){
                pos=j;
                break;
            }
        }
        for(int j=pos;j>i;j--){
            swap(arr[j],arr[j-1]);
            ans++;
        }
    }
    cout << "Case #" << cnt << ": " << ans << "\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    cout << fixed << setprecision(15);
    cin >> t;
    while(t--)
    solve();
}

詳細信息

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 1ms
memory: 3928kb

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: 1ms
memory: 3684kb

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