답안 #109180

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
109180 2019-05-05T10:49:43 Z MetB Pairs (IOI07_pairs) C++14
18 / 100
314 ms 293848 KB
#include <iostream>
#include <cstdlib>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <math.h>
#include <stack>
#include <vector>
#include <string.h>
#include <random>
 
typedef long long ll;
 
const ll MOD = 1e9 + 7, INF = 1e18;
 
using namespace std;

struct Fenwick1D
{
	vector <int> t;
	int n;

	void build (int v)
	{
		n = v;
		t.resize (n + 1);
	}

	void update (int x, int d)
	{
		for (;x <= n; x = (x | (x + 1)))
			t[x] += d;
	}

	int get (int r)
	{
		int sum = 0;
		for (;r >= 0; r = (r & (r + 1)) - 1)
			sum += t[r];
		return sum;
	}

	int get (int l, int r)
	{
		return get (r) - get (l - 1);
	}
} t1d, row2d, col2d;

struct Fenwick2D
{
	vector < vector <int> > t;
	int n;

	void build (int v)
	{
		n = v;
		t.resize (n + 1);

		for (int i = 0; i <= n; i++)
			t[i].resize (n + 1);
	}

	void update (int x, int y, int d)
	{
		for (;x <= n; x = (x | (x + 1)))
			for (; y <= n; y = (y | (y + 1)))
				t[x][y] += d;
	}

	int get (int r1, int r2)
	{
		int sum = 0;
		for (;r1 >= 0; r1 = (r1 & (r1 + 1)) - 1)
			for (;r2 >= 0; r2 = (r2 & (r2 + 1)) - 1)
				sum += t[r1][r2];
		return sum;
	}

	int get (int x1, int y1, int x2, int y2)
	{
		return get (x2, y2) - get (x1, y2) - get (x2, y1) + get (x1, y1);
	}
} t2d;

int n, b, d, m, a[100000], ans;

int main ()
{
	cin >> b >> n >> d >> m;

	if (b == 1)
	{
		t1d.build (m);

		for (int i = 0; i < n; i++)
			scanf ("%d", &a[i]);

		sort (a, a + n);

		for (int i = 0; i < n; i++)
		{
			ans += t1d.get (a[i] - d, a[i]);
			t1d.update (a[i], 1);
		}

		cout << ans << endl;
	}
	else b /= 0;

}

Compilation message

pairs.cpp: In function 'int main()':
pairs.cpp:111:9: warning: division by zero [-Wdiv-by-zero]
  else b /= 0;
       ~~^~~~
pairs.cpp:99:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf ("%d", &a[i]);
    ~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 260 ms 293848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 896 KB Output is correct
2 Incorrect 24 ms 1152 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 314 ms 275696 KB Output is correct
2 Incorrect 255 ms 275548 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 278 ms 275600 KB Output is correct
2 Correct 260 ms 275580 KB Output is correct
3 Correct 269 ms 275580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 384 KB Execution killed with signal 4 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 384 KB Execution killed with signal 4 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 384 KB Execution killed with signal 4 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 384 KB Execution killed with signal 4 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 384 KB Execution killed with signal 4 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 384 KB Execution killed with signal 4 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 432 KB Execution killed with signal 4 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 512 KB Execution killed with signal 4 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -