제출 #246720

#제출 시각아이디문제언어결과실행 시간메모리
246720luciocfNaan (JOI19_naan)C++14
29 / 100
496 ms55800 KiB
#include <bits/stdc++.h>

#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

const int maxn = 2e3+10;

int a[maxn][maxn];
ll soma[maxn];

pii split[maxn][maxn];

bool mark[maxn];

bool menor(pii f1, pii f2)
{
	return f1.ff*f2.ss < f2.ff*f1.ss;
}

int main(void)
{
	int n, l;
	scanf("%d %d", &n, &l);

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= l; j++)
		{
			scanf("%d", &a[i][j]);

			soma[i] += 1ll*a[i][j];
		}
	}

	for (int i = 1; i <= n; i++)
	{
		int at = 1;
		ll s = 0;

		for (int j = 1; j < n; j++)
		{
			s += soma[i];

			while (at <= l && 1ll*a[i][at]*n <= s)
				s -= 1ll*a[i][at++]*n;

			ll g = __gcd(s + 1ll*(at-1)*a[i][at]*n, 1ll*a[i][at]*n);
			split[i][j] = {(s + 1ll*(at-1)*a[i][at]*n)/g, (1ll*a[i][at]*n)/g};
		}
	}

	vector<int> p;

	for (int i = 1; i < n; i++)
	{
		int ind = 0;

		for (int j = 1; j <= n; j++)
		{
			if (mark[j]) continue;

			if (!ind || menor(split[j][i], split[ind][i]))
				ind = j;
		}

		mark[ind] = 1;

		printf("%lld %lld\n", split[ind][i].ff, split[ind][i].ss);
		p.push_back(ind);
	}

	for (int i = 1; i <= n; i++)
		if (!mark[i])
			p.push_back(i);

	for (auto x: p)
		printf("%d ", x);
	printf("\n");
}

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

naan.cpp: In function 'int main()':
naan.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &l);
  ~~~~~^~~~~~~~~~~~~~~~~
naan.cpp:34:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &a[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...