QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#124157 | #5662. Distance Calculator | IanPaulo | WA | 1ms | 3356kb | C++14 | 642b | 2023-07-14 11:09:28 | 2023-07-14 11:09:29 |
Judging History
answer
#include<iostream>
using namespace std;
int sort(int arr[], int n){
int i, j, c;
bool swapped;
for (i = 0; i < n - 1; i++) {
swapped = false;
for (j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
swapped = true;
c++;
}
}
// If no two elements were swapped by inner loop,
// then break
if (swapped == false)
break;
}
return c;
}
int main(){
int t;
cin >> t;
for(int i=0;i<t;i++){
int n;
cin >> n;
int c[n];
for(int j=0;j<n;j++){
cin >> c[j];
}
int a = sort(c, n);
cout << a <<endl;
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3356kb
input:
5 3 3 1 2 4 4 3 2 1 5 4 1 2 3 5 7 2 6 1 5 4 3 7 10 3 2 1 5 7 6 4 10 8 9
output:
2 8 11 19 28
result:
wrong answer 2nd lines differ - expected: '6', found: '8'