답안 #866914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866914 2023-10-27T10:18:55 Z epicci23 Lampice (COCI21_lampice) C++17
50 / 50
1 ms 604 KB
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define endl "\n" 
#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

void solve(){

	int n,k;
	cin >> n >> k;
   
   int ar[n+1];
   for(int i=1;i<=n;i++) cin >> ar[i];

   for(int l=1;l<=n;l++){
   	for(int r=n;r>=l;r--){

   	  if((r-l+1)%k) continue;
   	  bool ok=1;
   	  int u=(r-l+1)/k;

   	  for(int x=l;x+u<=r;x+=u)
        for(int j=x;j<=x+u-1;j++)
          if(ar[j]!=ar[j+u]) ok=0;
   	  
   	  if(ok){
   	    cout << u << endl;
        for(int j=l;j<l+u;j++) cout << ar[j] << " \n"[j==l+u-1];
   	    return;
   	  }
   	}
   }

   cout << -1 << endl;
}

int32_t main(){

  cin.tie(0); ios::sync_with_stdio(0);
  
  int t=1;//cin >> t;
  while(t--) solve();

  return 0;
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:25:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   25 |         for(int j=x;j<=x+u-1;j++)
      |         ^~~
Main.cpp:28:7: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   28 |       if(ok){
      |       ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 1 ms 604 KB Output is correct