답안 #332637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
332637 2020-12-03T01:58:56 Z Kevin_Zhang_TW Selling RNA Strands (JOI16_selling_rna) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T>
bool chmax(T &v, T val) { return v < val ? (v = val, true) : false; }
template<class T>
bool chmin(T &v, T val) { return val < v ? (v = val, true) : false; }

#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U>
void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T>
void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif

const int MAX_N = 100010;

int n, m, enc[256], res[MAX_N];
string w[MAX_N], p[MAX_N], q[MAX_N], rw[MAX_N];
int ac[MAX_N], ca[MAX_N];

struct ask {
	int u, d, sc, id;
};
bitset<5000> pfa[MAX_N], pfb[MAX_N];
void brute(vector<ask> qries) {
	for (int i = 0;i < n;++i) {
		if (i) pfa[i] = pfa[i-1];
		pfa[i][ ac[i] ] = true;
	}
	for (int i = 0;i < n;++i) {
		if (i) pfb[i] = pfb[i-1];
		pfb[i][ ca[i] ] = true;
	}
	for (auto [u, d, sc, id] : qries) {
		if (min(u, d) < 0) continue;
		DE(u, d, sc, id);
		res[id] += sc * (pfa[u] & pfb[d]).count();
	}
}
bool cmpac(int a, int b) { return w[a] < w[b]; }
bool cmpca(int a, int b) { return rw[a] < rw[b]; }
void solve() {
	iota(ac, ac+n, 0);
	iota(ca, ca+n, 0);
	for (int i = 0;i < n;++i) {
		rw[i] = w[i];
		reverse(AI(rw[i]));
	}
	for (int i = 0;i < m;++i)
		reverse(AI(q[i]));

	sort(ca, ca+n, cmpca);
//
//	for (int i = 0;i < n;++i) 
//		cout << w[ ac[i] ] << '\n';
//	cout << '\n';
//	for (int i = 0;i < n;++i) 
//		cout << w[ ca[i] ] << '\n';

	
	vector<ask> qries;

	for (int i = 0;i < m;++i) {
		w[n] = p[i];
		rw[n] = q[i];
		DE(w[n], rw[n]);

		int al = lower_bound(ac, ac+n, n, cmpac) - ac;
		int cl = lower_bound(ca, ca+n, n, cmpca) - ca;
		w[n].push_back(255);
		rw[n].push_back(255);
		int ar = lower_bound(ac, ac+n, n, cmpac) - ac;
		int cr = lower_bound(ca, ca+n, n, cmpca) - ca;
		DE(al, ar, cl, cr);
		if (al == ar || cl == cr) continue;
		--ar, --cr;

		qries.pb(ar, cr, 1, i), qries.pb(ar, cl-1, -1, i);
		qries.pb(al-1, cr, -1, i), qries.pb(al-1, cl-1, 1, i);
	}

	brute(qries);

}
int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	enc['A'] = 0, enc['G'] = 1, enc['C'] = 2, enc['U'] = 3;
	cin >> n >> m;
	for (int i = 0;i < n;++i)
		cin >> w[i];

	for (int i = 0;i < m;++i)
		cin >> p[i] >> q[i];

	sort(w, w+n);

	if (n > 5000) return 1;

	solve();

	for (int i = 0;i < m;++i)
		cout << res[i] << '\n';
}

Compilation message

selling_rna.cpp: In function 'void brute(std::vector<ask>)':
selling_rna.cpp:19:17: warning: statement has no effect [-Wunused-value]
   19 | #define DE(...) 0
      |                 ^
selling_rna.cpp:44:3: note: in expansion of macro 'DE'
   44 |   DE(u, d, sc, id);
      |   ^~
selling_rna.cpp: In function 'void solve()':
selling_rna.cpp:19:17: warning: statement has no effect [-Wunused-value]
   19 | #define DE(...) 0
      |                 ^
selling_rna.cpp:74:3: note: in expansion of macro 'DE'
   74 |   DE(w[n], rw[n]);
      |   ^~
selling_rna.cpp:19:17: warning: statement has no effect [-Wunused-value]
   19 | #define DE(...) 0
      |                 ^
