제출 #666265

#제출 시각아이디문제언어결과실행 시간메모리
666265Chal1shkanLampice (COCI21_lampice)C++14
50 / 50
1 ms340 KiB
# 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;
}

컴파일 시 표준 에러 (stderr) 메시지

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)
      |                       ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...