제출 #1309974

#제출 시각아이디문제언어결과실행 시간메모리
1309974quollcucumber`Sličnost (COI23_slicnost)C++20
14 / 100
3095 ms584 KiB
#include <bits/stdc++.h> #define int long long using namespace std; // int arr[300][300]; // int update(int leftx, int rightx, int lefty, int righty, bool addsub) { // // } // int maxval() { // int val = 0; // for(int i = 0; i < 300; i++) { // for(int j = 0; j < 300; j++) { // val = max(val, arr[i][j]); // } // } // return val; // } int n, k, q; pair<int, int> score(int * a, int * b) { int maxval = 0; int num = 0; for(int i = 0; i < n - k + 1; i++) { for(int j = 0; j < n - k + 1; j++) { set<int> s; for(int l = i; l < i + k; l++) { s.insert(a[l]); } int total = 0; for(int l = j; l < j + k; l++) { if(s.contains(b[l])) total++; } if(total > maxval) { maxval = total; num = 1; }else if(total == maxval) { num++; } } } return {maxval, num}; } signed main(){ cin >> n >> k >> q; // int arr[n]; // for(int i = 0; i < n; i++) { // cin >> arr[i]; // } // int pos[n+1]; // for(int i = 0; i < n; i++) { // int a; // cin >> a; // pos[a] = i; // } // for(int i = 0; i < n; i++) { // // } int a[n]; int b[n]; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i <n; i++) cin >> b[i]; pair<int, int> thing = score(a, b); cout<<thing.first<<' '<<thing.second<<'\n'; for(int i = 0; i < q; i++) { int pos; cin >> pos; pos--; int val = a[pos]; int val2 = a[pos+ 1]; a[pos] = val2; a[pos + 1] = val; thing = score(a, b); cout<<thing.first<<' '<<thing.second<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...