selling_rna.cpp:82:3: note: in expansion of macro 'DE'
   82 |   DE(al, ar, cl, cr);
      |   ^~
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/string:41,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from selling_rna.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = ask; _Args = {int&, int&, int, int&}; _Tp = ask]':
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = ask; _Args = {int&, int&, int, int&}; _Tp = ask; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<ask>]'
/usr/include/c++/9/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&, int, int&}; _Tp = ask; _Alloc = std::allocator<ask>; std::vector<_Tp, _Alloc>::reference = ask&]'
selling_rna.cpp:86:24:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: new initializer expression list treated as compound expression [-fpermissive]
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/ext/new_allocator.h:145:20: error: no matching function for call to 'ask::ask(int&)'
selling_rna.cpp:29:8: note: candidate: 'ask::ask()'
   29 | struct ask {
      |        ^~~
selling_rna.cpp:29:8: note:   candidate expects 0 arguments, 1 provided
selling_rna.cpp:29:8: note: candidate: 'constexpr ask::ask(const ask&)'
selling_rna.cpp:29:8: note:   no known conversion for argument 1 from 'int' to 'const ask&'
selling_rna.cpp:29:8: note: candidate: 'constexpr ask::ask(ask&&)'
selling_rna.cpp:29:8: note:   no known conversion for argument 1 from 'int' to 'ask&&'
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/string:41,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from selling_rna.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = ask; _Args = {int&, int, int, int&}; _Tp = ask]':
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = ask; _Args = {int&, int, int, int&}; _Tp = ask; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<ask>]'
/usr/include/c++/9/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int, int, int&}; _Tp = ask; _Alloc = std::allocator<ask>; std::vector<_Tp, _Alloc>::reference = ask&]'
selling_rna.cpp:86:51:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: new initializer expression list treated as compound expression [-fpermissive]
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/ext/new_allocator.h:145:20: error: no matching function for call to 'ask::ask(int&)'
selling_rna.cpp:29:8: note: candidate: 'ask::ask()'
   29 | struct ask {
      |        ^~~
selling_rna.cpp:29:8: note:   candidate expects 0 arguments, 1 provided
selling_rna.cpp:29:8: note: candidate: 'constexpr ask::ask(const ask&)'
selling_rna.cpp:29:8: note:   no known conversion for argument 1 from 'int' to 'const ask&'
selling_rna.cpp:29:8: note: candidate: 'constexpr ask::ask(ask&&)'
selling_rna.cpp:29:8: note:   no known conversion for argument 1 from 'int' to 'ask&&'
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/string:41,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from selling_rna.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = ask; _Args = {int, int&, int, int&}; _Tp = ask]':
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = ask; _Args = {int, int&, int, int&}; _Tp = ask; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<ask>]'
/usr/include/c++/9/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, int&, int, int&}; _Tp = ask; _Alloc = std::allocator<ask>; std::vector<_Tp, _Alloc>::reference = ask&]'
selling_rna.cpp:87:27:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: new initializer expression list treated as compound expression [-fpermissive]
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/ext/new_allocator.h:145:20: error: no matching function for call to 'ask::ask(int&)'
selling_rna.cpp:29:8: note: candidate: 'ask::ask()'
   29 | struct ask {
      |        ^~~
selling_rna.cpp:29:8: note:   candidate expects 0 arguments, 1 provided
selling_rna.cpp:29:8: note: candidate: 'constexpr ask::ask(const ask&)'
selling_rna.cpp:29:8: note:   no known conversion for argument 1 from 'int' to 'const ask&'
selling_rna.cpp:29:8: note: candidate: 'constexpr ask::ask(ask&&)'
selling_rna.cpp:29:8: note:   no known conversion for argument 1 from 'int' to 'ask&&'
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/string:41,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from selling_rna.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = ask; _Args = {int, int, int, int&}; _Tp = ask]':
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = ask; _Args = {int, int, int, int&}; _Tp = ask; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<ask>]'
/usr/include/c++/9/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, int, int, int&}; _Tp = ask; _Alloc = std::allocator<ask>; std::vector<_Tp, _Alloc>::reference = ask&]'
selling_rna.cpp:87:55:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: new initializer expression list treated as compound expression [-fpermissive]
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/ext/new_allocator.h:145:20: error: no matching function for call to 'ask::ask(int&)'
selling_rna.cpp:29:8: note: candidate: 'ask::ask()'
   29 | struct ask {
      |        ^~~
selling_rna.cpp:29:8: note:   candidate expects 0 arguments, 1 provided
selling_rna.cpp:29:8: note: candidate: 'constexpr ask::ask(const ask&)'
selling_rna.cpp:29:8: note:   no known conversion for argument 1 from 'int' to 'const ask&'
selling_rna.cpp:29:8: note: candidate: 'constexpr ask::ask(ask&&)'
selling_rna.cpp:29:8: note:   no known conversion for argument 1 from 'int' to 'ask&&'