A. Little Elephant and ProblemThe Little Elephant has got a problem —  dịch - A. Little Elephant and ProblemThe Little Elephant has got a problem —  Việt làm thế nào để nói

A. Little Elephant and ProblemThe L

A. Little Elephant and Problem
The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.
The Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. He thinks that he could have accidentally changed array a, only if array a can be sorted in no more than one operation of swapping elements (not necessarily adjacent). That is, the Little Elephant could have accidentally swapped some two elements.
Help the Little Elephant, determine if he could have accidentally changed the array a, sorted by non-decreasing, himself.
Input
The first line contains a single integer n (2 ≤ n ≤ 105) — the size of array a. The next line contains n positive integers, separated by single spaces and not exceeding 109, — array a.
Note that the elements of the array are not necessarily distinct numbers.
Output
In a single line print "YES" (without the quotes) if the Little Elephant could have accidentally changed the array himself, and "NO" (without the quotes) otherwise.
Sample test(s)
input
2
1 2
output
YES
input
3
3 2 1
output
YES
input
4
4 3 2 1
output
NO
Note
In the first sample the array has already been sorted, so to sort it, we need 0 swap operations, that is not more than 1. Thus, the answer is "YES".
In the second sample we can sort the array if we swap elements 1 and 3, so we need 1 swap operation to sort the array. Thus, the answer is "YES".
In the third sample we can't sort the array in more than on
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
A. con voi nhỏ và vấn đề
The con voi nhỏ đã có một vấn đề-ai đó đã chạm vào của mình được sắp xếp bởi phòng không giảm mảng một chiều dài n và có thể trao đổi một số yếu tố của mảng.
The con voi nhỏ không thể gọi cảnh sát cho đến khi ông hiểu nếu ông có thể đã vô tình thay đổi các mảng mình. Ông nghĩ rằng ông có thể đã vô tình thay đổi mảng một, chỉ khi mảng có thể được sắp xếp trong các hoạt động không nhiều hơn một của trao đổi các yếu tố (không nhất thiết phải liền kề). Có nghĩa là, con voi nhỏ có thể đã vô tình trao đổi một số yếu tố hai.
giúp con voi nhỏ, xác định nếu ông có thể đã vô tình thay đổi các mảng một, được sắp xếp theo phòng không-giảm, mình.
đầu vào
Dòng đầu tiên có một đơn số nguyên n (2 ≤ n ≤ 105) — kích thước mảng một. Dòng kế tiếp có n số nguyên dương, cách nhau bằng dấu cách duy nhất và không quá 109, — mảng a.
lưu ý rằng các yếu tố của mảng là không nhất thiết phải phân biệt số.
sản lượng
trong một dòng in "Có" (không có dấu ngoặc kép) nếu con voi nhỏ có thể vô tình đã thay đổi các mảng mình, và "NO" (không có dấu ngoặc kép) nếu không.
mẫu test(s)
đầu vào
2
1 2
sản lượng

đầu vào
3
3 2 1
sản lượng

đầu vào
4
4 3 2 1
sản lượng
NO
lưu ý
trong mẫu đầu tiên các mảng có đã được sắp xếp, do đó, để phân loại của nó, chúng ta cần hoạt động trao đổi 0, đó không phải là nhiều hơn 1. Vì vậy, câu trả lời là "Có".
trong mẫu thứ hai, chúng tôi có thể sắp xếp các mảng nếu chúng tôi trao đổi thành phần 1 và 3, Vì vậy, chúng tôi cần 1 trao đổi hoạt động để sắp xếp các mảng. Vì vậy, câu trả lời là "Có".
trong mẫu thứ ba, chúng tôi không thể sắp xếp các mảng trong hơn trên
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
A. Little Elephant and Problem
The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.
The Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. He thinks that he could have accidentally changed array a, only if array a can be sorted in no more than one operation of swapping elements (not necessarily adjacent). That is, the Little Elephant could have accidentally swapped some two elements.
Help the Little Elephant, determine if he could have accidentally changed the array a, sorted by non-decreasing, himself.
Input
The first line contains a single integer n (2 ≤ n ≤ 105) — the size of array a. The next line contains n positive integers, separated by single spaces and not exceeding 109, — array a.
Note that the elements of the array are not necessarily distinct numbers.
Output
In a single line print "YES" (without the quotes) if the Little Elephant could have accidentally changed the array himself, and "NO" (without the quotes) otherwise.
Sample test(s)
input
2
1 2
output
YES
input
3
3 2 1
output
YES
input
4
4 3 2 1
output
NO
Note
In the first sample the array has already been sorted, so to sort it, we need 0 swap operations, that is not more than 1. Thus, the answer is "YES".
In the second sample we can sort the array if we swap elements 1 and 3, so we need 1 swap operation to sort the array. Thus, the answer is "YES".
In the third sample we can't sort the array in more than on
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2024 I Love Translation. All reserved.

E-mail: