Submission #622400

# Submission time Handle Problem Language Result Execution time Memory
622400 2022-08-04T08:49:53 Z Ferid20072020 Lampice (COCI21_lampice) C++14
50 / 50
1 ms 340 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>



using namespace __gnu_pbds;
using namespace std;
using namespace chrono;
// using namespace atcoder



#define YES             cout << "YES"
#define NO              cout << "NO"
#define fd              fixed
#define ll              long long
#define ull             unsigned long long
#define ui              unsigned int
#define dbl             double
#define ld              long double
#define f               first
#define s               second
#define pii             pair<int , int>
#define pll             pair<ll , ll>
#define pil             pair<int , ll>
#define pli             pair<ll , int>
#define psi             pair<string , int>
#define pci             pair<char , int>
#define pic             pair<int , char>
#define pis             pair<int , string>
#define psl             pair<string , ll>
#define pcl             pair<char , ll>
#define plc             pair<ll , char>
#define pls             pair<ll , string>
#define pb              push_back
#define eb              emplace_back
#define mp              make_pair
#define ins             insert
#define END             return 0
#define speed           ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define all(x)          (x).begin() , (x).end()
#define oo              1e9


/*
int gcd(int number1 , int number2){
   if(number2 == 0){
      return number1;
   }
   return gcd(number2 , number1 % number2);
}

int lcm(int number1 , int number2){
   return number1 / gcd(number1 , number2) * number2;
}

ll fact(int number){
   ll product = 1;
   for(int i=2 ; i<=number ; i++){
      product *= i;
   }
   return product;
}
*/


#define int ll



void solve(){
   int n , k;
   cin >> n >> k;

   vector<int> A(n+5);
   for(int i=1 ; i<=n ; i++){
      cin >> A[i];
   }

   for(int i=1 ; i<=n ; i++){
      for(int j=1 ; j<=n-i+1 ; j++){
         vector<int> ededler;
         for(int k=j ; k<=j+i-1 ; k++){
            ededler.pb(A[k]);
         }
         int ind = 0 , say = 1 , say1 = 0;
         for(int z=j+i ; z<=n ; z++){
            if(A[z] == ededler[ind]){
               say1++;
               if(say1 == ededler.size()){
                  say++;
                  say1 = 0;
               }
            }
            else{
               break;
            }
            ind++;
            if(ind == ededler.size()){
               ind = 0;
            }
         }
         if(say >= k){
            cout << ededler.size() << '\n';
            for(int i=0 ; i<ededler.size() ; i++){
               cout << ededler[i] << " ";
            }
            return;
         }
      }
   }
   cout << -1;
}


signed  main(){
   speed;

   int t = 1;
   //cin >> t;

   while(t--){
      solve();
   }

   END;
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:95:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |                if(say1 == ededler.size()){
      |                   ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:104:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  104 |             if(ind == ededler.size()){
      |                ~~~~^~~~~~~~~~~~~~~~~
Main.cpp:110:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  110 |             for(int i=0 ; i<ededler.size() ; i++){
      |                           ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct