/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'int main()':
foo.cc:14:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |                 sort(p.begin(), p.end());
      |                 ^~~~
      |                 short

Code

#include <iostream>

using namespace std;

int main()
{
    int t, n;
	cin >> t;
	while (t-- && cin >> n)
	{
		string s;
		cin >> s;
		string p = s;
		sort(p.begin(), p.end());
		int ans = 0;
		for (int i = 0; i < s.size(); i++)
		{
			ans += (s[i] != p[i]);
		}
		ans /= 2;
		cout << ans << "\n";
	}
}

Information

Submit By
Type
Pretest
Problem
P1016 Swap sort
Language
C++17 (G++ 13.2.0)
Submit At
2023-12-28 14:24:31
Judged At
2023-12-28 14:24:31
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes