Submission #900077

#TimeUsernameProblemLanguageResultExecution timeMemory
900077HamzaTLampice (COCI21_lampice)C++14
50 / 50
3 ms4852 KiB
//struct Edge {int u, v, weight;bool operator<(Edge const& other) {return weight < other.weight;}}; #include <bits/stdc++.h> #define endl "\n" #define ll long long #define sp ' ' #define pb push_back #define ar for(int i=1;i<=n;i++) using namespace std; ll t=1; const ll N=3e5+100; ll n,m,q,k; ll a[N],b[N],c[N]; vector<int>v[10000]; vector<int>ans; bool ok(int l,int r) { if((r-l+1)%k!=0){return false;} for(int i=0;i<n;i++){v[i].clear();} ll lenth=(r-l+1)/k; for(int i=0;i<k;i++) { for(int j=1;j<=lenth;j++) { ll ndx=(i)*lenth;ndx+=l-1; v[i].push_back(a[ndx+j]); } } // if(l==1&&r==4)for(int i=0;i<5;i++){for(auto j:v[i]){cout<<j<<" ";}cout<<endl;} for(int i=0;i<lenth;i++) { set<int>s; for(int j=0;j<k;j++) { s.insert(v[j][i]); } if(s.size()!=1){return false;} } ans=v[0]; return true; } void solve() { cin>>n>>k; for(int i=1;i<=n;i++){cin>>a[i];} for(int i=1;i<=n;i++) { for(int j=i+1;j<=n;j++) { if(!ok(i,j)){continue;} cout<<(j-i+1)/k<<endl; for(auto i:ans){cout<<i<<" ";}cout<<endl;return; } } cout<<-1<<endl;return; } int main() { //freopen("shell.in", "r", stdin); // freopen("shell.out", "w", stdout); ios::sync_with_stdio(NULL); cin.tie(NULL);cout.tie(NULL); // cin>>t; while(t--){solve();} return 0; } //09:00 :: 9:45 //10:30 ::
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...