Submission #863214

#TimeUsernameProblemLanguageResultExecution timeMemory
863214Ahmed_SolymanLampice (COCI21_lampice)C++14
50 / 50
1 ms456 KiB
/* In the name of Allah made by: Ahmed_Solyman */ #include <bits/stdc++.h> #include <ext/rope> using namespace std; using namespace __gnu_cxx; #pragma GCC optimize("-Ofast") #pragma GCC optimize("-O1") //-------------------------------------------------------------// typedef long long ll; typedef unsigned long long ull; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define PI acos(-1) #define lb lower_bound #define ub upper_bound #define endl '\n' #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() #define sum_to(n) (n*(n+1))/2 #define pb push_back #define pf push_front #define fil(arr,x) memset(arr,x,sizeof(arr)) const ll mod=1e9+7; int dx[8]={0,1,0,-1,1,1,-1,-1}; int dy[8]={1,0,-1,0,1,-1,-1,1}; //-------------------------------------------------------------// ll lcm(ll a,ll b) { return (max(a,b)/__gcd(a,b))*min(a,b); } void person_bool(bool x) { cout<<(x?"YES":"NO")<<endl; } bool ok(vector<int>&v,int k){ if(v.size()%k==0 && v.size()){ vector<vector<int>>g; vector<int>temp; for(int i=0;i<v.size();i++){ temp.push_back(v[i]); if(temp.size()==v.size()/k){ g.push_back(temp); temp.clear(); } } bool ret=1; for(int i=1;i<g.size();i++)ret&=(g[i]==g[i-1]); return ret; } else{ return 0; } } int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); #ifndef ONLINE_JUDGE //freopen("input.in", "r", stdin); //freopen("output.out", "w", stdout); #endif fast int n,k;cin>>n>>k; vector<int>v(n); for(auto &i:v)cin>>i; for(int i=0;i<n;i++){ vector<int>arr; for(int j=i;j<n;j++){ arr.push_back(v[j]); if(ok(arr,k)){ cout<<arr.size()/k<<endl; for(int p=0;p<arr.size()/k;p++){ cout<<arr[p]<<" "; } return 0; } } } cout<<-1<<endl; return 0; }

Compilation message (stderr)

Main.cpp: In function 'bool ok(std::vector<int>&, int)':
Main.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for(int i=0;i<v.size();i++){
      |               ~^~~~~~~~~
Main.cpp:50:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for(int i=1;i<g.size();i++)ret&=(g[i]==g[i-1]);
      |               ~^~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:75:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |        for(int p=0;p<arr.size()/k;p++){
      |                    ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...