Submission #32220955
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
void printArr(vector<int>arr){
for(auto i : arr){
cout << i << " ";
}
cout << endl;
}
void printArrPair(vector<pair<int,int>>arr){
for(auto i : arr){
cout << i.first << " " << i.second << " ";
}
cout << endl;
}
void solve(){
int n,k;
cin >> n >> k;
vector<int>arr(n);
vector<vector<int>>sortArr;
for(auto &it : arr){
cin >> it;
}
for(int i = 0;i < k;i++){
vector<int>cur;
for(int j = i;j < n;j += k){
cur.push_back(arr[j]);
}
sort(cur.begin(),cur.end());
sortArr.push_back(cur);
}
vector<int>fin;
int size = sortArr[0].size();
for(int i = 0;i < size;i++){
for(int j = 0;j < sortArr.size();j++){
if(sortArr[j].size() > i){
fin.push_back(sortArr[j][i]);
}
}
}
sort(arr.begin(),arr.end());
for(int i = 0;i < arr.size();i++){
if(arr[i] != fin[i]){
cout << "No" << endl;
return;
}
}
cout << "Yes" << endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("data", "r", stdin);
#endif
int n = 1;
// cin >> n;
while(n--)
solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - K Swap |
| User | liuji |
| Language | C++ (GCC 9.2.1) |
| Score | 300 |
| Code Size | 1447 Byte |
| Status | AC |
| Exec Time | 56 ms |
| Memory | 16764 KiB |
Compile Error
./Main.cpp: In function ‘void solve()’:
./Main.cpp:38:25: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
38 | for(int j = 0;j < sortArr.size();j++){
| ~~^~~~~~~~~~~~~~~~
./Main.cpp:39:34: warning: comparison of integer expressions of different signedness: ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
39 | if(sortArr[j].size() > i){
| ~~~~~~~~~~~~~~~~~~^~~
./Main.cpp:45:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
45 | for(int i = 0;i < arr.size();i++){
| ~~^~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_srnd_00.txt, 01_srnd_01.txt, 01_srnd_02.txt, 01_srnd_03.txt, 01_srnd_04.txt, 02_rnd_00.txt, 02_rnd_01.txt, 02_rnd_02.txt, 02_rnd_03.txt, 02_rnd_04.txt, 02_rnd_05.txt, 02_rnd_06.txt, 02_rnd_07.txt, 02_rnd_08.txt, 02_rnd_09.txt, 03_worst_00.txt, 03_worst_01.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 7 ms | 3448 KiB |
| 00_sample_01.txt | AC | 2 ms | 3524 KiB |
| 00_sample_02.txt | AC | 3 ms | 3472 KiB |
| 01_srnd_00.txt | AC | 2 ms | 3464 KiB |
| 01_srnd_01.txt | AC | 2 ms | 3464 KiB |
| 01_srnd_02.txt | AC | 2 ms | 3532 KiB |
| 01_srnd_03.txt | AC | 2 ms | 3448 KiB |
| 01_srnd_04.txt | AC | 2 ms | 3508 KiB |
| 02_rnd_00.txt | AC | 45 ms | 5708 KiB |
| 02_rnd_01.txt | AC | 44 ms | 16652 KiB |
| 02_rnd_02.txt | AC | 46 ms | 6100 KiB |
| 02_rnd_03.txt | AC | 52 ms | 16712 KiB |
| 02_rnd_04.txt | AC | 49 ms | 5756 KiB |
| 02_rnd_05.txt | AC | 52 ms | 16764 KiB |
| 02_rnd_06.txt | AC | 51 ms | 5756 KiB |
| 02_rnd_07.txt | AC | 56 ms | 16572 KiB |
| 02_rnd_08.txt | AC | 52 ms | 5716 KiB |
| 02_rnd_09.txt | AC | 52 ms | 6352 KiB |
| 03_worst_00.txt | AC | 52 ms | 6116 KiB |
| 03_worst_01.txt | AC | 53 ms | 6152 KiB |