Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions atcoder/all
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>
#include "atcoder/convolution"
#include "atcoder/dsu"
#include "atcoder/fenwicktree"
#include "atcoder/lazysegtree"
#include "atcoder/math"
#include "atcoder/maxflow"
#include "atcoder/mincostflow"
#include "atcoder/modint"
#include "atcoder/scc"
#include "atcoder/segtree"
#include "atcoder/string"
#include "atcoder/twosat"
2 changes: 1 addition & 1 deletion atcoder/convolution
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/convolution.hpp>
#include "atcoder/convolution.hpp"
5 changes: 3 additions & 2 deletions atcoder/convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

#include <algorithm>
#include <array>
#include <atcoder/internal_bit>
#include <atcoder/modint>
#include <cassert>
#include <type_traits>
#include <vector>

#include "atcoder/internal_bit"
#include "atcoder/modint"

namespace atcoder {

namespace internal {
Expand Down
2 changes: 1 addition & 1 deletion atcoder/dsu
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/dsu.hpp>
#include "atcoder/dsu.hpp"
2 changes: 1 addition & 1 deletion atcoder/fenwicktree
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/fenwicktree.hpp>
#include "atcoder/fenwicktree.hpp"
3 changes: 2 additions & 1 deletion atcoder/fenwicktree.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#ifndef ATCODER_FENWICKTREE_HPP
#define ATCODER_FENWICKTREE_HPP 1

#include <atcoder/internal_type_traits>
#include <cassert>
#include <vector>

#include "atcoder/internal_type_traits"

namespace atcoder {

// Reference: https://en.wikipedia.org/wiki/Fenwick_tree
Expand Down
2 changes: 1 addition & 1 deletion atcoder/internal_bit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/internal_bit.hpp>
#include "atcoder/internal_bit.hpp"
2 changes: 1 addition & 1 deletion atcoder/internal_math
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/internal_math.hpp>
#include "atcoder/internal_math.hpp"
2 changes: 1 addition & 1 deletion atcoder/internal_queue
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/internal_queue.hpp>
#include "atcoder/internal_queue.hpp"
2 changes: 1 addition & 1 deletion atcoder/internal_scc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/internal_scc.hpp>
#include "atcoder/internal_scc.hpp"
2 changes: 1 addition & 1 deletion atcoder/internal_type_traits
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/internal_type_traits.hpp>
#include "atcoder/internal_type_traits.hpp"
2 changes: 1 addition & 1 deletion atcoder/lazysegtree
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/lazysegtree.hpp>
#include "atcoder/lazysegtree.hpp"
4 changes: 3 additions & 1 deletion atcoder/lazysegtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#define ATCODER_LAZYSEGTREE_HPP 1

#include <algorithm>
#include <atcoder/internal_bit>
#include <cassert>
#include <iostream>
#include <vector>

#include "atcoder/internal_bit"

namespace atcoder {

template <class S,
Expand Down
2 changes: 1 addition & 1 deletion atcoder/math
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/math.hpp>
#include "atcoder/math.hpp"
3 changes: 2 additions & 1 deletion atcoder/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include <cassert>
#include <tuple>
#include <vector>
#include <atcoder/internal_math>

#include "atcoder/internal_math"

namespace atcoder {

Expand Down
2 changes: 1 addition & 1 deletion atcoder/maxflow
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/maxflow.hpp>
#include "atcoder/maxflow.hpp"
3 changes: 2 additions & 1 deletion atcoder/maxflow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#define ATCODER_MAXFLOW_HPP 1

#include <algorithm>
#include <atcoder/internal_queue>
#include <cassert>
#include <limits>
#include <queue>
#include <vector>

#include "atcoder/internal_queue"

namespace atcoder {

template <class Cap> struct mf_graph {
Expand Down
2 changes: 1 addition & 1 deletion atcoder/mincostflow
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/mincostflow.hpp>
#include "atcoder/mincostflow.hpp"
2 changes: 1 addition & 1 deletion atcoder/modint
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/modint.hpp>
#include "atcoder/modint.hpp"
5 changes: 3 additions & 2 deletions atcoder/modint.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef ATCODER_MODINT_HPP
#define ATCODER_MODINT_HPP 1

#include <atcoder/internal_math>
#include <atcoder/internal_type_traits>
#include <cassert>
#include <numeric>
#include <type_traits>
Expand All @@ -11,6 +9,9 @@
#include <intrin.h>
#endif

#include "atcoder/internal_math"
#include "atcoder/internal_type_traits"

namespace atcoder {

namespace internal {
Expand Down
2 changes: 1 addition & 1 deletion atcoder/scc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/scc.hpp>
#include "atcoder/scc.hpp"
3 changes: 2 additions & 1 deletion atcoder/scc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#define ATCODER_SCC_HPP 1

#include <algorithm>
#include <atcoder/internal_scc>
#include <cassert>
#include <vector>

#include "atcoder/internal_scc"

namespace atcoder {

struct scc_graph {
Expand Down
2 changes: 1 addition & 1 deletion atcoder/segtree
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/segtree.hpp>
#include "atcoder/segtree.hpp"
3 changes: 2 additions & 1 deletion atcoder/segtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#define ATCODER_SEGTREE_HPP 1

#include <algorithm>
#include <atcoder/internal_bit>
#include <cassert>
#include <vector>

#include "atcoder/internal_bit"

namespace atcoder {

template <class S, S (*op)(S, S), S (*e)()> struct segtree {
Expand Down
2 changes: 1 addition & 1 deletion atcoder/string
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/string.hpp>
#include "atcoder/string.hpp"
2 changes: 1 addition & 1 deletion atcoder/twosat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <atcoder/twosat.hpp>
#include "atcoder/twosat.hpp"
3 changes: 2 additions & 1 deletion atcoder/twosat.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#ifndef ATCODER_TWOSAT_HPP
#define ATCODER_TWOSAT_HPP 1

#include <atcoder/internal_scc>
#include <cassert>
#include <vector>

#include "atcoder/internal_scc"

namespace atcoder {

// Reference:
Expand Down
43 changes: 25 additions & 18 deletions expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@


class Expander:
local_include = re.compile(
r'#include\s*"([a-z_]*(|.hpp))"\s*')
atcoder_include = re.compile(
'#include\s*["<](atcoder/[a-z_]*(|.hpp))[">]\s*')
r'#include\s*["<](atcoder/[a-z_]*(|.hpp))[">]\s*')

include_guard = re.compile('#.*ATCODER_[A-Z_]*_HPP')
include_guard = re.compile(r'#.*ATCODER_[A-Z_]*_HPP')

def is_ignored_line(self, line) -> bool:
if self.include_guard.match(line):
Expand All @@ -30,27 +32,24 @@ def is_ignored_line(self, line) -> bool:
def __init__(self, lib_paths: List[Path]):
self.lib_paths = lib_paths

included = set() # type: Set[str]
included = set() # type: Set[Path]

def find_acl(self, acl_name: str) -> Optional[Path]:
def find_acl(self, acl_name: str) -> Path:
for lib_path in self.lib_paths:
path = lib_path / acl_name
if path.exists():
return path
return None
logger.error('cannot find: {}'.format(acl_name))
raise FileNotFoundError()

def expand_acl(self, acl_name: str) -> List[str]:
if acl_name in self.included:
logger.info('already included: {}'.format(acl_name))
def expand_acl(self, acl_file_path: Path) -> List[str]:
if acl_file_path in self.included:
logger.info('already included: {}'.format(acl_file_path.name))
return []
self.included.add(acl_name)
logger.info('include: {}'.format(acl_name))
acl_path = self.find_acl(acl_name)
if not acl_path:
logger.warning('cannot find: {}'.format(acl_name))
raise FileNotFoundError()
self.included.add(acl_file_path)
logger.info('include: {}'.format(acl_file_path.name))

acl_source = open(str(acl_path)).read()
acl_source = open(str(acl_file_path)).read()

result = [] # type: List[str]
for line in acl_source.splitlines():
Expand All @@ -59,7 +58,14 @@ def expand_acl(self, acl_name: str) -> List[str]:

m = self.atcoder_include.match(line)
if m:
result.extend(self.expand_acl(m.group(1)))
name = m.group(1)
result.extend(self.expand_acl(self.find_acl(name)))
continue

m = self.local_include.match(line)
if m:
name = m.group(1)
result.extend(self.expand_acl(acl_file_path.parent / name))
continue

result.append(line)
Expand All @@ -71,10 +77,11 @@ def expand(self, source: str) -> str:
result = [] # type: List[str]
for line in source.splitlines():
m = self.atcoder_include.match(line)

if m:
result.extend(self.expand_acl(m.group(1)))
acl_path = self.find_acl(m.group(1))
result.extend(self.expand_acl(acl_path))
continue

result.append(line)
return '\n'.join(result)

Expand Down
3 changes: 2 additions & 1 deletion test/unittest/basic_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <atcoder/all>
#include "atcoder/all"

#include <type_traits>

#include <gtest/gtest.h>
Expand Down
3 changes: 2 additions & 1 deletion test/unittest/bit_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <atcoder/internal_bit>
#include "atcoder/internal_bit"

#include <numeric>

#include <gtest/gtest.h>
Expand Down
5 changes: 3 additions & 2 deletions test/unittest/convolution_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <atcoder/convolution>
#include <atcoder/modint>
#include "atcoder/convolution"
#include "atcoder/modint"

#include <random>
#include "../utils/random.hpp"

Expand Down
3 changes: 2 additions & 1 deletion test/unittest/dsu_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <atcoder/dsu>
#include "atcoder/dsu"

#include <numeric>

#include <gtest/gtest.h>
Expand Down
5 changes: 3 additions & 2 deletions test/unittest/fenwicktree_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <atcoder/fenwicktree>
#include <atcoder/modint>
#include "atcoder/fenwicktree"
#include "atcoder/modint"

#include <numeric>

#include <gtest/gtest.h>
Expand Down
7 changes: 4 additions & 3 deletions test/unittest/internal_math_test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include <gtest/gtest.h>
#include <numeric>
#include "atcoder/internal_math"

#include "../utils/math.hpp"

#include <atcoder/internal_math>
#include <gtest/gtest.h>
#include <numeric>

using namespace atcoder;
using uint = unsigned int;
Expand Down
6 changes: 4 additions & 2 deletions test/unittest/lazysegtree_stress_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <algorithm>
#include <atcoder/lazysegtree>
#include "atcoder/lazysegtree"

#include "../utils/random.hpp"

#include <algorithm>
#include <string>
#include <vector>

Expand Down
3 changes: 2 additions & 1 deletion test/unittest/lazysegtree_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "atcoder/lazysegtree"

#include <algorithm>
#include <atcoder/lazysegtree>
#include <string>
#include <vector>

Expand Down
3 changes: 2 additions & 1 deletion test/unittest/math_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <atcoder/math>
#include "atcoder/math"

#include <numeric>

#include <gtest/gtest.h>
Expand Down
5 changes: 3 additions & 2 deletions test/unittest/maxflow_test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include <atcoder/maxflow>
#include "atcoder/maxflow"
#include "../utils/random.hpp"

#include <numeric>
#include <tuple>
#include <vector>
#include "../utils/random.hpp"

#include <gtest/gtest.h>

Expand Down
7 changes: 4 additions & 3 deletions test/unittest/mincostflow_test.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include "atcoder/maxflow"
#include "atcoder/mincostflow"

#include "../utils/random.hpp"

#include <numeric>
#include <tuple>
#include <vector>
#include "../utils/random.hpp"

#include <gtest/gtest.h>

Expand Down
3 changes: 2 additions & 1 deletion test/unittest/modint_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <atcoder/modint>
#include "atcoder/modint"

#include <type_traits>

#include <gtest/gtest.h>
Expand Down
Loading