QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#124161#5662. Distance CalculatorIanPauloWA 1ms3376kbC++17608b2023-07-14 11:12:122023-07-14 11:12:16

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-14 11:12:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3376kb
  • [2023-07-14 11:12:12]
  • 提交

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 (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: 3376kb

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'