답안 #666265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
666265 2022-11-28T02:28:11 Z Chal1shkan Lampice (COCI21_lampice) C++14
50 / 50
1 ms 340 KB
# include <bits/stdc++.h>

# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define pii pair <int, int>
# define pll pair <ll, ll>
  
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
  
const ll maxn = 2e6 + 125;
const ll maxl = 20 + 0;
const ll inf = 2e9 + 0;
const ll mod = 998244353;

using namespace std;

void ma1n ()
{
	int n, k;
	cin >> n >> k;
	int a[n + 3];
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	for (int pr = 0; pr <= n; ++pr)
	{
		for (int sf = 0; sf <= n; ++sf)
		{
			if (pr + sf >= n)
			{
				continue;
			}
			else
			{
				int sz = (n - sf - pr);
				if (sz % k == 0)
				{
					int d = sz / k, cnt = 0;
					bool ok = 1, fnd = 0;
					vector <int> x, need;
					for (int i = 1 + pr; i <= n - sf; ++i)
					{
						x.pb(a[i]);
						cnt++;
						if (cnt == d)
						{
							if (fnd == 0)
							{
								need = x;
								fnd = 1;
							}
							else
							{
								if (x != need)
								{
									ok = 0;
									break;
								}
							}
							cnt = 0;
							x.clear();
						}
					}
					if (ok)
					{
						cout << need.size() << nl;
						for (int i = 0; i < need.size(); ++i)
						{
							cout << need[i] << ' ';
						}
						cout << nl;
						return;
					}
				}
			}
		}
	}
	cout << -1 << nl;
}
    
int main ()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int ttt = 1;
//  cin >> ttt;
    for (int test = 1; test <= ttt; test++)
    {
//      cout << "Case " << test << ":" << nl;
        ma1n();
    }
    return 0;
}

Compilation message

Main.cpp: In function 'void ma1n()':
Main.cpp:72:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |       for (int i = 0; i < need.size(); ++i)
      |                       ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 220 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 1 ms 216 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 216 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 220 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 1 ms 216 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 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
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 316 KB Output is correct
16 Correct 1 ms 216 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct