AtCoder Beginner Contest 001

Submission #792631

Source codeソースコード

#include <ctime>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
template <class Type>
class BIT {
private:
	size_t size_; Type *v;
	inline Type sum(size_t r) { Type ret = 0; while (r > 0) ret += v[r], r -= r & (-r); return ret; }
public:
	BIT() {};
	BIT(size_t size__) {
		for (size_ = 1; size_ < size__;) size_ <<= 1;
		v = (Type *)malloc(sizeof(Type) * (size_ + 1));
		for (size_t i = 0; i <= size_; i++) v[i] = 0;
	}
	inline void add(size_t i, Type x) { i++; while (i <= size_) v[i] += x, i += i & -i; }
	inline Type sum(size_t l, size_t r) { return sum(r) - sum(l); }
	bool operator[](size_t x) { return sum(x, x + 1); }
};
template <class Type>
class BIT2 {
private:
	size_t size_; vector<Type> v;
	Type sum(size_t r) { Type ret = 0; while (r > 0) ret += v[r], r -= r & (-r); return ret; }
public:
	BIT2() {};
	BIT2(size_t size__) {
		for (size_ = 1; size_ < size__;) size_ <<= 1;
		v.resize(size_ + 1, 0);
	}
	inline void add(size_t i, Type x) { i++; while (i <= size_) v[i] += x, i += i & -i; }
	inline Type sum(size_t l, size_t r) { return sum(r) - sum(l); }
	bool operator[](size_t x) { return sum(x, x + 1); }
};
int main() {
	srand((unsigned)time(NULL));
	int a, b;
	scanf("%d%d", &a, &b);
	BIT<int> x(1 << 15);
	for (int i = 0; i < (1 << 25); i++) {
		int k = i & 32767;
		x.add(k ^ 23233, k ^ 9548);
		int l = k ^ 15496, r = k ^ 2544;
		if (l > r) swap(l, r);
		x.sum(l, r + 1);
	}
	printf("%d\n", a - b);
	//cout << clock() - t << endl;
	return 0;
}

Submission

Task問題 A - 積雪深差
User nameユーザ名 square1001
Created time投稿日時
Language言語 C++11 (GCC 4.8.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 1548 Byte
File nameファイル名
Exec time実行時間 1677 ms
Memory usageメモリ使用量 1052 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &a, &b);
^

Test case

Set

Set name Score得点 / Max score Cases
all 100 / 100 00_sample_01.txt,00_sample_02.txt,00_sample_03.txt,test_01.txt,test_02.txt,test_03.txt,test_04.txt,test_05.txt,test_06.txt,test_07.txt,test_08.txt,test_09.txt,test_10.txt,test_11.txt,test_12.txt,test_13.txt,test_14.txt,test_15.txt,test_16.txt,test_17.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample_01.txt AC 1666 ms 928 KB
00_sample_02.txt AC 1672 ms 1000 KB
00_sample_03.txt AC 1663 ms 1000 KB
test_01.txt AC 1661 ms 928 KB
test_02.txt AC 1660 ms 932 KB
test_03.txt AC 1659 ms 1000 KB
test_04.txt AC 1671 ms 1052 KB
test_05.txt AC 1664 ms 932 KB
test_06.txt AC 1668 ms 1012 KB
test_07.txt AC 1667 ms 1008 KB
test_08.txt AC 1663 ms 1004 KB
test_09.txt AC 1664 ms 916 KB
test_10.txt AC 1665 ms 1000 KB
test_11.txt AC 1661 ms 1008 KB
test_12.txt AC 1664 ms 1000 KB
test_13.txt AC 1677 ms 1004 KB
test_14.txt AC 1664 ms 1000 KB
test_15.txt AC 1663 ms 1000 KB
test_16.txt AC 1664 ms 924 KB
test_17.txt AC 1668 ms 880 KB