Submission #158547

#TimeUsernameProblemLanguageResultExecution timeMemory
158547luciocfPort Facility (JOI17_port_facility)C++14
0 / 100
2 ms504 KiB
#include <bits/stdc++.h>

#define ff first
#define ss second

using namespace std;

typedef pair<int, int> pii;

const int maxn = 1e6+10;

pii a[maxn];

pii event[maxn];

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

	for (int i = 1; i <= n; i++)
		scanf("%d %d", &a[i].ff, &a[i].ss);

	sort(a+1, a+n+1);

	for (int i = 1; i <= n; i++)
	{
		event[a[i].ff] = {i, 1};
		event[a[i].ss] = {i, 0};
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = i+1; j <= n; j++)
		{
			for (int k = j+1; k <= n; k++)
			{
				if (a[j].ff < a[i].ss && a[k].ff < a[i].ss && a[j].ss > a[i].ss && a[k].ss > a[j].ss)
				{
					printf("0\n");
					return 0;
				}
			}
		}
	}

	int ans = 1;

	for (int i = 1; i <= 2*n; i++)
	{
		pii pp = event[i];

		int ind = pp.ff, op = pp.ss;

		if (op == 0)
		{
			bool ok = 1;

			for (int j = 1; j < ind; j++)
				if (a[j].ss > a[ind].ff && a[j].ss < a[ind].ss)
					ok = 0;

			if (ok)
				ans *= 2;
		}
	}

	printf("%d\n", ans);
}

Compilation message (stderr)

port_facility.cpp: In function 'int main()':
port_facility.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
port_facility.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a[i].ff, &a[i].ss);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...