submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s984098426
p03893
C++
#include <iostream> using namespace std; int main() { f[0]=2; cin>>n; for(int i=1;i<=n;i++) f[n]=f[n-1]*2+2; cout<<f[n]<<endl; return 0; } //f[n]=f[n-1]*2+2
a.cc: In function 'int main()': a.cc:5:5: error: 'f' was not declared in this scope 5 | f[0]=2; | ^ a.cc:6:10: error: 'n' was not declared in this scope 6 | cin>>n; | ^
s615990511
p03893
C++
#include<iostream> using namespace std; const int MAXN=101;//好习惯:下标为常量 long long f[MAXN],X;//一定要用long long,我第一次 就因此WA了一次 int main(){ cin>>X; f[0]=2;/记住:赋初值 for(int i=1;i<=X;i++) f[i]=f[i-1]*2+2; //一个easy的递推,按照公式 cout<<f[X]<<endl;//输出 return 0;//快乐结束 }
a.cc: In function 'int main()': a.cc:7:12: error: expected primary-expression before '/' token 7 | f[0]=2;/记住:赋初值 | ^ a.cc:7:13: error: '\U00008bb0\U00004f4f\U0000ff1a\U00008d4b\U0000521d\U0000503c' was not declared in this scope 7 | f[0]=2;/记住:赋初值 | ^~~~~~~~~~~~ a.cc:8:17: error: 'i' was not declared in this scope 8 | for(int i=1;i<=X;i++) f[i]=f[i-1]*2+2; | ^
s214158640
p03893
C++
#include<iostream> using nsmespace std; int a=2,n; int main() { cin>>n; for(int i=1;i<=n;i++) { a*=2; a+=2; } cout<<a<<endl; }
a.cc:2:7: error: expected nested-name-specifier before 'nsmespace' 2 | using nsmespace std; | ^~~~~~~~~ a.cc: In function 'int main()': a.cc:6:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 6 | cin>>n; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:12:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 12 | cout<<a<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:12:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 12 | cout<<a<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s448488745
p03893
C++
#include<cstdio> #include<iostream> #include<cmath> using namespace std; int n; long long f[400] int main() { scanf("%d",&n); f[0]=2; for(int i=0;i<=n;i++) f[i]=f[i-1]*2+2; printf("%d\n",f[n]); return 0; }
a.cc:7:1: error: expected initializer before 'int' 7 | int main() | ^~~
s308322191
p03893
C++
#include<cstdio> #include<iostream> #include<cmath> using namespace std; int n; long long f[400] int main() { scanf("%d",&n); f[0]=2; for(int i=0;i<=n;i++) f[i]=f[i-1]*2+2; printf("%d",f[n]); return 0; }
a.cc:7:1: error: expected initializer before 'int' 7 | int main() | ^~~
s730102490
p03893
C++
2
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 2 | ^
s081381539
p03893
C++
#include <cstdio> int main() { int n,f[41] = {2}; scanf("%d",&n); for (int i = 1;<= n;i++) f[i] = f[i-1]*2+2; printf("%d",f[n]); return 0; }
a.cc: In function 'int main()': a.cc:5:20: error: expected primary-expression before '<=' token 5 | for (int i = 1;<= n;i++) f[i] = f[i-1]*2+2; | ^~
s447832985
p03893
C++
x=int(input()) j=2 for i in range(x): j*=2 j+=2 print(j)
a.cc:1:1: error: 'x' does not name a type 1 | x=int(input()) | ^
s390089579
p03894
C++
acm test
a.cc:1:1: error: 'acm' does not name a type 1 | acm test | ^~~
s766662744
p03894
C++
qwe
a.cc:1:1: error: 'qwe' does not name a type 1 | qwe | ^~~
s735428739
p03894
C++
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,Q; int A[101010],B[101010]; int D[101010]; int yes[101010]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>Q; FOR(i,N) D[i]=i; yes[0]=1; yes[1]=1; cur=0; FOR(i,Q) { cin>>A[i]>>B[i]; A[i]--,B[i]--; if(A[i]==cur) cur=B[i]; else if(B[i]==cur) cur=A[i]; swap(D[A[i]],D[B[i]]); if(cur) yes[D[cur-1]]=1; if(cur<N-1) yes[D[cur+1]]=1; } cout<<count(yes,yes+N,1)<<endl; } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:26:9: error: 'cur' was not declared in this scope 26 | cur=0; | ^~~
s669499520
p03894
C++
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,Q; int A[101010],B[101010]; int D[101010]; int yes[101010]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>Q; FOR(i,N) D[i]=i; yes[0]=1; yes[1]=1; cur=0; FOR(i,Q) { cin>>A[i]>>B[i]; if(A[i]==cur) cur=B[i]; else if(B[i]==cur) cur=A[i]; swap(D[A[i]],D[B[i]]); if(cur) yes[D[cur-1]]=1; if(cur<N-1) yes[D[cur+1]]=1; } cout<<count(yes,yes+N,1)<<endl; } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:26:9: error: 'cur' was not declared in this scope 26 | cur=0; | ^~~
s298159615
p03895
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T> class tRMQ { vector<T> data; T unit; public: int n; function<T(const T &, const T &)> f; tRMQ(int _, T u, function<T(T, T)> bi) { unit = u; f = bi; n = 1; while (n < _) { n <<= 1; } data.resize(n * 4); for (int i = 0; i < n * 4; i++) data[i] = unit; } tRMQ(vector<T> &v, T u, function<T(T, T)> bi) { unit = u; f = bi; n = 1; while (n < v.size()) n <<= 1; data.resize(n * 2 + 1); for (int i = 0; i < n + 1; i++) { if (i < v.size()) data[i + n] = v[i]; else data[i + n] = u; } for (int i = n - 1; i >= 0; i--) { data[i] = f(data[i * 2 + 1], data[i * 2 + 2]); } } void update(int index, T val) { int i = index + n - 1; data[i] = val; while (i > 0) { i = (i - 1) / 2; data[i] = f(data[i * 2 + 1], data[i * 2 + 2]); } } // [a, b) T query(int a, int b, int k, int l, int r) { if (a < 0 || r <= a || b <= l) return unit; if (a <= l && r <= b) return data[k]; else return f(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (r + l) / 2, r)); } }; int DAY = 86400; int MOR = 10800; int main() { int n; cin >> n; int base = 0; vector<ll> d(DAY); for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; d[(base + a) % DAY] += 1; base += a + b; base %= DAY; } tRMQ<ll> q(d, 0ll, [](const ll &l, const ll &r) { return l + r; }); ll ans = 0; for (int i = 0; i < DAY; i++) { ll b = q.query(max(-DAY + i, 0), max(-DAY + i + MOR + 1, 0)) + q.query(min(i, DAY), min(i + MOR + 1, DAY)); ans = max(ans, b); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:81:19: error: no matching function for call to 'tRMQ<long long int>::query(const int&, const int&)' 81 | ll b = q.query(max(-DAY + i, 0), max(-DAY + i + MOR + 1, 0)) + | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:53:5: note: candidate: 'T tRMQ<T>::query(int, int, int, int, int) [with T = long long int]' 53 | T query(int a, int b, int k, int l, int r) { | ^~~~~ a.cc:53:5: note: candidate expects 5 arguments, 2 provided a.cc:82:19: error: no matching function for call to 'tRMQ<long long int>::query(const int&, const int&)' 82 | q.query(min(i, DAY), min(i + MOR + 1, DAY)); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:53:5: note: candidate: 'T tRMQ<T>::query(int, int, int, int, int) [with T = long long int]' 53 | T query(int a, int b, int k, int l, int r) { | ^~~~~ a.cc:53:5: note: candidate expects 5 arguments, 2 provided
s058162781
p03897
C++
#include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; int main() { int n; cin >> n; vector<vector<int>> v(n, vector<int>(n, 0)); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if((i+j)&1^1){ v[i][j] = 1; } } } vector<pair<int, int>> ans; for (int i = 1; i < n; i += 6) { for (int j = 0; j < n; j += 2) { if(!v[i][j]){ v[i][j] = 1; ans.emplace_back(i, j); } } } for (int i = 4; i < n; i += 6) { for (int j = 1; j < n; j += 2) { if(!v[i][j]){ v[i][j] = 1; ans.emplace_back(i, j); } } } for (int i = 0; i < n; ++i) { if(!v[i][0]){ v[i][0] = 1; ans.emplace_back(i, 0); } if(!v[n-1][i]){ v[n-1][i] = 1; ans.emplace_back(n-1, i); } if(!v[i][n-1]){ v[i][n-1] = 1; ans.emplace_back(i, n-1); } } cout << ans.size() << "\n"; for (auto &&k : ans) { printf("%d %d\n", k.first, k.second);4 } return 0; }
a.cc: In function 'int main()': a.cc:64:47: error: expected ';' before '}' token 64 | printf("%d %d\n", k.first, k.second);4 | ^ | ; 65 | } | ~
s751465431
p03898
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using Pi = pair<int, int>; using Pl = pair<ll, ll>; using vint = vector<int>; using vvint = vector<vint>; using vvvint = vector<vvint>; using vll = vector<ll>; using uint = unsigned int; using ull = unsigned long long; template<typename T> using uset = unordered_set<T>; template<typename T1, typename T2> using umap = unordered_map<T1, T2>; constexpr int INF = (1 << 30) - 1; constexpr ll LLINF = 1LL << 60; constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}; constexpr char el = '\n'; constexpr int mod = 1000000007; template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); } template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); } template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } template<typename T> ostream& operator <<(ostream &os, vector<T> &v) { for (auto &u : v) os << u << el; return (os); } template<typename T> istream& operator >>(istream &is, vector<T> &v) { for (auto &u : v) is >> u; return (is); } template<typename T1, typename T2> istream& operator >>(istream &is, pair<T1, T2> &p) { return (is >> p.first >> p.second); } int main() { int N; cin >> N; vvint G(N); for (int i = 0; i < N-1; i++) { int p, q; cin >> p >> q; --p, --q; G[p].push_back(q); G[q].push_back(p); } int maxd = 0; function<int(int, int)> dfs = [&](int u, int prev) { int ret = (int)(G[u].size() == 2); vint dat; for (auto &v : G[u]) { if (v != prev) dat.push_back(dfs(v, u)); } sort(begin(dat), end(dat), greater<>()); int maxv = 0; if (dat.size() >= 1) { maxv = dat[0]; if (dat.size() >= 2) chmax(maxd, dat[0] + dat[1]); } chmax(maxd, ret + maxv); return (ret + maxv); }; int cnt = 0; for (int i = 0; i < N; i++) { if (G[i].size() == 1) cnt++; } dfs(i, -1); cout << cnt + maxd << endl; return (0); }
a.cc: In function 'int main()': a.cc:78:13: error: 'i' was not declared in this scope 78 | dfs(i, -1); | ^
s289633062
p03898
C++
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename F> struct FixPoint : F{ FixPoint(F&& f):F(forward<F>(f)){} template<typename... Args> decltype(auto) operator()(Args&&... args) const{ return F::operator()(*this,forward<Args>(args)...); } }; template<typename F> inline decltype(auto) MFP(F&& f){ return FixPoint<F>{forward<F>(f)}; } //INSERT ABOVE HERE signed main(){ int n; cin>>n; vector< vector<int> > G(n); for(int i=1;i<n;i++){ int p,q; cin>>p>>q; p--;q--; G[p].emplace_back(q); G[q].emplace_back(p); } vector<int> dp1(n,0),dp2(n,0),dp3(n,0); int ans=0; MFP([&](auto dfs,int v,int p)->void{ int sum=0; vector<int> vs,mx; for(int u:G[v]){ if(u==p) continue; dfs(u,v); sum+=dp2[u]; mx.emplace_back(dp1[u]); vs.emplace_back(dp1[u]-dp2[u]); } if(vs.empty()){ dp1[v]=1; dp2[v]=1; dp3[v]=1; return; } while(vs.size()<2) vs.emplace_back(0); while(mx.size()<2) mx.emplace_back(0); sort(vs.rbegin(),vs.rend()); sort(mx.rbegin(),mx.rend()); // c1 -> v -> c2, not take v chmax(dp3[v],sum+vs[0]+vs[1]); chmax(dp3[v],mx[0]+mx[1]); for(int u:G[v]){ if(u==p) continue; chmax(dp3[v],sum-dp2[u]+dp3[u]); chmax(ans,dp3[u]+1); } // c1 -> v, take v chmax(dp1[v],mx[0]+1); // c1 -> v, not take v chmax(dp1[v],sum+vs[0]); // not take v chmax(dp2[v],sum); // c1 -> v -> c2, take v chmax(ans,mx[0]+1+mx[1]); chmax(ans,dp1[v]); chmax(ans,dp2[v]); chmax(ans,dp3[v]); continue; cout<<v; cout<<", dp1[v] = "<<dp1[v]; cout<<", dp2[v] = "<<dp2[v]; cout<<", dp3[v] = "<<dp3[v]<<endl; })(0,-1); cout<<ans<<endl; return 0; }
a.cc: In lambda function: a.cc:83:9: error: continue statement not within a loop 83 | continue; | ^~~~~~~~
s367674416
p03898
C++
#include <cstdio> #include <vector> using namespace std; const int N = 100000; vector<int> g[N]; int sz[N], dp[N]; void dfs(int u, int prev) { vector<int> len; for (auto v : g[u]) if (prev != v) { dfs(v, u); len.push_back(sz[v]); dp[u] = max(dp[u], dp[v]); sz[u] = max(sz[u], sz[v] + (g[u].size() == 2)); } sort(len.rbegin(), len.rend()); if (len.size() >= 2) dp[u] = max(dp[u], len[0] + len[1] + (g[u].size() == 2)); } int main() { int n; scanf("%d", &n); for (int i = 0; i < n - 1; i ++) { int a, b; scanf("%d%d", &a, &b); a --, b --; g[a].push_back(b); g[b].push_back(a); } int leaf = 0; for (int i = 0; i < n; i ++) if (g[i].size() == 1) leaf ++; dfs(0, -1); printf("%d\n", dp[0] + leaf); return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:17:9: error: 'sort' was not declared in this scope; did you mean 'short'? 17 | sort(len.rbegin(), len.rend()); | ^~~~ | short
s523467426
p03898
C++
def dfs(z,c) r=[0,c] G[c].each{|e| next if e==z t=dfs(c,e) r=[r,[t[0]+(G[c].size==2 ? 1 : 0),t[1]]].max } r end N=gets.to_i G=N.times.map{[]} (N-1).times{ a,b=gets.split.map(&:to_i) G[a-1]<<b-1 G[b-1]<<a-1 } p dfs(-1,dfs(-1,0)[1])[0]+G.count{|e|e.size==1}
a.cc:1:1: error: 'def' does not name a type 1 | def dfs(z,c) | ^~~ a.cc:8:9: error: 'r' does not name a type 8 | r | ^ a.cc:12:3: error: expected ')' before '-' token 12 | (N-1).times{ | ~ ^ | ) a.cc:17:1: error: 'p' does not name a type 17 | p dfs(-1,dfs(-1,0)[1])[0]+G.count{|e|e.size==1} | ^
s213581894
p03899
C++
#include <bits/stdc++.h> using namespace std; #define ll long long #define se second #define fi first #define mp make_pair #define pb push_back #define all(_v) _v.begin(), _v.end() const int mod = (int)1e9 + 7; const int INF = (int)1e9; const ll LINF = (ll)1e18; const int N = (int)1e5 + 100; const int MAXA = (int)3e6; int n,m,k; deque<ll> q[310]; ll a[N]; ll dp[N][310]; void update(int pos,int j){ while(!q[j].empty() && dp[q[j].front()][j] <= dp[pos][j]){ q[j].pop_front(); } q[j].push_front(pos); if(q[j].back() < pos - m)q[j].pop_back(); } ll get_max(int j){ if(q[j].empty())return 0LL; return dp[q[j].back()][j]; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //ifstream cin("input.txt"); //ofstream cout("output.txt"); cin >> n >> m >> k; for(int i = 1;i <= n;i++)cin >> a[i]; for(int i = 1;i <= n;i++)dp[i][1] = a[i]; for(ll j = min(i, k);j >= 1;j--){ for(int i = 1;i <= n;i++){ dp[i][j] = get_max(j - 1) + (j * a[i] * 1LL); update(i, j); } } ll ans = 0; for(int i = 1;i <= n;i++){ for(int j = 0;j <= min(i, k);j++){ ans = max(ans, dp[i][j]); } } cout << ans; return 0; }
a.cc: In function 'int main()': a.cc:38:21: error: 'i' was not declared in this scope 38 | for(ll j = min(i, k);j >= 1;j--){ | ^
s086839508
p03899
C++
#include <bits/stdc++.h> using namespace std; using i64 = int_fast64_t; #define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i)) #define rep(i, n) repeat(i, 0, n) const i64 CYCLES_PER_SEC = 2800000000; struct Timer { i64 start; Timer() { reset(); } void reset() { start = getCycle(); } inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC * 1000; } private: inline i64 getCycle() { uint32_t low, high; __asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); return ((i64)low) | ((i64)high << 32); } } timer; /* SegmentTree */ template <typename T> struct SegTree { using F = function<T(T, T)>; int n; F f; T ti; vector<T> dat; SegTree(){}; SegTree(F f, T ti) : f(f), ti(ti) {} void init(int n_) { n = 1; while(n < n_) n <<= 1; dat.assign(n << 1, ti); } void build(const vector<T> &v) { int n_ = v.size(); init(n_); for(int i = 0; i < n_; i++) dat[n + i] = v[i]; for(int i = n - 1; i; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); } void update(int k, T x) { dat[k += n] = x; while(k >>= 1) dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]); } T query(int a, int b) { T vl = ti, vr = ti; for(int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) { if(l & 1) vl = f(vl, dat[l++]); if(r & 1) vr = f(dat[--r], vr); } return f(vl, vr); } template <typename C> int find(int st, C &check, T &acc, int k, int l, int r) { if(l + 1 == r) { acc = f(acc, dat[k]); return check(acc) ? k - n : -1; } int m = (l + r) >> 1; if(m <= st) return find(st, check, acc, (k << 1) | 1, m, r); if(st <= l && !check(f(acc, dat[k]))) { acc = f(acc, dat[k]); return -1; } int vl = find(st, check, acc, (k << 1) | 0, l, m); if(~vl) return vl; return find(st, check, acc, (k << 1) | 1, m, r); } template <typename C> int find(int st, C &check) { T acc = ti; return find(st, check, acc, 1, 0, n); } T operator[](const int &k) const { return dat[k + n]; } }; // https://atcoder.jp/contests/cf16-tournament-round3-open/tasks/asaporo_d void asaporo_d() { int n, m, k; scanf("%d%d%d", &n, &m, &k); std::vector<i64> a(n); rep(i, n) scanf("%ld", &a[i]); a.insert(a.begin(), 0LL); timer.reset(); SegTree<i64> seg([](i64 a, i64 b) { return std::max<i64>(a, b); }, 0); seg.build(std::vector<i64>(n + 10, 0)); std::vector<std::vector<i64>> dp( n + 10, std::vector<i64>(k + 10, static_cast<i64>(0))); for(i64 j = 0; j <= k; j++) { if(timer.get() > 1000) assert(0); rep(i, n + 1) seg.update(i, dp[i][j]); for(i64 i = 1; i <= n; i++) { if(j >= i) dp[i][j + 1] = 0; dp[i][j + 1] = (j + 1) * a[i] + seg.query(max(i - m, 0LL), i); } } i64 ret = 0; printf("%ld\n", seg.query(0, n + 1)); } int main() { asaporo_d(); return 0; }
a.cc: In function 'void asaporo_d()': a.cc:104:58: error: no matching function for call to 'max(i64, long long int)' 104 | dp[i][j + 1] = (j + 1) * a[i] + seg.query(max(i - m, 0LL), i); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:104:58: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 104 | dp[i][j + 1] = (j + 1) * a[i] + seg.query(max(i - m, 0LL), i); | ~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:104:58: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 104 | dp[i][j + 1] = (j + 1) * a[i] + seg.query(max(i - m, 0LL), i); | ~~~^~~~~~~~~~~~
s196441416
p03899
C++
#include <bits/stdc++.h> using namespace std; using i64 = int_fast64_t; #define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i)) #define rep(i, n) repeat(i, 0, n) const i64 CYCLES_PER_SEC = 2800000000; struct Timer { i64 start; Timer() { reset(); } void reset() { start = getCycle(); } inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC * 1000; } private: inline i64 getCycle() { uint32_t low, high; __asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); return ((i64)low) | ((i64)high << 32); } } timer; /* SegmentTree */ template <typename T> struct SegTree { using F = function<T(T, T)>; int n; F f; T ti; vector<T> dat; SegTree(){}; SegTree(F f, T ti) : f(f), ti(ti) {} void init(int n_) { n = 1; while(n < n_) n <<= 1; dat.assign(n << 1, ti); } void build(const vector<T> &v) { int n_ = v.size(); init(n_); for(int i = 0; i < n_; i++) dat[n + i] = v[i]; for(int i = n - 1; i; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); } void update(int k, T x) { dat[k += n] = x; while(k >>= 1) dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]); } T query(int a, int b) { T vl = ti, vr = ti; for(int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) { if(l & 1) vl = f(vl, dat[l++]); if(r & 1) vr = f(dat[--r], vr); } return f(vl, vr); } template <typename C> int find(int st, C &check, T &acc, int k, int l, int r) { if(l + 1 == r) { acc = f(acc, dat[k]); return check(acc) ? k - n : -1; } int m = (l + r) >> 1; if(m <= st) return find(st, check, acc, (k << 1) | 1, m, r); if(st <= l && !check(f(acc, dat[k]))) { acc = f(acc, dat[k]); return -1; } int vl = find(st, check, acc, (k << 1) | 0, l, m); if(~vl) return vl; return find(st, check, acc, (k << 1) | 1, m, r); } template <typename C> int find(int st, C &check) { T acc = ti; return find(st, check, acc, 1, 0, n); } T operator[](const int &k) const { return dat[k + n]; } }; // https://atcoder.jp/contests/cf16-tournament-round3-open/tasks/asaporo_d void asaporo_d() { timer.reset(); int n, m, k; scanf("%d%d%d", &n, &m, &k); std::vector<i64> a(n); rep(i, n) scanf("%ld", &a[i]); a.insert(a.begin(), 0LL); SegTree<i64> seg([](i64 a, i64 b) { return std::max<i64>(a, b); }, -1); seg.build(std::vector<i64>(n + 10, 0)); std::vector<std::vector<i64>> dp( n + 10, std::vector<i64>(k + 10, static_cast<i64>(0))); for(i64 j = 0; j <= k; j++) { if(timer.get() > 1000) assert(0); rep(i, n + 1) seg.update(i, dp[i][j]); for(i64 i = 1; i <= n; i++) { dp[i][j + 1] = (j + 1) * a[i] + seg.query(max(i - m, 0LL), i); } } i64 ret = 0; printf("%ld\n", seg.query(0, n + 1)); } int main() { asaporo_d(); return 0; }
a.cc: In function 'void asaporo_d()': a.cc:103:58: error: no matching function for call to 'max(i64, long long int)' 103 | dp[i][j + 1] = (j + 1) * a[i] + seg.query(max(i - m, 0LL), i); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:103:58: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 103 | dp[i][j + 1] = (j + 1) * a[i] + seg.query(max(i - m, 0LL), i); | ~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:103:58: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 103 | dp[i][j + 1] = (j + 1) * a[i] + seg.query(max(i - m, 0LL), i); | ~~~^~~~~~~~~~~~
s407801189
p03899
C++
#include <bits/stdc++.h> typedef long long i64; using std::cout; using std::endl; using std::cin; struct SegmentTree { std::vector<i64> seg; int sz = 1; #include <bits/stdc++.h> typedef long long i64; using std::cout; using std::endl; using std::cin; struct Slide_Max { std::deque<int> deq; std::vector<i64> v; int k, i; i64 ret; Slide_Max(int k) : k(k) { deq.clear(); v.clear(); ret = 0; i = 0; } i64 push(i64 x) { v.push_back(x); while(!deq.empty() and v[deq.back()] <= v[i]) { deq.pop_back(); } deq.push_back(i); ret = v[deq.front()]; if(deq.front() == i - k + 1) deq.pop_front(); i++; return ret; } i64 get() { return (v.size() ? ret : -1); }; }; int main(){ int n, m, k; cin >> n >> m >> k; std::vector<i64> a(n); for(int i = 0; i < n; i++) cin >> a[i]; Slide_Max sm[k + 1](m); sm[0].push(0); std::vector<std::vector<i64>> dp(n + 1, std::vector<i64>(k + 1, 0)); for(int i = 0; i < n; i++) { for(i64 j = k - 1; j >= 0; j--) { if(sm[j].get() == -1) continue; i64 ma = sm[j].get(); dp[i + 1][j + 1] = ma + a[i] * (j + 1); sm[j + 1].push(dp[i + 1][j + 1]); } } cout << sm[k].get() << endl; return 0; } SegmentTree(int n) { while(sz < n) sz *= 2; seg.assign(sz * 2 - 1, 0); } void update(int k, i64 x) { k += sz - 1; seg[k] = x; while(k) { k = (k - 1) / 2; seg[k] = std::max(seg[2 * k + 1], seg[2 * k + 2]); } } i64 get(int a, int b, int k, int l, int r) { if(r<=a||b<=l) return 0; if(a<=l&&r<=b) return seg[k]; return std::max(get(a, b, 2 * k + 1, l, (l + r) / 2), get(a, b, 2 * k + 2, (l + r) / 2, r)); } i64 get(int a, int b) { return get(a, b, 0, 0, sz); } }; int main(){ int n, m, k; cin >> n >> m >> k; std::vector<i64> a(n); for(int i = 0; i < n; i++) cin >> a[i]; SegmentTree dp[k + 1](n + 1); for(int i = 0; i < n; i++) dp[0].update(i, 1); for(int i = 0; i < n; i++) { for(i64 j = 0; j < k; j++) { i64 tmp = dp[j].get(std::max(0, i - m), i + 1); if(!tmp) continue; dp[j + 1].update(i + 1, tmp + a[i] * (j + 1LL)); } } cout << dp[k].get(0, n + 1) - 1 << endl; return 0; }
a.cc:11:19: warning: declaration of 'typedef long long int SegmentTree::i64' changes meaning of 'i64' [-Wchanges-meaning] 11 | typedef long long i64; | ^~~ a.cc:8:21: note: used here to mean 'typedef long long int i64' 8 | std::vector<i64> seg; | ^~~ a.cc:2:19: note: declared here 2 | typedef long long i64; | ^~~ a.cc:12:12: error: using-declaration for non-member at class scope 12 | using std::cout; | ^~~~ a.cc:13:12: error: using-declaration for non-member at class scope 13 | using std::endl; | ^~~~ a.cc:14:12: error: using-declaration for non-member at class scope 14 | using std::cin; | ^~~ a.cc: In member function 'int SegmentTree::main()': a.cc:50:29: error: array must be initialized with a brace-enclosed initializer 50 | Slide_Max sm[k + 1](m); sm[0].push(0); | ^ a.cc: In function 'int main()': a.cc:98:33: error: array must be initialized with a brace-enclosed initializer 98 | SegmentTree dp[k + 1](n + 1); | ~~^~~
s464750234
p03899
C++
//左のパネルから順番に当てると考えられるので、以下の問題にできる。 //問題概要: //N個のうちK個のパネルを選びます。左のパネルから書かれている数を1,2,3,…,K倍し, 和を取ります。 //その値が最大になるようにパネルを選んでください。ただし、2つのパネルの距離は1以上M以下とします。 // //M = Nのときは、2つのパネルの距離の制約がないと考えてよく、選ぶパネルはスコアが大きいほうからK個にすべきです。 //↑これは嘘です。反例:{1, 1, 30, 5, 5}, K = 3. //{1, 1, 30}を選ぶと30が3倍され、{30,5,5}を選ぶと30が1倍される。←このように、何倍するかが変わってしまうので、 //戦略は非自明です。だから全探索ベースでやります。dp[n][k] := 的1~nのうちk個当てたときの、スコアの最大値 //O(NK) //(100点) #include <iostream> #include <algorithm> #include <vector> #include <functional> #define int long long using namespace std; typedef pair<int, int> P; int INF = 1e-17; int n, m, k; int a[100000]; int dp[100001][301]; int wrong_dp[100001][301]; signed main() { int i, j; cin >> n >> m >> k; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i <= n; i++) for (j = 0; j <= k; j++) dp[i][j] = -INF; dp[0][0] = 0; for (i = 0; i < n; i++) { for (j = 0; j <= k; j++) { if (j > i) continue; dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); if (j < k) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + a[i] * (j + 1)); } } cout << dp[n][k] << endl; //0点だったコードを書きます for (i = 0; i <= n; i++) for (j = 0; j <= k; j++) wrong_dp[i][j] = -INF; wrong_dp[0][0] = 0; for (i = 0; i < n; i++) { for (j = 0; j <= k; j++) { wrong_dp[i + 1][j] = max(wrong_dp[i + 1][j], wrong_dp[i][j]); if (j < k) wrong_dp[i + 1][j + 1] = max(wrong_dp[i + 1][j + 1], wrong_dp[i][j] + a[i] * (j + 1)); } } if (wrong_dp[n][k] > dp[n][k]) assert(0); return 0; }
a.cc: In function 'int main()': a.cc:56:40: error: 'assert' was not declared in this scope 56 | if (wrong_dp[n][k] > dp[n][k]) assert(0); | ^~~~~~ a.cc:17:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 16 | #include <functional> +++ |+#include <cassert> 17 | #define int long long
s800984621
p03899
C++
//左のパネルから順番に当てると考えられるので、以下の問題にできる。 //問題概要: //N個のうちK個のパネルを選びます。左のパネルから書かれている数を1,2,3,…,K倍し, 和を取ります。 //その値が最大になるようにパネルを選んでください。ただし、2つのパネルの距離は1以上M以下とします。 // //M = Nのときは、2つのパネルの距離の制約がないと考えてよく、選ぶパネルはスコアが大きいほうからK個にすべきです。 //↑これは嘘です。反例:{1, 1, 30, 5, 5}, K = 3. //{1, 1, 30}を選ぶと30が3倍され、{30,5,5}を選ぶと30が1倍される。←このように、何倍するかが変わってしまうので、 //戦略は非自明です。だから全探索ベースでやります。dp[n][k] := 的1~nのうちk個当てたときの、スコアの最大値 //O(NK) //(100点) #include <iostream> #include <algorithm> #include <vector> #include <functional> #define int long long using namespace std; typedef pair<int, int> P; int INF = 1e-17; int n, m, k; int a[100000]; int dp[100001][301]; signed main() { int i, j; cin >> n >> m >> k; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i <= n; i++) for (j = 0; j <= k; j++) dp[i][j] = -INF; dp[0][0] = 0; for (i = 0; i < n; i++) { for (j = 0; j <= k; j++) { if (j > i) continue; dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); if (j < k) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + a[i] * (j + 1)); } } cout << dp[n][k] << endl; if (dp[n][k] >= INF) assert(0); return 0; }
a.cc: In function 'int main()': a.cc:43:30: error: 'assert' was not declared in this scope 43 | if (dp[n][k] >= INF) assert(0); | ^~~~~~ a.cc:17:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 16 | #include <functional> +++ |+#include <cassert> 17 | #define int long long
s187019488
p03899
C++
#include <bits/stdc++.h> using namespace std; #define INF_LL (int64)1e18 #define INF (int32)1e9 #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(x) x.begin(),x.end() #define fs first #define sc second using int32 = int_fast32_t; using uint32 = uint_fast32_t; using int64 = int_fast64_t; using uint64 = uint_fast64_t; using PII = pair<int32, int32>; using PLL = pair<int64, int64>; const double eps = 1e-6; template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;} template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;} const int64 mod = 1e9+7; /* int main(void){ int32 N; cin >> N; vector<int64> v(N); REP(i, N) cin >> v[i]; int64 maxi = 0; int64 res = 0; REP(i, N){ int64 cnt = (v[i]-1)/(maxi+1); if(cnt){ res += cnt; chmax(maxi, 1); } else maxi = v[i]; } cout << res << endl; } */ class RMQ{ private: int32 n; vector<int64> node, lazy; vector<bool> lazyFlag; public: RMQ(vector<int64> v){ int sz = v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1, -INF_LL); lazy.resize(2*n-1, 0); lazyFlag.resize(2*n-1, false); for(int32 i = 0;i < sz;i++) node[i+n-1] = v[i]; for(int32 i = n-2;i >= 0;i--) node[i] = max(node[2*i+1], node[2*i+2]); } void eval(int32 k, int32 l, int32 r){ if(lazyFlag[k]){ node[k] = lazy[k]; if(r-l > 1){ lazy[2*k+1] = lazy[k]; lazy[2*k+2] = lazy[k]; lazyFlag[2*k+1] = lazyFlag[2*k+2] = true; } lazy[k] = 0; lazyFlag[k] = false; } } void update(int32 k, int64 x){ k += n-1; if(node[k] > x) return; node[k] = x; while(k){ k = (k-1)/2; node[k] = max(node[k*2+1], node[k*2+2]); } } int64 query(int32 a, int32 b, int32 k=0, int32 l=0, int32 r=-1){ if(r < 0) r = n; // eval(k, l, r); if(b <= l || r <= a) return -INF_LL; if(a <= l && r <= b) return node[k]; return max(query(a, b, k*2+1, l, (l+r)/2), query(a, b, k*2+2, (l+r)/2, r)); } }; int main(void){ int32 M, N, K; cin >> N >> M >> K; vector<int64> A(N); vector<RMQ> rmq(K+1, RMQ(vector<int64>(N+1, 0))); REP(i, N) cin >> A[i]; REP(i, N){ REP(j, K){ rmq[j+1].update(i+1, rmq[j].query(max(0, i-M+1), i+1)+A[i]*(j+1)); } } cout << rmq[K].query(0, N+1) << endl; }
a.cc: In function 'int main()': a.cc:103:62: error: no matching function for call to 'max(int, int32)' 103 | rmq[j+1].update(i+1, rmq[j].query(max(0, i-M+1), i+1)+A[i]*(j+1)); | ~~~^~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:103:62: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'int32' {aka 'long int'}) 103 | rmq[j+1].update(i+1, rmq[j].query(max(0, i-M+1), i+1)+A[i]*(j+1)); | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:103:62: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 103 | rmq[j+1].update(i+1, rmq[j].query(max(0, i-M+1), i+1)+A[i]*(j+1)); | ~~~^~~~~~~~~~
s385895483
p03899
C++
// need #include <iostream> #include <algorithm> // data structure #include <bitset> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #include <complex> //#include <deque> #include <valarray> // stream //#include <istream> //#include <sstream> //#include <ostream> #include <fstream> // etc #include <cassert> #include <cmath> #include <functional> #include <iomanip> #include <chrono> #include <random> #include <numeric> // input #define INIT std::ios::sync_with_stdio(false);std::cin.tie(0); #define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; } template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } #define VEC_ROW(type, n, ...)std::vector<type> __VA_ARGS__;MACRO_VEC_ROW_Init(n, __VA_ARGS__); for(int i=0; i<n; ++i){MACRO_VEC_ROW_Scan(i, __VA_ARGS__);} template<typename T> void MACRO_VEC_ROW_Init(int n, T& t) { t.resize(n); } template<typename First, typename...Rest>void MACRO_VEC_ROW_Init(int n, First& first, Rest&...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); } template<typename T> void MACRO_VEC_ROW_Scan(int p, T& t) { std::cin >> t[p]; } template<typename First, typename...Rest>void MACRO_VEC_ROW_Scan(int p, First& first, Rest&...rest) { std::cin >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); } #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i; #define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i; // output #define OUT(d) std::cout<<(d); #define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<(d); #define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<(d); #define SP std::cout<<" "; #define TAB std::cout<<"\t"; #define BR std::cout<<"\n"; #define SPBR(i, n) std::cout<<(i + 1 == n ? '\n' : ' '); #define ENDL std::cout<<std::endl; #define FLUSH std::cout<<std::flush; #define SHOW(d) {std::cerr << #d << "\t:" << (d) << "\n";} #define SHOWVECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";} #define SHOWVECTOR2(v) {std::cerr << #v << "\t:\n";for(const auto& xxx : v){for(const auto& yyy : xxx){std::cerr << yyy << " ";}std::cerr << "\n";}} #define SHOWQUEUE(a) {auto tmp(a);std::cerr << #a << "\t:";while(!tmp.empty()){std::cerr << tmp.front() << " ";tmp.pop();}std::cerr << "\n";} // utility #define ALL(a) (a).begin(),(a).end() #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i) #define REP(i, n) for(int i=0;i<int(n);++i) #define RREP(i, n) for(int i=int(n)-1;i>=0;--i) #define FORLL(i, a, b) for(ll i=ll(a);i<ll(b);++i) #define RFORLL(i, a, b) for(ll i=ll(b)-1;i>=ll(a);--i) #define REPLL(i, n) for(ll i=0;i<ll(n);++i) #define RREPLL(i, n) for(ll i=ll(n)-1;i>=0;--i) #define IN(a, x, b) (a<=x && x<b) template<typename T> inline T CHMAX(T& a, const T b) { return a = (a < b) ? b : a; } template<typename T> inline T CHMIN(T& a, const T b) { return a = (a > b) ? b : a; } #define EXCEPTION(msg) throw std::string("Exception : " msg " [ in ") + __func__ + " : " + std::to_string(__LINE__) + " lines ]" #define TRY(cond, msg) try {if (cond) EXCEPTION(msg);}catch (std::string s) {std::cerr << s << std::endl;} void CHECKTIME(std::function<void()> f) { auto start = std::chrono::system_clock::now(); f(); auto end = std::chrono::system_clock::now(); auto res = std::chrono::duration_cast<std::chrono::nanoseconds>((end - start)).count(); std::cerr << "[Time:" << res << "ns (" << res / (1.0e9) << "s)]\n"; } // test template<class T> std::vector<std::vector<T>> VV(int n, int m, T init = T()) { return std::vector<std::vector<T>>(n, std::vector<T>(m, init)); } template<typename S, typename T> std::ostream& operator<<(std::ostream& os, std::pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; } // type/const #define int ll using ll = long long; using ull = unsigned long long; using ld = long double; using PAIR = std::pair<int, int>; using PAIRLL = std::pair<ll, ll>; constexpr int INFINT = 1 << 30; // 1.07x10^ 9 constexpr int INFINT_LIM = (1LL << 31) - 1; // 2.15x10^ 9 constexpr ll INFLL = 1LL << 60; // 1.15x10^18 constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62); // 9.22x10^18 constexpr double EPS = 1e-9; constexpr int MOD = 1000000007; constexpr double PI = 3.141592653589793238462643383279; template<class T, size_t N> void FILL(T(&a)[N], const T& val) { for (auto& x : a) x = val; } template<class ARY, size_t N, size_t M, class T> void FILL(ARY(&a)[N][M], const T& val) { for (auto& b : a) FILL(b, val); } template<class T> void FILL(std::vector<T>& a, const T& val) { for (auto& x : a) x = val; } template<class ARY, class T> void FILL(std::vector<std::vector<ARY>>& a, const T& val) { for (auto& b : a) FILL(b, val); } // ------------>8------------------------------------->8------------ // Description: スライド最小値.minを取る区間が広義単調増加のとき使える.全体O(N). // ## Compare: min -> std::less<T>, max -> std::greater<T> template<class T, class Compare> struct SlideMinimum { std::deque<size_t> deq; std::vector<T> a; size_t sz; Compare cmp; signed L, R; SlideMinimum(const std::vector<T>& a) : a(a), sz(a.size), cmp(Compare()), L(0), R(0) {} // ++L inline void incL() { if (deq.front() == L++) deq.pop_front(); } // slide [L, R) to [l, R) inline void slideL(signed l) { assert(L <= l && l <= R); while (L < l) incL(); } // ++R inline void incR() { while (!deq.empty() && !cmp(a[deq.back()], a[R])) deq.pop_back(); deq.push_back(R++); } // slide [L, R) to [L, r) inline void slideR(signed r) { assert(R <= r && r <= (int)sz); while (R < r) incR(); } // slide [L, R) to [l, r) inline void slide(signed l, signed r) { assert(l <= r && r <= (int)sz && L <= l && R <= r); if (R <= l) { deq.clear(); L = R = l; } slideR(r); slideL(l); } // reset deque ( slide [L, R) to [0, 0) ) inline void clear() { deq.clear(); L = R = 0; } inline size_t getIndex() const { assert(deq.size() > 0); return deq.front(); } }; // dp[i][j] = i回投げて最後にj番目に当たったときの最大値 signed main() { INIT; VAR(int, n, m, k); VEC(int, a, n); std::vector<std::vector<int>> dp(k + 1, std::vector<int>(n + 1, 0)); REP(i, n) dp[1][i + 1] = a[i]; FOR(i, 1, k) { SlideMinimum<int, std::greater<>> sm(dp[i]); sm.slide(std::max(0LL, i - m + 1), i); FOR(j, i, n) { sm.slide(std::max(0LL, j - m + 1), j + 1); int t = dp[i][sm.getIndex()]; dp[i + 1][j + 1] = t + (i + 1)*a[j]; } } int ans = 0; REP(i, n + 1) CHMAX(ans, dp[k][i]); OUT(ans)BR; return 0; }
a.cc: In instantiation of 'SlideMinimum<T, Compare>::SlideMinimum(const std::vector<_Tp>&) [with T = long long int; Compare = std::greater<void>]': a.cc:173:45: required from here 173 | SlideMinimum<int, std::greater<>> sm(dp[i]); | ^ a.cc:119:55: error: cannot convert 'std::vector<long long int>::size' from type 'std::vector<long long int>::size_type (std::vector<long long int>::)() const noexcept' {aka 'long unsigned int (std::vector<long long int>::)() const noexcept'} to type 'size_t' {aka 'long unsigned int'} 119 | SlideMinimum(const std::vector<T>& a) : a(a), sz(a.size), cmp(Compare()), L(0), R(0) {} | ^~~~~~~~~~
s131398180
p03899
C++
#include <algorithm> int N, M, K, ptr[100009]; long long dp[309][100009]; int main() { scanf("%d %d %d", &N, &M, &K); for (int i = 0; i < N; i++) scanf("%lld", &dp[0][i]); for (int i = 1; i < K; i++) { int pl = 0, pr = 0; for (int j = 0; j < N; j++) { if (j >= i) dp[i][j] = dp[i - 1][ptr[pl]] + 1LL * (i + 1) * dp[0][j]; if (ptr[pl] == j - M) pl++; while (pl < pr && dp[i - 1][ptr[pr - 1]] < dp[i - 1][j]) pr--; ptr[pr++] = j; } } printf("%lld\n", *std::max_element(dp[K - 1], dp[K - 1] + N)); return 0; }
a.cc: In function 'int main()': a.cc:4:9: error: 'scanf' was not declared in this scope 4 | scanf("%d %d %d", &N, &M, &K); | ^~~~~ a.cc:15:9: error: 'printf' was not declared in this scope 15 | printf("%lld\n", *std::max_element(dp[K - 1], dp[K - 1] + N)); | ^~~~~~ a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' 1 | #include <algorithm> +++ |+#include <cstdio> 2 | int N, M, K, ptr[100009]; long long dp[309][100009];
s088499613
p03899
C++
#include <iostream> #include <fstream> #include <cassert> #include <typeinfo> #include <vector> #include <stack> #include <cmath> #include <set> #include <map> #include <string> #include <algorithm> #include <cstdio> #include <queue> #include <iomanip> #include <cctype> #include <random> #define syosu(x) fixed<<setprecision(x) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> P; typedef pair<double,double> pdd; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<P> vp; typedef vector<vp> vvp; typedef vector<pll> vpll; typedef pair<P,int> pip; typedef vector<pip> vip; const int inf=1<<29; const ll INF=1ll<<60; const double pi=acos(-1); const double eps=1e-8; const ll mod=1e9+7; const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0}; int n,m,k; vl a; vl dp; int main(){ cin>>n>>m>>k; a=dp=vl(n); for(int i=0;i<n;i++) cin>>a[i]; dp=a; for( i=1;i<k;i++){ deque<int> q; vl DP(n); for(int j=0;j<n;j++){ if(j>=i) DP[j]=dp[q.front()]+a[j]*(i+1); while(!q.empty()&&dp[q.back()]<=dp[j]) q.pop_back(); q.push_back(j); if(!q.empty()&&q.front()==j-m) q.pop_front(); } dp=DP; } ll res=-1; for(int i=0;i<n;i++) res=max(res,dp[i]); cout<<res<<endl; }
a.cc: In function 'int main()': a.cc:57:14: error: 'i' was not declared in this scope; did you mean 'vi'? 57 | for( i=1;i<k;i++){ | ^ | vi
s081679007
p03899
C++
#include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <set> #include <iostream> #include <string> #include <vector> #include <algorithm> #include <sstream> #include <complex> #include <stack> #include <queue> #include <cstdio> #include <cstring> #include <iterator> #include <bitset> #include <unordered_set> #include <unordered_map> #include <fstream> #include <iomanip> #include <cassert> //#include <utility> //#include <memory> //#include <functional> //#include <deque> //#include <cctype> //#include <ctime> //#include <numeric> //#include <list> //#include <iomanip> //#if __cplusplus >= 201103L //#include <array> //#include <tuple> //#include <initializer_list> //#include <forward_list> // //#define cauto const auto& //#else //#endif using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vint; typedef vector<vector<int> > vvint; typedef vector<ll> vll, vLL; typedef vector<vector<long long> > vvll, vvLL; #define VV(T) vector<vector< T > > template <class T> void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) { v.assign(a, vector<T>(b, t)); } template <class F, class T> void convert(const F &f, T &t) { stringstream ss; ss << f; ss >> t; } #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define reep(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) reep((i),0,(n)) #define ALL(v) (v).begin(),(v).end() #define PB push_back #define F first #define S second #define mkp make_pair #define RALL(v) (v).rbegin(),(v).rend() #define DEBUG #ifdef DEBUG #define dump(x) cout << #x << " = " << (x) << endl; #define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; #else #define dump(x) #define debug(x) #endif #define MOD 1000000007LL #define EPS 1e-8 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL #define maxs(x,y) x=max(x,y) #define mins(x,y) x=min(x,y) template<class T> class RMQ { public: vector<T> data; vector<vector<int> > block; vector<int> sblock; int N; int lg; // Max -> data[b] > data[a] int argMin(int a, int b) { return data[b] < data[a] ? b : a; } // x の下位 y bit を 0 にする int maskBits(int x, int y) { return (x >> y) << y; } RMQ(vector<T> &v) { data = v; N = data.size(); // lg = 32 - __builtin_clz(N); lg = 32; block.assign((N + lg - 1) / lg, vector<int>(lg, 0)); for(int i = 0; i < N; i++) { if(i % lg == 0) block[i / lg][0] = i; block[i / lg][0] = argMin(block[i / lg][0], i); } for(int j = 1; j < lg; j++) { for(int i = 0; i < block.size(); i++) { block[i][j] = argMin(block[i][j - 1], block[min(i + (1 << (j - 1)), (int)block.size() - 1][j - 1]); } } sblock.assign(N, 0); stack<int> st; for(int i = 0; i < N; i++) { if(i % lg == 0) while(st.size()) st.pop(); while(st.size() && i == argMin(i, st.top())) st.pop(); if(st.size()) { int g = st.top(); sblock[i] = sblock[g] | (1 << (g % lg)); } st.push(i); } } // return = min{data[i] : i in [l .. r]} T query(int l, int r) { if(l == r) return data[l]; int l1 = l / lg + 1; int r1 = r / lg - 1; int ret = l; if(l1 <= r1) { int d = r1 - l1 + 1; if(d <= 2){ ret = argMin(ret, argMin(block[l1][0], block[r1][0])); } else { int lg2 = 32 - __builtin_clz(d) - 1; ret = argMin(ret, argMin(block[l1][lg2], block[r1 - (1 << lg2)+1][lg2])); } } if(l1 - r1 == 2) { // same block int t = maskBits(sblock[r], l % lg); if(t == 0) { ret = argMin(ret, r); } else { ret = argMin(ret, __builtin_ctz(t) + (l1 - 1) * lg); } } else { // other block int t1 = maskBits(sblock[l1 * lg - 1], l % lg); if(t1 == 0) { ret = argMin(ret, l1 * lg - 1); } else { ret = argMin(ret, __builtin_ctz(t1) + (l1 - 1) * lg); } int t2 = sblock[r]; if(t2 == 0) { ret = argMin(ret, r); } else { ret = argMin(ret, __builtin_ctz(t2) + (r1 + 1) * lg); } } return data[ret]; } }; void mainmain() { int n, m, K; cin >> n >> m >> K; // assert(n <= 300 && K <= 30); vll v(n); vll dp(n); rep(i, n) { cin >> v[i]; dp[i] = v[i]; } rep(i, K - 1) { RMQ<ll> rmq(dp); dp = vll(n); reep(j, i + 1, n) { ll t = 0; int a = max(j - m, 0); int b = j - 1; t = rmq.query(a, b); if(t) dp[j] = t + v[j] * (i + 2); } // 3 7 2 6 9 4 8 5 1 1000000000 // if(i==0){ // cout << -rmq.query(1,2) << endl; // } // rep(i,n){ // rep(j,i+1){ // cout<<j<<" "<<i<<" "<<-rmq.query(j,i)<<endl; // } // } // break; // rep(j,n){ // cout << -dp[j] << " "; // } // cout<<endl; } ll ans = 0; rep(i, n) { maxs(ans, dp[i]); } cout << ans << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); mainmain(); }
a.cc: In constructor 'RMQ<T>::RMQ(std::vector<_Tp>&)': a.cc:128:122: error: expected ')' before ']' token 128 | block[i][j] = argMin(block[i][j - 1], block[min(i + (1 << (j - 1)), (int)block.size() - 1][j - 1]); | ^ a.cc:128:80: note: to match this '(' 128 | block[i][j] = argMin(block[i][j - 1], block[min(i + (1 << (j - 1)), (int)block.size() - 1][j - 1]); | ^
s314444695
p03899
C++
#include "bits/stdc++.h" using namespace std; //諸機能 #pragma region MACRO #define putans(x) std::cerr << "[ answer ]: " ; cout << (x) << endl #define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(40) << (double)(x) << endl #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define RREP(i,n,a) for(int i=(int)(n-1); i>= a; i--) #define rep(i,n) REP(i,0,n) #define rrep(i,n) RREP(i,n,0) #define all(a) begin((a)),end((a)) #define mp make_pair #define exist(container, n) ((container).find((n)) != (container).end()) #define equals(a,b) (fabs((a)-(b)) < EPS) #ifdef _DEBUG //ファイルからテストデータを読み込む std::ifstream ifs("data.txt"); #define put ifs >> #else //ジャッジシステムでいい感じにやる #define put cin >> #endif #pragma endregion //デバッグなどの支援 #pragma region CODING_SUPPORT #ifdef _DEBUG #define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; } #define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); } #define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); } #define dbgArray(a,n) {std::cerr << (#a) << "="; rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} #else #define dbg(var0) {} #define dbg2(var0, var1) {} #define dbg3(var0, var1, var2) {} #define dbgArray(a,n) {} #endif #pragma endregion //typedef(書き換える、書き足す可能性ある) #pragma region TYPE_DEF typedef long long ll; typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis; typedef pair<long long, long long> pll; typedef vector<int> vi; #pragma endregion //諸々の定数(書き換える可能性ある) #pragma region CONST_VAL #define PI (2*acos(0.0)) #define EPS (1e-10) #define MOD (ll)(1e9 + 7) #define INF (ll)(2*1e9) #pragma endregion int m, n, k; vector<ll> a; ll dp[100000 + 1][31]; bool filled[100000 + 1][31]; int dfs(int top, int k) { dbg2(top, k); if (filled[top][k])return dp[top][k]; int ret = 0; if (k == 1) { rep(i, top) { ret = max(ret, a[i]); } filled[top][k] = true; return dp[top][k] = ret; } REP(i, max(k-1, top - m), top) { ret = max(ret, k*a[i] + dfs(i, k - 1)); if (top == 10 && k == 5) { dbg(k*a[i]); } } filled[top][k] = true; return dp[top][k] = ret; } int main() { put n >> m >> k; fill(*dp, *dp + 100001 * 30, 0); fill(*filled, *filled + 100001 * 30, 0); rep(i, n) { int ttt; put ttt; a.push_back(ttt); } if (n <= 300 && k <= 30) { cout << dfs(n, k) << endl; } else { cout << "うんちうんち" << endl; } END: return 0; }
a.cc: In function 'int dfs(int, int)': a.cc:66:34: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 66 | ret = max(ret, a[i]); | ~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:66:34: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 66 | ret = max(ret, a[i]); | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:66:34: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 66 | ret = max(ret, a[i]); | ~~~^~~~~~~~~~~ a.cc:72:26: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 72 | ret = max(ret, k*a[i] + dfs(i, k - 1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:72:26: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 72 | ret = max(ret, k*a[i] + dfs(i, k - 1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:72:26: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 72 | ret = max(ret, k*a[i] + dfs(i, k - 1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s111387446
p03899
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<cstdio> #include<sstream> #include<iomanip> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define mp make_pair #define all(in) in.begin(),in.end() #define shosu(x) fixed<<setprecision(x) using namespace std; //kaewasuretyuui typedef long long ll; typedef pair<int,int> pii; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef pair<int,pii> pip; typedef vector<pip>vip; const double PI=acos(-1); const double EPS=1e-8; const ll inf=1e15; typedef ll SegT; const ll defvalue=0; class SegTree{ private: vector<SegT>val; ll n; SegT combine(SegT a,SegT b){return max(a,b);} public: SegTree(ll size){ n=1; while(n<size)n<<=1; val=vector<SegT>(2*n,defvalue); } SegTree(const vector<SegT> &in){ n=1; while(n<in.size())n<<=1; val=vector<SegT>(2*n,defvalue); for(int i=n-1+in.size()-1;i>=0;i--){ if(n-1<=i)val[i]=in[i-(n-1)]; else val[i]=combine(val[i*2+1],val[i*2+2]); } } void update(int i,SegT a){ i+=n-1; val[i]=a; while(i>0){ i=(i-1)/2; val[i]=combine(val[i*2+1],val[i*2+2]); } } SegT query(int a,int b,int k=0,int l=0,int r=-1){//[a,b) if(r==-1)r=n; if(r<=a||b<=l)return defvalue; if(a<=l&&r<=b)return val[k]; else return combine(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r)); } void tmp(){ rep(i,val.size())cout<<" "<<val[i];cout<<endl; } }; int main(){ int n,m,q; cin>>n>>m>>q; if(q>40&&n!=m)return 1; vi in(n); rep(i,n)cin>>in[i]; if(n==m){ vi dp=in; rep(i,q){ ll ma=0; rep(j,n-1){ ma=max(ma,dp[j]); dp[j+1]=ma+(i+2)*in[j+1] } rep(j,i+1)dp[j]=0; } ll out=0; rep(i,n)out=max(out,dp[i]); cout<<out<<endl; return 0; } SegTree st(in); rep(i,q-1){ for(int j=n-1;j>=0;j--){ if(j<i+1)st.update(j,0); else st.update(j,(i+2)*in[j]+st.query(max(0,j-m),j)); } } cout<<st.query(0,n)<<endl; }
a.cc: In function 'int main()': a.cc:88:57: error: expected ';' before '}' token 88 | dp[j+1]=ma+(i+2)*in[j+1] | ^ | ; 89 | } | ~
s988394690
p03899
C++
#include "bits/stdc++.h" using namespace std; //諸機能 #pragma region MACRO #define putans(x) std::cerr << "[ answer ]: " ; cout << (x) << endl #define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(40) << (double)(x) << endl #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define RREP(i,n,a) for(int i=(int)(n-1); i>= a; i--) #define rep(i,n) REP(i,0,n) #define rrep(i,n) RREP(i,n,0) #define all(a) begin((a)),end((a)) #define mp make_pair #define exist(container, n) ((container).find((n)) != (container).end()) #define equals(a,b) (fabs((a)-(b)) < EPS) #ifdef _DEBUG //ファイルからテストデータを読み込む std::ifstream ifs("data.txt"); #define put ifs >> #else //ジャッジシステムでいい感じにやる #define put cin >> #endif #pragma endregion //デバッグなどの支援 #pragma region CODING_SUPPORT #ifdef _DEBUG #define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; } #define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); } #define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); } #define dbgArray(a,n) {std::cerr << (#a) << "="; rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} #else #define dbg(var0) {} #define dbg2(var0, var1) {} #define dbg3(var0, var1, var2) {} #define dbgArray(a,n) {} #endif #pragma endregion //typedef(書き換える、書き足す可能性ある) #pragma region TYPE_DEF typedef long long ll; typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis; typedef pair<long long, long long> pll; typedef vector<int> vi; #pragma endregion //諸々の定数(書き換える可能性ある) #pragma region CONST_VAL #define PI (2*acos(0.0)) #define EPS (1e-10) #define MOD (ll)(1e9 + 7) #define INF (ll)(2*1e9) #pragma endregion int m, n, k; evtor<ll> a; ll dp[100000 + 1][31]; bool filled[100000 + 1][31]; int dfs(int top, int k) { dbg2(top, k); if (filled[top][k])return dp[top][k]; int ret = 0; if (k == 1) { rep(i, top) { ret = max(ret, a[i]); } filled[top][k] = true; return dp[top][k] = ret; } REP(i, max(k-1, top - m), top) { ret = max(ret, k*a[i] + dfs(i, k - 1)); if (top == 10 && k == 5) { dbg(k*a[i]); } } filled[top][k] = true; return dp[top][k] = ret; } int main() { put n >> m >> k; fill(*dp, *dp + 100001 * 30, 0); fill(*filled, *filled + 100001 * 30, 0); rep(i, n) { int ttt; put ttt; a.push_back(ttt); } if (n <= 300 && k <= 30) { cout << dfs(n, k) << endl; } else { cout << "うんちうんち" << endl; } END: return 0; }
a.cc:53:1: error: 'evtor' does not name a type 53 | evtor<ll> a; | ^~~~~ a.cc: In function 'int dfs(int, int)': a.cc:66:40: error: 'a' was not declared in this scope 66 | ret = max(ret, a[i]); | ^ a.cc:72:34: error: 'a' was not declared in this scope 72 | ret = max(ret, k*a[i] + dfs(i, k - 1)); | ^ a.cc: In function 'int main()': a.cc:89:17: error: 'a' was not declared in this scope 89 | a.push_back(ttt); | ^
s031585018
p03899
C
#include<stdio.h> long long MAX(long long a,long long b){return a<b?b:a;} long long d[310][100010]={}; int main(){ long long n,m,k,a[100010],i,j; scanf("%lld %lld %lld",&n,&m,&k); for(i=0;i<n;i++)scanf("%lld",&a[i]); for(i=0;i<k;i++){ for(j=i;j<n;j++)d[i+1][j+1]=MAX(d[i+1][j],d[i][j]+(i+1)*a[j]); } //for(i=0;i<=k;i++){ for(j=0;j<=n;j++)printf("%lld ",d[i][j]);printf("\n"); }//*/ printf("%lld\n",d[k][n]); return 0; }
main.c:14:10: error: expected declaration specifiers or '...' before string constant 14 | printf("%lld\n",d[k][n]); | ^~~~~~~~ main.c:14:19: error: expected declaration specifiers or '...' before 'd' 14 | printf("%lld\n",d[k][n]); | ^ main.c:15:3: error: expected identifier or '(' before 'return' 15 | return 0; | ^~~~~~ main.c:16:1: error: expected identifier or '(' before '}' token 16 | } | ^
s469660531
p03899
C++
#include <cstdio> #include <cstring> #include <string> #include <cmath> #include <cassert> #include <iostream> #include <algorithm> #include <stack> #include <queue> #include <vector> #include <set> #include <map> #include <bitset> #include <functional> using namespace std; #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define mp(a,b) make_pair((a),(b)) #define pb(a) push_back((a)) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<((x))<<endl #define fi first #define se second #define INF 2147483600 long dp[2][301]; long dp2[2][301]; int main(){ int n,m,k; cin>>n>>m>>k; vector<long> vec(n); rep(i,n) scanf("%ld", &(vec[i])); long * prev = dp[0]; long * crnt = dp[1]; // long * prei = dp2[0]; // long * crni = dp2[1]; rep(i,n){ fill(crnt, crnt+301, 0); fill(crni, crni+301, INF); crnt[1] = max(prev[1], vec[i]); repl(j,1,min(i+1,k+1)){ // vec[i]までみてk個つかう crnt[j] = max(prev[j], prev[j-1]+j*vec[i]); } // rep(i,k+1) cout<<crnt[i]<<" "; cout<<endl; swap(crnt, prev); } cout << prev[k] << endl; return 0; }
a.cc: In function 'int main()': a.cc:44:10: error: 'crni' was not declared in this scope; did you mean 'crnt'? 44 | fill(crni, crni+301, INF); | ^~~~ | crnt
s157326531
p03899
C++
#include <iostream> #include <queue> using namespace std; const int N = (int) 1e5; long long f[N], g[N + 1]; int a[N]; int main() { ios::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; for (int i = 0; i < n; ++i) cin >> a[i]; for (int t = k; t >= 1; --t) { for (int i = 0; i < n; ++i) g[i] = f[i]; deque<int> q; q.push_back(n); if (t != k) g[n] = -1e18; for (int i = n - 1; i >= 0; --i) { while (!q.empty() && q.front() - i > m) q.pop_front(); f[i] = g[q.front()] + 1LL * t * a[i]; while (!q.empty() && g[i] >= g[q.back()]) q.pop_back(); q.push_back(i); } } cout << *max_element(f, f + n) << endl; return 0; }
a.cc: In function 'int main()': a.cc:25:14: error: 'max_element' was not declared in this scope 25 | cout << *max_element(f, f + n) << endl; | ^~~~~~~~~~~
s344619764
p03899
C
#include<stdio.h> long long MAX(long long a,long long b){return a<b?b:a;} long long d[310][100010]={}; int main(){ long long n,m,k,a[100010],i,j; scanf("%lld %lld %lld",&n,&m,&k); for(i=0;i<n;i++)scanf("%lld",&a[i]); for(i=0;i<k;i++){ for(j=0;j<n;j++){ d[i+1][j+1]=MAX(d[i+1][j+1],d[i+1][j]); d[i+1][j+1]=MAX(d[i+1][j+1],d[i][j]+(i+1)*a[j]);//,d[i+1][j]+(i+1)*(a[j+1]-a[j])); } } //for(i=0;i<=k;i++){ for(j=0;j<=n;j++)printf("%2lld ",d[i][j]);printf("\n"); }//*/ printf("%lld\n",d[k][n]); return 0; }
main.c:17:10: error: expected declaration specifiers or '...' before string constant 17 | printf("%lld\n",d[k][n]); | ^~~~~~~~ main.c:17:19: error: expected declaration specifiers or '...' before 'd' 17 | printf("%lld\n",d[k][n]); | ^ main.c:18:3: error: expected identifier or '(' before 'return' 18 | return 0; | ^~~~~~ main.c:19:1: error: expected identifier or '(' before '}' token 19 | } | ^
s603714102
p03899
C++
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <vector> #include <map> #include <set> #include <string> #include <cstdlib> #include <ctime> #include <deque> using namespace std; int n, m, k; int a[1100000]; long long dp[1100000][310]; int q[1100000], h[1100000], xx[1100000][310]; int main() { scanf("%d%d%d", &n, &m, &k); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= k; i++) dp[0][i] = -1e18; for (int i = 0; i <= k; i++) q[i] = h[i] = 1, xx[i][1] = i; for (int i = 1; i <= n; i++) { for (int j = 0; j <= k; j++) { while (q[j] <= h[j] && xx[j][q[j]] < i - m) q[j] += 1; dp[i][j + 1] = dp[xx[j][q[j]]][j] + 1LL * (j + 1) * a[i]; } for (int j = 0; j <= k; j++) { while (q[j] <= h[j] && dp[xx[j][h[j]]][j] <= dp[i][j]) h[j] -= 1; xx[j][++h[j]] = i; // q[j] += 1; } } long long ans = -1e18; for (int i = 1; i <= n; i++) ans = max(ans, dp[i][k]); cout << ans << endl; }
/tmp/ccapwz16.o: in function `main': a.cc:(.text+0xd3): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/ccapwz16.o a.cc:(.text+0xee): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/ccapwz16.o a.cc:(.text+0x106): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccapwz16.o a.cc:(.text+0x11c): relocation truncated to fit: R_X86_64_PC32 against symbol `xx' defined in .bss section in /tmp/ccapwz16.o a.cc:(.text+0x15d): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccapwz16.o a.cc:(.text+0x177): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccapwz16.o a.cc:(.text+0x18e): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccapwz16.o a.cc:(.text+0x1a5): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/ccapwz16.o a.cc:(.text+0x1c0): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccapwz16.o a.cc:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against symbol `xx' defined in .bss section in /tmp/ccapwz16.o a.cc:(.text+0x20e): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s622698928
p03900
C++
import std.stdio, std.conv, std.string, std.container, std.typecons, std.algorithm; alias Tuple!(int,int) dat; int AlgoA(int N, int [] A, string S) { int cnt = 0; foreach(i;S) { if(i == 'M') cnt++; } BinaryHeap!(Array!dat) hq; foreach(i;0..cnt) { hq.insert(dat(A[i],i)); } int res = 100_000; foreach(i;cnt..N) { hq.insert(dat(A[i],i)); dat t; while(hq.front()[1] < i-cnt) hq.removeFront(); res = min(res, hq.front()[0]); } return res; } int AlgoB(int N, int [] A, string S) { dat [] tmp; foreach(i;0..N) { tmp ~= dat(A[i],i); } auto hq = heapify(tmp); while(hq.length()) { dat t = hq.front(); if( (t[1]!=0 && A[t[1]-1] > t[0]) && (t[1] != N-1 && A[t[1]+1] > t[0]) ) { A[t[1]] = min(A[t[1]-1], A[t[1]+1]); } hq.removeFront(); } if(N % 2 == 1) { return A[N/2]; } else { return max(A[N/2],A[N/2-1]); } } void main() { int N = to!int(readln().chomp()); int [] A; A = readln().chomp().split().to!(int[]); auto hq = heapify(A); string S = readln().chomp(); int cnt = 0; foreach(i;1..(N-1)) { if(S[i] != S[i-1]) cnt++; } if(cnt == 1 && S[0]=='M') { writeln(AlgoA(N,A,S)); } else if(cnt == N-2 && S[0]=='M') { writeln(AlgoB(N,A,S)); } else { writeln("not implemented"); } }
a.cc:11:19: error: too many decimal points in number 11 | foreach(i;0..cnt) { | ^~~~~~ a.cc:26:19: error: too many decimal points in number 26 | foreach(i;0..N) { | ^~~~ a.cc:52:19: error: too many decimal points in number 52 | foreach(i;1..(N-1)) { | ^~~ a.cc:1:1: error: 'import' does not name a type 1 | import std.stdio, std.conv, std.string, std.container, std.typecons, std.algorithm; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'alias' does not name a type 3 | alias Tuple!(int,int) dat; | ^~~~~ a.cc:5:25: error: expected ',' or '...' before 'A' 5 | int AlgoA(int N, int [] A, string S) { | ^ a.cc: In function 'int AlgoA(int, int*)': a.cc:7:17: error: 'i' was not declared in this scope 7 | foreach(i;S) { | ^ a.cc:7:19: error: 'S' was not declared in this scope 7 | foreach(i;S) { | ^ a.cc:10:9: error: 'BinaryHeap' was not declared in this scope 10 | BinaryHeap!(Array!dat) hq; | ^~~~~~~~~~ a.cc:11:18: error: expected ')' before ';' token 11 | foreach(i;0..cnt) { | ~ ^ | ) a.cc:14:19: error: unable to find numeric literal operator 'operator""_000' 14 | int res = 100_000; | ^~~~~~~ a.cc:15:18: error: expected ')' before ';' token 15 | foreach(i;cnt..N) { | ~ ^ | ) a.cc:15:23: error: expected unqualified-id before '.' token 15 | foreach(i;cnt..N) { | ^ a.cc: At global scope: a.cc:24:25: error: expected ',' or '...' before 'A' 24 | int AlgoB(int N, int [] A, string S) { | ^ a.cc: In function 'int AlgoB(int, int*)': a.cc:25:9: error: 'dat' was not declared in this scope 25 | dat [] tmp; | ^~~ a.cc:25:14: error: expected primary-expression before ']' token 25 | dat [] tmp; | ^ a.cc:26:17: error: 'i' was not declared in this scope 26 | foreach(i;0..N) { | ^ a.cc:29:27: error: 'tmp' was not declared in this scope 29 | auto hq = heapify(tmp); | ^~~ a.cc:29:19: error: 'heapify' was not declared in this scope 29 | auto hq = heapify(tmp); | ^~~~~~~ a.cc:31:20: error: expected ';' before 't' 31 | dat t = hq.front(); | ^~ | ; a.cc:32:22: error: 't' was not declared in this scope 32 | if( (t[1]!=0 && A[t[1]-1] > t[0]) && (t[1] != N-1 && A[t[1]+1] > t[0]) ) { | ^ a.cc:32:33: error: 'A' was not declared in this scope 32 | if( (t[1]!=0 && A[t[1]-1] > t[0]) && (t[1] != N-1 && A[t[1]+1] > t[0]) ) { | ^ a.cc:33:35: error: 'min' was not declared in this scope 33 | A[t[1]] = min(A[t[1]-1], A[t[1]+1]); | ^~~ a.cc:38:24: error: 'A' was not declared in this scope 38 | return A[N/2]; | ^ a.cc:41:28: error: 'A' was not declared in this scope 41 | return max(A[N/2],A[N/2-1]); | ^ a.cc:41:24: error: 'max' was not declared in this scope 41 | return max(A[N/2],A[N/2-1]); | ^~~ a.cc: At global scope: a.cc:45:1: error: '::main' must return 'int' 45 | void main() { | ^~~~ a.cc: In function 'int main()': a.cc:46:17: error: 'to' was not declared in this scope 46 | int N = to!int(readln().chomp()); | ^~ a.cc:47:13: error: structured binding declaration cannot have type 'int' 47 | int [] A; | ^~ a.cc:47:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:47:13: error: empty structured binding declaration a.cc:47:16: error: expected initializer before 'A' 47 | int [] A; | ^ a.cc:48:9: error: 'A' was not declared in this scope 48 | A = readln().chomp().split().to!(int[]); | ^ a.cc:48:13: error: 'readln' was not declared in this scope 48 | A = readln().chomp().split().to!(int[]); | ^~~~~~ a.cc:49:19: error: 'heapify' was not declared in this scope 49 | auto hq = heapify(A); | ^~~~~~~ a.cc:50:9: error: 'string' was not declared in this scope 50 | string S = readln().chomp(); | ^~~~~~ a.cc:52:17: error: 'i' was not declared in this scope 52 | foreach(i;1..(N-1)) { | ^ a.cc:55:24: error: 'S' was not declared in this scope 55 | if(cnt == 1 && S[0]=='M') { | ^ a.cc:56:17: error: 'writeln' was not declared in this scope 56 | writeln(AlgoA(N,A,S)); | ^~~~~~~ a.cc:59:17: error: 'writeln' was not declared in this scope 59 | writeln(AlgoB(N,A,S)); | ^~~~~~~ a.cc:62:17: error: 'writeln' was not declared in this scope 62 | writeln("not implemented"); | ^~~~~~~
s507830192
p03900
C++
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <utility> int main(){ int n; std::cin >> n; std::vector<int> a; std::vector<int> na(n - i - 1); a.resize(n); for(int i = 0; i < n; ++i){ std::cin >> a[i]; } std::string str; std::cin >> str; for(int i = 0; i < n - 1; ++i){ if(str[i] == 'M'){ for(int j = 0; j < n - i - 1; ++j){ na[j] = (std::max)(a[j], a[j + 1]); } }else if(str[i] == 'm'){ for(int j = 0; j < n - i - 1; ++j){ na[j] = (std::min)(a[j], a[j + 1]); } } for(int j = 0; j < n - i - 1; ++j){ a[j] = na[j]; } a = na; } std::cout << a[0] << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:11:29: error: 'i' was not declared in this scope 11 | std::vector<int> na(n - i - 1); | ^
s535962342
p03900
C++
#include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<queue> #include<map> #include<algorithm> #include<complex> #include<string> #include<cstring> using namespace std; #define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++) #define rep(x,to) rep2(x,0,to) #define INF 1000000 #define INF_MAX 1000000000 #define debug(x) cout<<#x<<": "<<x<<endl #define all(x) x.begin(),x.end() typedef pair<int,int> P; typedef pair<int,P> PP; const int MAX_N=200006; int n,dat[2*MAX_N-1]; void init(int n_) { n=1; while(n<n_)n*=2; rep(i,2*n-1)dat[i]=INT_MAX; } void update(int k,int a) { int kk=k+n-1; dat[kk]=a; while(kk) { kk=(kk-1)/2; dat[kk]=min(dat[kk*2+1],dat[kk*2+2]); } } int query(int a,int b,int k,int l,int r) { if(r<=a||b<=l)return INT_MAX; if(a<=l&&r<=b)return dat[k]; else { int vl=query(a,b,k*2+1,l,(l+r)/2); int vr=query(a,b,k*2+2,(l+r)/2,r); return min(vl,vr); } } int hai[200000]; int input; int N; int main() { cin>>N; init(N); rep(i,N) { cin>>input; update(i,-1*input); } //rep(i,2*N)cout<<dat[i]<<endl; int p; string s; cin>>s; int ss=s.size(); rep(i,ss-1) { if(s[i]=='M'&&s[i+1]=='m') { p=i+1; p++; break; } } rep(i,N-p+1) { hai[i]=query(i,i+p,0,0,n); //cout<<hai[i]<<endl; } init(N-p+1); rep(i,N-p+1) { update(i,hai[i]*(-1)); } cout<<query(0,N-p+1,0,0,n)<<endl; return 0; }
a.cc: In function 'void init(int)': a.cc:26:28: error: 'INT_MAX' was not declared in this scope 26 | rep(i,2*n-1)dat[i]=INT_MAX; | ^~~~~~~ a.cc:11:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 10 | #include<cstring> +++ |+#include <climits> 11 | using namespace std; a.cc: In function 'int query(int, int, int, int, int)': a.cc:40:30: error: 'INT_MAX' was not declared in this scope 40 | if(r<=a||b<=l)return INT_MAX; | ^~~~~~~ a.cc:40:30: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s127538239
p03900
C++
#include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<queue> #include<map> #include<algorithm> #include<complex> #include<string> #include<cstring> using namespace std; #define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++) #define rep(x,to) rep2(x,0,to) #define INF 1000000 #define debug(x) cout<<#x<<": "<<x<<endl #define all(x) x.begin(),x.end() typedef pair<int,int> P; typedef pair<int,P> PP; const int MAX_N=200006; int n,dat[2*MAX_N-1]; void init(int n_) { n=1; while(n<n_)n*=2; rep(i,2*n-1)dat[i]=INT_MAX; } void update(int k,int a) { int kk=k+n-1; dat[kk]=a; while(kk) { kk=(kk-1)/2; dat[kk]=min(dat[kk*2+1],dat[kk*2+2]); } } int query(int a,int b,int k,int l,int r) { if(r<=a||b<=l)return INT_MAX; if(a<=l&&r<=b)return dat[k]; else { int vl=query(a,b,k*2+1,l,(l+r)/2); int vr=query(a,b,k*2+2,(l+r)/2,r); return min(vl,vr); } } int hai[200000]; int input; int N; int main() { cin>>N; init(N); rep(i,N) { cin>>input; update(i,-1*input); } //rep(i,2*N)cout<<dat[i]<<endl; int p; string s; cin>>s; int ss=s.size(); rep(i,ss-1) { if(s[i]=='M'&&s[i+1]=='m') { p=i+1; p++; break; } } rep(i,N-p+1) { hai[i]=query(i,i+p,0,0,n); //cout<<hai[i]<<endl; } init(N-p+1); rep(i,N-p+1) { update(i,hai[i]*(-1)); } cout<<query(0,N-p+1,0,0,n)<<endl; return 0; }
a.cc: In function 'void init(int)': a.cc:25:28: error: 'INT_MAX' was not declared in this scope 25 | rep(i,2*n-1)dat[i]=INT_MAX; | ^~~~~~~ a.cc:11:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 10 | #include<cstring> +++ |+#include <climits> 11 | using namespace std; a.cc: In function 'int query(int, int, int, int, int)': a.cc:39:30: error: 'INT_MAX' was not declared in this scope 39 | if(r<=a||b<=l)return INT_MAX; | ^~~~~~~ a.cc:39:30: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s062882361
p03900
Java
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.*; public class Main2 { private static final int mod = (int)1e9+7; final Random random = new Random(0); final IOFast io = new IOFast(); /// MAIN CODE public void run() throws IOException { // int TEST_CASE = Integer.parseInt(new String(io.nextLine()).trim()); int TEST_CASE = 1; while(TEST_CASE-- != 0) { int n = io.nextInt(); int[] A = io.nextIntArray(n); char[] S = io.next(); int len = 0; for (int i = 0; i + 1 < S.length; i++) if (S[i] == 'M' && S[i+1] == 'm') len = i + 1; for (int i = 0; i < A.length; i++) { A[i] = -A[i]; } SlideMinimum m = new SlideMinimum(A, len + 1); for (int i = 0; i + len <= A.length; i++) { A[i] = -m.min(i); } int len2 = A.length - len; A = Arrays.copyOf(A, len2); m = new SlideMinimum(A, S.length - len + 1); // dump(A, S.length - len); for (int i = 0; i + S.length - len <= len2; i++) { A[i] = m.min(i); } // dump(A, S.length - len); len2 -= S.length - len; io.out.println(A[0]); } } static public class SlideMinimum { int[] b; public SlideMinimum(int[] a, int m) { final int n = a.length; b = new int[n]; int s, t; s = t = 0; int[] deq = new int[n]; for(int i = 0; i < n; i++) { while(s < t && a[deq[t-1]] >= a[i]) t--; deq[t++] = i; if(i - m + 1 >= 0) { b[i-m+1] = a[deq[s]]; if(deq[s] == i - m + 1) { s++; } } } } // min [idx..idx+m) public int min(int idx) { return b[idx]; } } /// TEMPLATE static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r); } static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r); } static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t; } static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t; } void printArrayLn(int[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); } void printArrayLn(long[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); } static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); } void main() throws IOException { // IOFast.setFileIO("rle-size.in", "rle-size.out"); try { run(); } catch (EndOfFileRuntimeException e) { } io.out.flush(); } public static void main(String[] args) throws IOException { new Main2().main(); } static class EndOfFileRuntimeException extends RuntimeException { private static final long serialVersionUID = -8565341110209207657L; } static public class IOFast { private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private PrintWriter out = new PrintWriter(System.out); void setFileIn(String ins) throws IOException { in.close(); in = new BufferedReader(new FileReader(ins)); } void setFileOut(String outs) throws IOException { out.flush(); out.close(); out = new PrintWriter(new FileWriter(outs)); } void setFileIO(String ins, String outs) throws IOException { setFileIn(ins); setFileOut(outs); } private static int pos, readLen; private static final char[] buffer = new char[1024 * 8]; private static char[] str = new char[500*8*2]; private static boolean[] isDigit = new boolean[256]; private static boolean[] isSpace = new boolean[256]; private static boolean[] isLineSep = new boolean[256]; static { for(int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; } public int read() throws IOException { if(pos >= readLen) { pos = 0; readLen = in.read(buffer); if(readLen <= 0) { throw new EndOfFileRuntimeException(); } } return buffer[pos++]; } public int nextInt() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; } public long nextLong() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; long ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; } public char nextChar() throws IOException { while(true) { final int c = read(); if(!isSpace[c]) { return (char)c; } } } int reads(int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } if(str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } int reads(char[] cs, int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } cs[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } public char[] nextLine() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isLineSep); try { if(str[len-1] == '\r') { len--; read(); } } catch(EndOfFileRuntimeException e) { ; } return Arrays.copyOf(str, len); } public String nextString() throws IOException { return new String(next()); } public char[] next() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); return Arrays.copyOf(str, len); } // public int next(char[] cs) throws IOException { int len = 0; cs[len++] = nextChar(); len = reads(cs, len, isSpace); return len; } public double nextDouble() throws IOException { return Double.parseDouble(nextString()); } public long[] nextLongArray(final int n) throws IOException { final long[] res = new long[n]; for(int i = 0; i < n; i++) { res[i] = nextLong(); } return res; } public int[] nextIntArray(final int n) throws IOException { final int[] res = new int[n]; for(int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } public int[][] nextIntArray2D(final int n, final int k) throws IOException { final int[][] res = new int[n][]; for(int i = 0; i < n; i++) { res[i] = nextIntArray(k); } return res; } public int[][] nextIntArray2DWithIndex(final int n, final int k) throws IOException { final int[][] res = new int[n][k+1]; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { res[i][j] = nextInt(); } res[i][k] = i; } return res; } public double[] nextDoubleArray(final int n) throws IOException { final double[] res = new double[n]; for(int i = 0; i < n; i++) { res[i] = nextDouble(); } return res; } } }
Main.java:8: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ 1 error
s280769747
p03900
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> PII; #define fi first #define se second #define mp make_pair #define pb push_back #define N 100010 int n, a[N]; deque<int> q; int m = 0; int S = 1e9; string s; bool cc() { for (int i = 0; i < n-1; i ++) if ((s[i] == 'M') != (i%2 == 0)) return false; return true; } void ff() { for (int i = 1; i < n-1; i ++) { if (a[i] < a[i-1] && a[i] < a[i+1]) a[i] = min(a[i-1], a[i+1]); } if (n%2 == 0) return max(a[n/2-1], a[n/2]); else return a[n/2]; } int main () { cin >> n; for (int i = 0; i < n; i ++) cin >> a[i]; cin >> s; if (cc()) { cout << ff() << endl; return 0; } while (m < n-1 && s[m] == 'M') m++; for (int i = 0; i < n; i ++) { while (!q.empty() && i-q.front() > m) q.pop_front(); while (!q.empty() && a[q.back()] < a[i]) q.pop_back(); q.push_back(i); if (i >= m) S = min(S, a[q.front()]); } cout << S << endl; return 0; }
a.cc: In function 'void ff()': a.cc:29:33: error: return-statement with a value, in function returning 'void' [-fpermissive] 29 | if (n%2 == 0) return max(a[n/2-1], a[n/2]); else return a[n/2]; | ~~~^~~~~~~~~~~~~~~~~~ a.cc:29:70: error: return-statement with a value, in function returning 'void' [-fpermissive] 29 | if (n%2 == 0) return max(a[n/2-1], a[n/2]); else return a[n/2]; | ~~~~~^ a.cc: In function 'int main()': a.cc:37:22: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'void') 37 | cout << ff() << endl; return 0; | ~~~~ ^~ ~~~~ | | | | | void | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'void' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'void' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'void' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'void' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'void' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'void' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'void' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'void' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'void' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'void' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'void' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'void' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'void' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'void' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'void' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'void' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullp
s284262813
p03900
C++
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <vector> #include <map> #include <set> #include <string> #include <cstdlib> #include <ctime> #include <deque> using namespace std; int n, a[110000]; char S[110000]; bitset<110000> B; bool ok(int x) { for (int i = 0; i < 110000; i++) B.set(i, 0); for (int i = 1; i <= n; i++) if (a[i] < x) B.set(i, 0); else B.set(i, 1); int m = strlen(S); // cout << B.to_string() << ' ' <<(B >> 1).to_string() << endl; for (int i = 0; i < m; i++) { if (S[i] == 'M') B |= (B >> 1); else B &= (B >> 1); B.set(n - i, 0); if (B.count() == 0) return false; // cout << B << endl; } // printf("%d\n", x); // cout << B.to_string() << endl; // cout << B[1] << endl; return B[1] == 1; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); scanf("%s", S); int q = 1, h = n + 1; while (q < h - 1) { int mid = (q + h) / 2; if (ok(mid)) q = mid; else h = mid; } printf("%d\n", q); }
a.cc:17:1: error: 'bitset' does not name a type 17 | bitset<110000> B; | ^~~~~~ a.cc: In function 'bool ok(int)': a.cc:21:17: error: 'B' was not declared in this scope 21 | B.set(i, 0); | ^ a.cc:24:25: error: 'B' was not declared in this scope 24 | B.set(i, 0); | ^ a.cc:26:25: error: 'B' was not declared in this scope 26 | B.set(i, 1); | ^ a.cc:31:25: error: 'B' was not declared in this scope 31 | B |= (B >> 1); | ^ a.cc:33:25: error: 'B' was not declared in this scope 33 | B &= (B >> 1); | ^ a.cc:34:17: error: 'B' was not declared in this scope 34 | B.set(n - i, 0); | ^ a.cc:42:16: error: 'B' was not declared in this scope 42 | return B[1] == 1; | ^
s077567090
p03900
C++
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <vector> #include <map> #include <set> #include <string> #include <cstdlib> #include <ctime> #include <deque> using namespace std; int n, a[110000]; char S[110000]; bitset<110000> B; bool ok(int x) { for (int i = 0; i < 110000; i++) B.set(i, 0); for (int i = 1; i <= n; i++) if (a[i] < x) B.set(i, 0); else B.set(i, 1); int m = strlen(S); // cout << B.to_string() << ' ' <<(B >> 1).to_string() << endl; for (int i = 0; i < m; i++) { if (S[i] == 'M') B |= (B >> 1); else B &= (B >> 1); // cout << B << endl; } // printf("%d\n", x); // cout << B.to_string() << endl; // cout << B[1] << endl; return B[1] == 1; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); scanf("%s", S); int q = 1, h = n + 1; while (q < h - 1) { int mid = (q + h) / 2; if (ok(mid)) q = mid; else h = mid; } printf("%d\n", q); }
a.cc:17:1: error: 'bitset' does not name a type 17 | bitset<110000> B; | ^~~~~~ a.cc: In function 'bool ok(int)': a.cc:21:17: error: 'B' was not declared in this scope 21 | B.set(i, 0); | ^ a.cc:24:25: error: 'B' was not declared in this scope 24 | B.set(i, 0); | ^ a.cc:26:25: error: 'B' was not declared in this scope 26 | B.set(i, 1); | ^ a.cc:31:25: error: 'B' was not declared in this scope 31 | B |= (B >> 1); | ^ a.cc:33:25: error: 'B' was not declared in this scope 33 | B &= (B >> 1); | ^ a.cc:39:16: error: 'B' was not declared in this scope 39 | return B[1] == 1; | ^
s446946902
p03900
C++
//sperse table const int SPT_MAX = 123456; const int SPT_lg = 20; template <class T> class SPT{ T x[SPT_MAX + 1][SPT_lg]; int lg[SPT_MAX + 1]; T eval(T a , T b){ return //*評価; } public: SPT(){ } SPT(int n , T a[]){ lg[1] = 0; for(int i = 2 ; i <= SPT_MAX ; ++i) lg[i] = lg[i / 2] + 1; for(int i = 0 ; i < n ; ++i) x[i][0] = a[i]; for(int j = 0 ; j < SPT_lg - 1 ; ++j){ for(int i = 0 ; i < n - (1 << j) ; ++i){ x[i][j + 1] = eval(x[i][j] , x[i + (1 << j)][j]); } } } T get(int s , int f){ //区間[s,f-1] int z = f - s; return eval(x[s][lg[z]] , x[f - (1 << lg[z])][lg[z]]); } }
a.cc:34:2: error: expected ';' after class definition 34 | } | ^ | ; a.cc: In member function 'T SPT<T>::eval(T, T)': a.cc:11:9: error: expected primary-expression before '}' token 11 | } | ^ a.cc:11:9: error: expected ';' before '}' token
s289658218
p03901
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); ll x; cin>>x; double p; cin>>p; if(p==100){ x++ cout << x/2 << endl; return 0; } p/=100.0; if(x%2==0){ cout << x/2.0/p << "\n"; } else{ x++; cout << x/2.0/p + 1 << "\n"; } }
a.cc: In function 'int main()': a.cc:17:10: error: expected ';' before 'cout' 17 | x++ | ^ | ; 18 | cout << x/2 << endl; | ~~~~
s424636013
p03901
C++
#include <stdio.h> int main(void) { int a, b; scanf("%d%d", &x, &p); printf("%.12f", (double)((x + 1) / 2) * 100.0 / (double)p); return 0; }
a.cc: In function 'int main()': a.cc:5:18: error: 'x' was not declared in this scope 5 | scanf("%d%d", &x, &p); | ^ a.cc:5:22: error: 'p' was not declared in this scope 5 | scanf("%d%d", &x, &p); | ^
s615200794
p03901
C++
#include <bits/stdc++.h> using namespace std; int main(){ long long x; double p; cin>>x>>p; if(x%2){cout<<setprecision(20)<<((double)x+1)/2/p*100)<<endl;} else{ cout<<setprecision(20)<<((double)x)/2/p*100)<<endl;} }
a.cc: In function 'int main()': a.cc:7:56: error: expected ';' before ')' token 7 | if(x%2){cout<<setprecision(20)<<((double)x+1)/2/p*100)<<endl;} | ^ | ; a.cc:8:52: error: expected ';' before ')' token 8 | else{ cout<<setprecision(20)<<((double)x)/2/p*100)<<endl;} | ^ | ;
s647315488
p03901
C++
#include <iostream> #include <iomanip> using namespace std; double p int x; int main(){ cin >> x >> p; if(x%2==1) x++; cout << setprecision(8) << x/(2*p) << endl; }
a.cc:5:1: error: expected initializer before 'int' 5 | int x; | ^~~ a.cc: In function 'int main()': a.cc:8:10: error: 'x' was not declared in this scope 8 | cin >> x >> p; | ^ a.cc:8:15: error: 'p' was not declared in this scope 8 | cin >> x >> p; | ^
s860172407
p03901
C++
#include <iostream> using namespace std; double p,x; int main(){ cin >> x >> p; if(x%2==1) x++; cout << setprecision(8) << x/(2*p) << endl; }
a.cc: In function 'int main()': a.cc:7:7: error: invalid operands of types 'double' and 'int' to binary 'operator%' 7 | if(x%2==1) x++; | ~^~ | | | | | int | double a.cc:8:11: error: 'setprecision' was not declared in this scope 8 | cout << setprecision(8) << x/(2*p) << endl; | ^~~~~~~~~~~~ a.cc:2:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>' 1 | #include <iostream> +++ |+#include <iomanip> 2 | using namespace std;
s317325770
p03901
C++
x = int(input()) p = int(input()) p *= 0.01 print((x+1)//2/p)
a.cc:1:1: error: 'x' does not name a type 1 | x = int(input()) | ^
s763890984
p03901
C++
#include <bits/stdc++.h> #define mp make_pair #define mt make_tuple #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using double = long double; const int INF=1<<29; const double EPS=1e-9; const ll MOD = 1000000007; const int dx[]={1,0,-1,0},dy[]={0,-1,0,1}; ll X,P; const int MAX_TURN = 2000; const int MAX_POS = 100; double dp[MAX_TURN][MAX_POS][MAX_POS]; bool visited[MAX_TURN][MAX_POS][MAX_POS]; //map<tuple<int, int, int>, double> dp; double memo(int turn, int pos_ao, int pos_cho){ if (pos_ao == pos_cho){ return turn; } if (turn >= MAX_TURN or pos_ao < 0 or pos_ao >= MAX_POS or pos_cho < 0 or pos_cho >= MAX_POS){ return INF; } double pro = (double) P / 100; if (visited[turn][pos_ao][pos_cho]){ return dp[turn][pos_ao][pos_cho]; } visited[turn][pos_ao][pos_cho] = true; //cout << turn << " " << pos_ao << " " << pos_cho << endl; double result = INF; //pre result = min(result, memo(turn + 1, pos_ao - 1, pos_cho - 1) * pro + memo(turn + 1, pos_ao - 1, pos_cho + 1) * (1 - pro)); //stop result = min(result, memo(turn + 1, pos_ao, pos_cho - 1) * pro + memo(turn + 1, pos_ao, pos_cho + 1) * (1 - pro)); //next result = min(result, memo(turn + 1, pos_ao + 1, pos_cho - 1) * pro + memo(turn + 1, pos_ao + 1, pos_cho + 1) * (1 - pro)); return dp[turn][pos_ao][pos_cho] = result; } int main(){ cin >> X >> P; if (X > 10)return 0; int geta = MAX_POS / 2; double result = memo(0, geta, X + geta); printf("%.20lf\n", result); return 0; }
a.cc:12:7: error: expected nested-name-specifier before 'double' 12 | using double = long double; | ^~~~~~
s123689973
p03901
C++
#include <bits/stdc++.h> #define mp make_pair #define mt make_tuple #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using double = long double; const int INF=1<<29; const double EPS=1e-9; const ll MOD = 1000000007; const int dx[]={1,0,-1,0},dy[]={0,-1,0,1}; ll X,P; const int MAX_TURN = 2000; const int MAX_POS = 100; double dp[MAX_TURN][MAX_POS][MAX_POS]; bool visited[MAX_TURN][MAX_POS][MAX_POS]; //map<tuple<int, int, int>, double> dp; double memo(int turn, int pos_ao, int pos_cho){ if (pos_ao == pos_cho){ return turn; } if (turn >= MAX_TURN or pos_ao < 0 or pos_ao >= MAX_POS or pos_cho < 0 or pos_cho >= MAX_POS){ return INF; } double pro = (double) P / 100; if (visited[turn][pos_ao][pos_cho]){ return dp[turn][pos_ao][pos_cho]; } visited[turn][pos_ao][pos_cho] = true; //cout << turn << " " << pos_ao << " " << pos_cho << endl; double result = INF; //pre result = min(result, memo(turn + 1, pos_ao - 1, pos_cho - 1) * pro + memo(turn + 1, pos_ao - 1, pos_cho + 1) * (1 - pro)); //stop result = min(result, memo(turn + 1, pos_ao, pos_cho - 1) * pro + memo(turn + 1, pos_ao, pos_cho + 1) * (1 - pro)); //next result = min(result, memo(turn + 1, pos_ao + 1, pos_cho - 1) * pro + memo(turn + 1, pos_ao + 1, pos_cho + 1) * (1 - pro)); return dp[turn][pos_ao][pos_cho] = result; } int main(){ cin >> X >> P; if (X > 10)return 0; int geta = MAX_POS / 2; double result = memo(0, geta, X + geta); printf("%.20lf\n", result); return 0;
a.cc:12:7: error: expected nested-name-specifier before 'double' 12 | using double = long double; | ^~~~~~ a.cc: In function 'int main()': a.cc:52:12: error: expected '}' at end of input 52 | return 0; | ^ a.cc:46:11: note: to match this '{' 46 | int main(){ | ^
s556721034
p03901
C++
sx = input() sp = input() x = int(sx) p = int(sp) ret = 0 e = 0 cnt = x % 2 if p == 100: ret = int(x / 2) + cnt print(ret)
a.cc:1:1: error: 'sx' does not name a type 1 | sx = input() | ^~
s930108408
p03902
C++
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector<int> VI; typedef vector<ll> VL; typedef pair<int, int> PI; const ll mod = 1e9 + 7; int trial(vector<VI> &a) { int tot = 0; REP(i, 0, n - 1) { if (tot >= 40000) { return -1; } while (not (a[i] < a[i + 1])) { // cast REP(j, 0, m - 1) { a[i + 1][j + 1] += a[i + 1][j]; } tot++; } } } int main(void){ int n, m; cin >> n >> m; vector<VI> a(n); REP(i, 0, n) { a[i] = VI(m); REP(j, 0, m) { cin >> a[i][j]; } } REP(i, 0, n - 1) { if (a[i][0] > a[i + 1][0]) { cout << -1 << endl; return 0; } } int tot = trial(a); cout << tot << endl; }
a.cc: In function 'int trial(std::vector<std::vector<int> >&)': a.cc:36:13: error: 'n' was not declared in this scope 36 | REP(i, 0, n - 1) { | ^ a.cc:25:47: note: in definition of macro 'REP' 25 | #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) | ^ a.cc:42:17: error: 'm' was not declared in this scope 42 | REP(j, 0, m - 1) { | ^ a.cc:25:47: note: in definition of macro 'REP' 25 | #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) | ^ a.cc:48:1: warning: control reaches end of non-void function [-Wreturn-type] 48 | } | ^
s568010796
p03902
C++
#include <vector> #include <iostream> #include <algorithm> using namespace std; const int lim = 1000000001; int calc(vector<int> v1, vector<int> v2, bool flag_eq = false) { if(v1 < v2) return -calc(v2, v1, true) + 1; if((v1[1] - v2[1]) % v1[0] != 0) return (v1[1] - v2[1]) / v1[0] + 1; int ex = (v1[1] - v2[1]) / v1[0]; int lp = v1.size(); for(int i = 0; i < ex; i++) { int clp = lp; for(int j = 1; j < lp; j++) { v2[j] += v2[j - 1]; if(v2[j] >= lim) { v2[j] = lim; if(clp == lp) clp = j; } } lp = clp; if(lp == 2) { v2[1] += ex - i - 1; break; } } if((!flag_eq && v1 < v2) || (flag_eq && v1 <= v2)) return ex; return ex + 1; } int N, M; int main() { cin.tie(0); ios_base::sync_with_stdio(false); cin >> N >> M; vector<vector<int> > v(N, vector<int>(M)); for(int i = 0; i < N; i++) { for(int j = 0; j < M; j++) { cin >> v[i][j]; } } if(M == 1) { bool f = true; for(int i = 1; i < N; i++) { if(v[i - 1][0] >= v[i][0]) f = false; } cout << (f ? 0 : -1) << endl; } else { bool f = true; for(int i = 1; i < N; i++) { if(v[i - 1][0] > v[i][0]) f = false; } if(!f) cout << -1 << endl; else { long long cur = 0, ret = 0; for(int i = 1; i < N; i++) { long long res = calc(v[i - 1], v[i]); cur = max(cur + res, 0); ret += cur; } cout << ret << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:57:42: error: no matching function for call to 'max(long long int, int)' 57 | cur = max(cur + res, 0); | ~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:62, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:57:42: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 57 | cur = max(cur + res, 0); | ~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:57:42: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 57 | cur = max(cur + res, 0); | ~~~^~~~~~~~~~~~~~
s607412660
p03902
C++
/*** Template Begin ***/ #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> auto init_ = [] { std::ios_base::sync_with_stdio(false); std::cout << std::fixed; return 0; }(); template <typename T> inline T in() { T x; std::cin >> x; return x; } template <typename T> inline void in(T &x) { std::cin >> x; } template <typename T, typename... Ts> inline void in(T &t, Ts &... ts) { std::cin >> t; in(ts...); } template <typename T, typename U = std::vector<T>> inline U vin(int n) { U v(n); for (int i = 0; i < n; ++i) { std::cin >> v[i]; } return v; } template <typename T, typename U = std::vector<T>, typename V = std::vector<U>> inline V vin(int h, int w) { V vv(h, U(w)); for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { std::cin >> vv[i][j]; } } return vv; } template <typename T> inline void out(const T &x) { std::cout << x << std::endl; } template <char delimiter = ' ', typename T, typename... Ts> inline void out(const T &t, const Ts &... ts) { std::cout << t << delimiter; out(ts...); } template <char delimiter = ' ', typename T> inline void vout(const T &v, int n) { for (int i = 0; i < n; ++i) { if (i) std::cout << delimiter; std::cout << v[i]; } std::cout << std::endl; } template <char delimiter = ' ', typename T> inline void vout(const T &v, int h, int w) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (j) std::cout << delimiter; std::cout << v[i][j]; } std::cout << std::endl; } } template <typename T, size_t D> struct multi_vector_type { using type = std::vector<typename multi_vector_type<T, D - 1>::type>; }; template <typename T> struct multi_vector_type<T, 1> { using type = std::vector<T>; }; template <typename T> struct multi_vector_type<T, 0> { using type = T; }; template <typename T, size_t D> using multi_vector = typename multi_vector_type<T, D>::type; template <typename T, size_t D, class = typename std::enable_if<D == 0>::type> T make_vector(const T &val = T()) { return val; } template <typename T, size_t D = 1, typename... Ts, class = typename std::enable_if<D != 0>::type> multi_vector<T, D> make_vector(size_t n, Ts &&... args) { return multi_vector<T, D>(n, make_vector<T, D - 1>(args...)); } using namespace std; #define USING_BOOST #ifdef USING_BOOST #include <boost/multiprecision/cpp_int.hpp> #include <boost/range.hpp> #include <boost/range/adaptors.hpp> #include <boost/range/algorithm.hpp> #include <boost/range/algorithm_ext.hpp> #include <boost/range/irange.hpp> inline auto rep(int begin, int end) { if (begin > end) { return boost::irange(0, 0); } else { return boost::irange(begin, end); } } inline auto rep(int begin, int end, int step) { if ((step > 0 && begin > end) || (step < 0 && begin < end)) { return boost::irange(0, 0, step); } else { return boost::irange(begin, end, step); } } #endif #define USING_NAMESPACE #ifdef USING_NAMESPACE using namespace std; #ifdef USING_BOOST using namespace boost; using namespace boost::adaptors; #endif #endif /*** Template End ***/ namespace mp = boost : multiprecision; int main() { int64_t n, m; in(n, m); auto a = vin<mp::cpp_int>(n, m); // auto s = make_vector<int64_t, 2>(n, m); // for (int i : rep(0, n)) { // for (int j : rep(0, m)) { // if (j == 0) { // s[i][j] = a[i][j]; // } else { // s[i][j] = s[i][j - 1] + a[i][j]; // } // } // } int ans = 0; for (int i : rep(1, n)) { if (a[i - 1][0] > a[i][0]) { out(-1); return 0; } while (a[i - 1] >= a[i]) { vector<mp::cpp_int> tmp(m); for (int j : rep(0, m)) { if (j == 0) { tmp[j] = a[i][j]; } else { tmp[j] = tmp[j - 1] + a[i][j]; } } swap(a[i], tmp); ans++; } } out(ans); }
a.cc:135:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory 135 | #include <boost/multiprecision/cpp_int.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s378540541
p03902
C++
#include <vector> #include <iostream> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf=1e9; const int64_t inf64=1e18; const double eps=1e-9; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } void solve(){ int n,m; cin >> n >> m; vector<vector<__int128 >> a(n,vector<__int128 >(m)); rep(i,0,n) rep(j,0,m) cin >> a[i][j]; rep(i,1,n){ if(a[i][0]<a[i-1][0]){ cout << -1 << endl; return; } } auto magic=[&](int i){ rep(j,1,m){ a[i][j]+=a[i][j-1]; } }; int ans=0; rep(i,1,n){ while(a[i]<=a[i-1]){ magic(i); ++ans; } } cout << ans << endl; } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:32:31: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}) 32 | rep(i,0,n) rep(j,0,m) cin >> a[i][j]; In file included from /usr/include/c++/14/iostream:42, from a.cc:2: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:170:7: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:174:7: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:177:7: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:181:7: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:184:7: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:188:7: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:192:7: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:199:7: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:203:7: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:219:7: error: cannot bind non-const lvalue reference of type 'float&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:223:7: error: cannot bind non-const lvalue reference of type 'double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:227:7: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:328:7: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} to 'void*' [-fpermissive] 328 | operator>>(void*& __p) | ^~~~~~~~ | | | __gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type {aka __int128} /usr/include/c++/14/istream:328:7: error: cannot bind rvalue '(void*)((long int)(& a.std::vector<std::vector<__int128> >::operator[](((std::vector<std::vector<__int128> >::size_type)i)))->std::vector<__int128>::operator[](((std::vector<__int128>::size_type)j)))' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:122:7: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ | | | __gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type {aka __int128} /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basi
s068744064
p03902
C++
#include <vector> #include <iostream> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf=1e9; const int64_t inf64=1e18; const double eps=1e-9; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } void solve(){ int n,m; cin >> n >> m; vector<vector<__int128 >> a(n,vector<__int128 >(m)); rep(i,0,n) rep(j,0,m) cin >> a[i][j]; rep(i,1,n){ if(a[i][0]<a[i-1][0]){ cout << -1 << endl; return; } } auto magic=[&](int i){ rep(j,1,m){ a[i][j]+=a[i][j-1]; } }; int ans=0; rep(i,1,n){ while(a[i]<=a[i-1]){ magic(i); ++ans; } } cout << ans << endl; } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:32:31: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}) 32 | rep(i,0,n) rep(j,0,m) cin >> a[i][j]; In file included from /usr/include/c++/14/iostream:42, from a.cc:2: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:170:7: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:174:7: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:177:7: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:181:7: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:184:7: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:188:7: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:192:7: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:199:7: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:203:7: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:219:7: error: cannot bind non-const lvalue reference of type 'float&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:223:7: error: cannot bind non-const lvalue reference of type 'double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:227:7: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:328:7: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} to 'void*' [-fpermissive] 328 | operator>>(void*& __p) | ^~~~~~~~ | | | __gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type {aka __int128} /usr/include/c++/14/istream:328:7: error: cannot bind rvalue '(void*)((long int)(& a.std::vector<std::vector<__int128> >::operator[](((std::vector<std::vector<__int128> >::size_type)i)))->std::vector<__int128>::operator[](((std::vector<__int128>::size_type)j)))' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:122:7: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ | | | __gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type {aka __int128} /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basi
s921490636
p03902
C++
#include <vector> #include <iostream> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf=1e9; const int64_t inf64=1e18; const double eps=1e-9; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } void solve(){ int n,m; cin >> n >> m; vector<vector<__int128 >> a(n,vector<__int128 >(m)); rep(i,0,n) rep(j,0,m) cin >> a[i][j]; rep(i,1,n){ if(a[i][0]<a[i-1][0]){ cout << -1 << endl; return; } } auto magic=[&](int i){ rep(j,1,m){ a[i][j]+=a[i][j-1]; } }; int ans=0; rep(i,1,n){ while(a[i]<=a[i-1]){ magic(i); ++ans; } } cout << ans << endl; } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:32:31: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}) 32 | rep(i,0,n) rep(j,0,m) cin >> a[i][j]; In file included from /usr/include/c++/14/iostream:42, from a.cc:2: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:170:7: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:174:7: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:177:7: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:181:7: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:184:7: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:188:7: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:192:7: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:199:7: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:203:7: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:219:7: error: cannot bind non-const lvalue reference of type 'float&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:223:7: error: cannot bind non-const lvalue reference of type 'double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:227:7: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:328:7: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} to 'void*' [-fpermissive] 328 | operator>>(void*& __p) | ^~~~~~~~ | | | __gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type {aka __int128} /usr/include/c++/14/istream:328:7: error: cannot bind rvalue '(void*)((long int)(& a.std::vector<std::vector<__int128> >::operator[](((std::vector<std::vector<__int128> >::size_type)i)))->std::vector<__int128>::operator[](((std::vector<__int128>::size_type)j)))' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: /usr/include/c++/14/istream:122:7: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ | | | __gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type {aka __int128} /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basi
s873784846
p03902
C++
#include <vector> #include <iostream> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf=1e9; const int64_t inf64=1e18; const double eps=1e-9; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } void solve(){ int n,m; cin >> n >> m; vector<vector<int128_t>> a(n,vector<int128_t>(m)); rep(i,0,n) rep(j,0,m) cin >> a[i][j]; rep(i,1,n){ if(a[i][0]<a[i-1][0]){ cout << -1 << endl; return; } } auto magic=[&](int i){ rep(j,1,m){ a[i][j]+=a[i][j-1]; } }; int ans=0; rep(i,1,n){ while(a[i]<=a[i-1]){ magic(i); ++ans; } } cout << ans << endl; } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:31:19: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'? 31 | vector<vector<int128_t>> a(n,vector<int128_t>(m)); | ^~~~~~~~ | int8_t a.cc:31:19: error: template argument 1 is invalid a.cc:31:19: error: template argument 2 is invalid a.cc:31:27: error: template argument 1 is invalid 31 | vector<vector<int128_t>> a(n,vector<int128_t>(m)); | ^~ a.cc:31:27: error: template argument 2 is invalid a.cc:31:49: error: template argument 2 is invalid 31 | vector<vector<int128_t>> a(n,vector<int128_t>(m)); | ^ a.cc:31:53: error: expression list treated as compound expression in initializer [-fpermissive] 31 | vector<vector<int128_t>> a(n,vector<int128_t>(m)); | ^ a.cc:32:35: error: invalid types 'int[int]' for array subscript 32 | rep(i,0,n) rep(j,0,m) cin >> a[i][j]; | ^ a.cc:35:13: error: invalid types 'int[int]' for array subscript 35 | if(a[i][0]<a[i-1][0]){ | ^ a.cc:35:21: error: invalid types 'int[int]' for array subscript 35 | if(a[i][0]<a[i-1][0]){ | ^ a.cc: In lambda function: a.cc:43:14: error: invalid types 'int[int]' for array subscript 43 | a[i][j]+=a[i][j-1]; | ^ a.cc:43:23: error: invalid types 'int[int]' for array subscript 43 | a[i][j]+=a[i][j-1]; | ^ a.cc: In function 'void solve()': a.cc:49:16: error: invalid types 'int[int]' for array subscript 49 | while(a[i]<=a[i-1]){ | ^ a.cc:49:22: error: invalid types 'int[int]' for array subscript 49 | while(a[i]<=a[i-1]){ | ^
s024486804
p03902
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf=1e9; const int64_t inf64=1e18; const double eps=1e-9; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } void solve(){ int n,m; cin >> n >> m; vector<vector<int128_t>> a(n,vector<int128_t>(m)); rep(i,0,n) rep(j,0,m) cin >> a[i][j]; rep(i,1,n){ if(a[i][0]<a[i-1][0]){ cout << -1 << endl; return; } } auto magic=[&](int i){ rep(j,1,m){ a[i][j]+=a[i][j-1]; } }; int ans=0; rep(i,1,n){ while(a[i]<=a[i-1]){ magic(i); ++ans; } } cout << ans << endl; } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:30:19: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'? 30 | vector<vector<int128_t>> a(n,vector<int128_t>(m)); | ^~~~~~~~ | int8_t a.cc:30:19: error: template argument 1 is invalid a.cc:30:19: error: template argument 2 is invalid a.cc:30:27: error: template argument 1 is invalid 30 | vector<vector<int128_t>> a(n,vector<int128_t>(m)); | ^~ a.cc:30:27: error: template argument 2 is invalid a.cc:30:49: error: template argument 2 is invalid 30 | vector<vector<int128_t>> a(n,vector<int128_t>(m)); | ^ a.cc:30:53: error: expression list treated as compound expression in initializer [-fpermissive] 30 | vector<vector<int128_t>> a(n,vector<int128_t>(m)); | ^ a.cc:31:35: error: invalid types 'int[int]' for array subscript 31 | rep(i,0,n) rep(j,0,m) cin >> a[i][j]; | ^ a.cc:34:13: error: invalid types 'int[int]' for array subscript 34 | if(a[i][0]<a[i-1][0]){ | ^ a.cc:34:21: error: invalid types 'int[int]' for array subscript 34 | if(a[i][0]<a[i-1][0]){ | ^ a.cc: In lambda function: a.cc:42:14: error: invalid types 'int[int]' for array subscript 42 | a[i][j]+=a[i][j-1]; | ^ a.cc:42:23: error: invalid types 'int[int]' for array subscript 42 | a[i][j]+=a[i][j-1]; | ^ a.cc: In function 'void solve()': a.cc:48:16: error: invalid types 'int[int]' for array subscript 48 | while(a[i]<=a[i-1]){ | ^ a.cc:48:22: error: invalid types 'int[int]' for array subscript 48 | while(a[i]<=a[i-1]){ | ^
s434272323
p03902
C++
#include <algorithm> #include <iostream> #include <cstdio> #include <string> #include <vector> #include <cmath> #include <queue> #include <set> #include <map> using namespace std; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef long long ll; typedef long double ld; int n,m; int a[1005][1005]; int main() { ios::sync_with_stdio(0); cin.tie(); cin >> n >> m; for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) cin >> a[i][j]; ll ans = 0; ll last = 0; for(int i = 1; i < n; ++i) { if(a[i-1][0] > a[i][0]) { cout << "-1\n"; return 0; } if(a[i-1][0] < a[i][0]) { last = 0; } else { if(n == 1) { cout << "-1\n"; return 0; } ll b = last*a[i-1][0] + a[i-1][1]; ll y = a[i][1]; ll x = a[i][0]; if((b-y)%x == 0 && n > 2 && a[i][2] > a[i-1][2]) { last = (b-y)/x; } else { ll k = max(0LL,ll(1+(b - y)/x))); last = k; } } ans += last; } cout << ans << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:46:64: error: expected ',' or ';' before ')' token 46 | ll k = max(0LL,ll(1+(b - y)/x))); | ^
s685344143
p03902
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf=1e9; const int64_t inf64=1e18; const double eps=1e-9; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } void solve(){ int n,m; cin >> n >> m; vector<vector<__int12>> a(n,vector<__int12>(m)); rep(i,0,n) rep(j,0,m) cin >> a[i][j]; rep(i,1,n){ if(a[i][0]<a[i-1][0]){ cout << -1 << endl; return; } } auto magic=[&](int i){ rep(j,1,m){ a[i][j]+=a[i][j-1]; } }; int ans=0; rep(i,1,n){ while(a[i]<=a[i-1]){ magic(i); ++ans; } } cout << ans << endl; } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:30:19: error: '__int12' was not declared in this scope; did you mean '__int128'? 30 | vector<vector<__int12>> a(n,vector<__int12>(m)); | ^~~~~~~ | __int128 a.cc:30:19: error: template argument 1 is invalid a.cc:30:19: error: template argument 2 is invalid a.cc:30:26: error: template argument 1 is invalid 30 | vector<vector<__int12>> a(n,vector<__int12>(m)); | ^~ a.cc:30:26: error: template argument 2 is invalid a.cc:30:47: error: template argument 2 is invalid 30 | vector<vector<__int12>> a(n,vector<__int12>(m)); | ^ a.cc:30:51: error: expression list treated as compound expression in initializer [-fpermissive] 30 | vector<vector<__int12>> a(n,vector<__int12>(m)); | ^ a.cc:31:35: error: invalid types 'int[int]' for array subscript 31 | rep(i,0,n) rep(j,0,m) cin >> a[i][j]; | ^ a.cc:34:13: error: invalid types 'int[int]' for array subscript 34 | if(a[i][0]<a[i-1][0]){ | ^ a.cc:34:21: error: invalid types 'int[int]' for array subscript 34 | if(a[i][0]<a[i-1][0]){ | ^ a.cc: In lambda function: a.cc:42:14: error: invalid types 'int[int]' for array subscript 42 | a[i][j]+=a[i][j-1]; | ^ a.cc:42:23: error: invalid types 'int[int]' for array subscript 42 | a[i][j]+=a[i][j-1]; | ^ a.cc: In function 'void solve()': a.cc:48:16: error: invalid types 'int[int]' for array subscript 48 | while(a[i]<=a[i-1]){ | ^ a.cc:48:22: error: invalid types 'int[int]' for array subscript 48 | while(a[i]<=a[i-1]){ | ^
s301178974
p03902
C++
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author RiaD */ #include <iostream> #include <fstream> #include <iostream> #include <vector> #include <iterator> #include <string> #include <stdexcept> #ifndef SPCPPL_ASSERT #ifdef SPCPPL_DEBUG #define SPCPPL_ASSERT(condition) \ if(!(condition)) { \ throw std::runtime_error(std::string() + #condition + " in line " + std::to_string(__LINE__) + " in " + __PRETTY_FUNCTION__); \ } #else #define SPCPPL_ASSERT(condition) #endif #endif /** * Support decrementing and multi-passing, but not declared bidirectional(or even forward) because * it's reference type is not a reference. * * It doesn't return reference because * 1. Anyway it'll not satisfy requirement [forward.iterators]/6 * If a and b are both dereferenceable, then a == b if and only if *a and * b are bound to the same object. * 2. It'll not work with reverse_iterator that returns operator * of temporary which is temporary for this iterator * * Note, reverse_iterator is not guaranteed to work now too since it works only with bidirectional iterators, * but it's seems to work at least on my implementation. * * It's not really useful anywhere except iterating anyway. */ template <typename T> class IntegerIterator: public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> { public: explicit IntegerIterator(T value): value(value) { } IntegerIterator& operator++() { ++value; return *this; } IntegerIterator operator++(int) { IntegerIterator copy = *this; ++value; return copy; } IntegerIterator& operator--() { --value; return *this; } IntegerIterator operator--(int) { IntegerIterator copy = *this; --value; return copy; } T operator*() const { return value; } bool operator==(IntegerIterator rhs) const { return value == rhs.value; } bool operator!=(IntegerIterator rhs) const { return !(*this == rhs); } private: T value; }; template <typename T> class IntegerRange { public: IntegerRange(T begin, T end): begin_(begin), end_(end) { SPCPPL_ASSERT(begin <= end); } IntegerIterator<T> begin() const { return IntegerIterator<T>(begin_); } IntegerIterator<T> end() const { return IntegerIterator<T>(end_); } private: T begin_; T end_; }; template <typename T> class ReversedIntegerRange { typedef std::reverse_iterator<IntegerIterator<T>> IteratorType; public: ReversedIntegerRange(T begin, T end): begin_(begin), end_(end) { SPCPPL_ASSERT(begin >= end); } IteratorType begin() const { return IteratorType(IntegerIterator<T>(begin_)); } IteratorType end() const { return IteratorType(IntegerIterator<T>(end_)); } private: T begin_; T end_; }; template <typename T> IntegerRange<T> range(T to) { return IntegerRange<T>(0, to); } template <typename T> IntegerRange<T> range(T from, T to) { return IntegerRange<T>(from, to); } template <typename T> IntegerRange<T> inclusiveRange(T to) { return IntegerRange<T>(0, to + 1); } template <typename T> IntegerRange<T> inclusiveRange(T from, T to) { return IntegerRange<T>(from, to + 1); } template <typename T> ReversedIntegerRange<T> downrange(T from) { return ReversedIntegerRange<T>(from, 0); } template <typename T> ReversedIntegerRange<T> downrange(T from, T to) { return ReversedIntegerRange<T>(from, to); } template <typename T> ReversedIntegerRange<T> inclusiveDownrange(T from) { return ReversedIntegerRange<T>(from + 1, 0); } template <typename T> ReversedIntegerRange<T> inclusiveDownrange(T from, T to) { return ReversedIntegerRange<T>(from + 1, to); } template <typename T> T divideCeil(T a, T b) { SPCPPL_ASSERT(b != 0); if (b < 0) { a = -a; b = -b; } return a / b + (a % b > 0); } template <typename T> T divideFloor(T a, T b) { SPCPPL_ASSERT(b != 0); if (b < 0) { a = -a; b = -b; } return a / b - (a % b < 0); } template <typename T> T divideTowardsZero(T a, T b) { SPCPPL_ASSERT(b != 0); return a / b; } template <typename T> T divideAwayFromZero(T a, T b) { SPCPPL_ASSERT(b != 0); bool changeSign = false; if (a < 0) { changeSign = !changeSign; a = -a; } if (b < 0) { changeSign = !changeSign; b = -b; } T res = (a + b - 1) / b; if (changeSign) { res *= -1; } return res; } using namespace std; class TaskB { public: void solve(std::istream& in, std::ostream& out) { int n, m; in >> n >> m; vector<vector<int64_t>> v(n, vector<int64_t>(m)); vector<vector<int64_t>> ov(n, vector<int64_t>(m)); for (int i: range(n)) { for (int j: range(m)) { in >> v[i][j]; ov[i][j] = v[i][j]; } } if(!is_sorted(v.begin(), v.end(), [](auto& a, auto& b) { return a[0] < b[0]; })) { out << "-1"; return; } if (m == 1) { out << 0; return; } int64_t ans = 0; int prevans = 0; for (int i: range(1, n)) { if (v[i][0] > v[i - 1][0]) { continue; } int64_t need = v[i - 1][1]; int64_t cur = v[i][1]; int64_t add = v[i][0]; int64_t curCntMin = cur >= need ? 0 : divideCeil(need - cur, add); for (int j: range(curCntMin)) { for (int k: range(1, m)) { v[i][k] += v[i][k - 1]; } } if (v[i] <= v[i - 1]) { for (int k: range(1, m)) { v[i][k] += v[i][k - 1]; } ++curCntMin; } ans += curCntMin; } out << ans << "\n"; } }; int main() { std::ios_base::sync_with_stdio(false); TaskB solver; std::istream& in(std::cin); std::ostream& out(std::cout); in.tie(nullptr); out << std::fixed; out.precision(20); solver.solve(in, out); return 0; }
a.cc:48:36: warning: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Wdeprecated-declarations] 48 | class IntegerIterator: public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> { | ^~~~~~~~ In file included from /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66, from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:7: /usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note: declared here 127 | struct _GLIBCXX17_DEPRECATED iterator | ^~~~~~~~ a.cc: In member function 'void TaskB::solve(std::istream&, std::ostream&)': a.cc:241:21: error: 'is_sorted' was not declared in this scope 241 | if(!is_sorted(v.begin(), v.end(), [](auto& a, auto& b) { | ^~~~~~~~~
s234980106
p03903
C
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // ここまで use std::io::Write; fn root(p: &Vec<i32>, mut x: usize) -> usize { while p[x] >= 0 { x = p[x] as usize; } x } fn run() { let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); input! { n: usize, m: usize, e: [(usize1, usize1, u64); m], q: usize, p: [(usize1, usize1); q], } let mut e = e; e.sort_by(|a, b| a.2.cmp(&b.2)); let mut parent = vec![-1; n]; let mut cost = vec![1000000000 + 1; n]; let mut sum = 0; for (a, b, c) in e { let mut a = root(&parent, a); let mut b = root(&parent, b); if a == b { continue; } sum += c; if parent[a] > parent[b] { std::mem::swap(&mut a, &mut b); } parent[a] += parent[b]; parent[b] = a as i32; cost[b] = c; } for (mut s, mut t) in p { let mut ans = 0; while s != t { if cost[s] < cost[t] { ans = cost[s]; s = parent[s] as usize; } else { ans = cost[t]; t = parent[t] as usize; } } writeln!(out, "{}", sum - ans).unwrap(); } } fn main() { run(); }
main.c:2:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '!' token 2 | macro_rules! input { | ^ main.c:19:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '!' token 19 | macro_rules! input_inner { | ^ main.c:28:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '!' token 28 | macro_rules! read_value { | ^ main.c:33:10: error: too many decimal points in number 33 | (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() | ^~~~~~~ main.c:48:1: error: unknown type name 'use' 48 | use std::io::Write; | ^~~ main.c:48:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '::' token 48 | use std::io::Write; | ^~ main.c:50:1: error: unknown type name 'fn' 50 | fn root(p: &Vec<i32>, mut x: usize) -> usize { | ^~ main.c:50:10: error: expected ')' before ':' token 50 | fn root(p: &Vec<i32>, mut x: usize) -> usize { | ^ | ) main.c:57:1: error: unknown type name 'fn' 57 | fn run() { | ^~ main.c: In function 'run': main.c:58:5: error: unknown type name 'let' 58 | let out = std::io::stdout(); | ^~~ main.c:58:15: error: 'std' undeclared (first use in this function) 58 | let out = std::io::stdout(); | ^~~ main.c:58:15: note: each undeclared identifier is reported only once for each function it appears in main.c:58:18: error: expected ',' or ';' before '::' token 58 | let out = std::io::stdout(); | ^~ main.c:59:5: error: unknown type name 'let' 59 | let mut out = std::io::BufWriter::new(out.lock()); | ^~~ main.c:59:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'out' 59 | let mut out = std::io::BufWriter::new(out.lock()); | ^~~ main.c:60:5: error: 'input' undeclared (first use in this function); did you mean 'int'? 60 | input! { | ^~~~~ | int main.c:60:10: error: expected ';' before '!' token 60 | input! { | ^ | ; main.c:68:5: error: 'e' undeclared (first use in this function) 68 | e.sort_by(|a, b| a.2.cmp(&b.2)); | ^ main.c:68:15: error: expected expression before '|' token 68 | e.sort_by(|a, b| a.2.cmp(&b.2)); | ^ main.c:68:23: error: too many decimal points in number 68 | e.sort_by(|a, b| a.2.cmp(&b.2)); | ^~~~~~ main.c:69:5: error: unknown type name 'let' 69 | let mut parent = vec![-1; n]; | ^~~ main.c:69:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'parent' 69 | let mut parent = vec![-1; n]; | ^~~~~~ main.c:69:31: error: 'n' undeclared (first use in this function) 69 | let mut parent = vec![-1; n]; | ^ main.c:69:32: error: expected ';' before ']' token 69 | let mut parent = vec![-1; n]; | ^ | ; main.c:69:32: error: expected statement before ']' token main.c:70:5: error: unknown type name 'let' 70 | let mut cost = vec![1000000000 + 1; n]; | ^~~ main.c:70:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'cost' 70 | let mut cost = vec![1000000000 + 1; n]; | ^~~~ main.c:70:42: error: expected ';' before ']' token 70 | let mut cost = vec![1000000000 + 1; n]; | ^ | ; main.c:70:42: error: expected statement before ']' token main.c:71:5: error: unknown type name 'let' 71 | let mut sum = 0; | ^~~ main.c:71:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'sum' 71 | let mut sum = 0; | ^~~ main.c:72:10: error: 'a' undeclared (first use in this function) 72 | for (a, b, c) in e { | ^ main.c:72:13: error: 'b' undeclared (first use in this function) 72 | for (a, b, c) in e { | ^ main.c:72:16: error: 'c' undeclared (first use in this function) 72 | for (a, b, c) in e { | ^ main.c:72:17: error: expected ';' before ')' token 72 | for (a, b, c) in e { | ^ | ; main.c:72:17: error: expected expression before ')' token main.c:72:19: error: 'in' undeclared (first use in this function); did you mean 'int'? 72 | for (a, b, c) in e { | ^~ | int main.c:72:21: error: expected ';' before 'e' 72 | for (a, b, c) in e { | ^~ | ; main.c: At top level: main.c:101:1: error: unknown type name 'fn' 101 | fn main() { | ^~
s528429811
p03903
C++
#include <cstdio> #include <iostream> #include <string> #include <vector> #include <sstream> #include <map> #include <set> #include <queue> #include <algorithm> #include <cmath> #include <cstring> #include <typeinfo> #include <numeric> #include <functional> #include <unordered_map> #include <bitset> #include <stack> #include <assert.h> #include <unordered_set> using namespace std; using ll = long long; using ull = unsigned long long; const ll INF = 1e16; const ll MOD = 1e9 + 7; #define REP(i, n) for(ll i = 0; i < n; i++) class unionfind { private: vector<int> par; vector<int> rank; vector<int> counter; public: unionfind(int n) : rank(n), counter(n, 1){ for(int i = 0; i < n; i++){ par.push_back(i); } } int find(int x){ if (par[x] == x) { return x; } else { return par[x] = find(par[x]); } } void unite(int x, int y){ x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) { counter[y] += counter[x]; counter[x] = counter[y]; par[x] = y; } else { counter[y] += counter[x]; counter[x] = counter[y]; par[y] = x; if (rank[x] == rank[y]) { rank[x]++; } } } bool same(int x, int y){ return find(x) == find(y); } ll count(int x){ return counter[find(x)]; } }; template <typename T> class kruskal { private: struct edge{ T cost; int u, v; bool operator<(const edge& e1) const { return cost < e1.cost; } }; vector<edge> es; int n; public: kruskal(int n) : n(n){} void add_edge(int u, int v, T cost){ es.push_back({cost, u, v}); es.push_back({cost, v, u}); } pair<vector<pair<pair<ll, ll>, ll>>, T> run(){ sort(es.begin(), es.end()); unionfind uni(n); T res = 0; vector<pair<pair<ll, ll>, ll>> edges; for(auto& e : es){ if(!uni.same(e.u, e.v)){ uni.unite(e.u, e.v); res += e.cost; edges.push_back({{e.u, e.v}, e.cost}); } } return {edges, res}; } }; class LCA { ll n, log_n; vector<vector<pair<ll, ll>>> parent; vector<ll> depth; vector<bool> used; private: void dfs(const vector<vector<pair<ll, ll>>> &g, ll now, ll par, ll d, ll cost){ parent[0][now].first = par; parent[0][now].second = cost; depth[now] = d; used[now] = true; for(auto &edge : g[now]){ ll child = edge.first, c = edge.second; if(child != par){ dfs(g, child, now, d + 1, c); } } } public: LCA(const vector<vector<pair<ll, ll>>> &g) : n(g.size()), log_n(0), depth(n), used(n) { for(ll v = n; v > 0; v /= 2){ log_n++; } parent.resize(log_n, vector<pair<ll, ll>>(n)); for(ll i = 0; i < n; i++){ if(!used[i]){ dfs(g, i, -1, 0, 0); } } for(ll k = 0; k < log_n - 1; k++){ for(ll v = 0; v < n; v++){ if(parent[k][v].first < 0){ parent[k + 1][v] = parent[k][v]; } else{ parent[k + 1][v].first = parent[k][parent[k][v].first].first; parent[k + 1][v].second = max(parent[k][v].second, parent[k][parent[k][v].first].second); } } } } ll query(ll u, ll v){ if(depth[u] > depth[v]){ swap(u, v); } ll res = 0; for(ll k = 0; k < log_n; k++){ if(((depth[v] - depth[u]) >> k) & 1){ res = max(res, parent[k][v].second); v = parent[k][v].first; } } if(u == v){ return res; } for(ll k = log_n - 1; k >= 0; k--){ if(parent[k][u] != parent[k][v]){ res = max(res, parent[k][u].second); res = max(res, parent[k][v].second); u = parent[k][u].first; v = parent[k][v].first; } } return res; } };
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s772744524
p03903
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; ll unipar[4010]; ll unilen[4010]; struct edge{ int len,from,to; }; bool cmp(edge& a,edge& b){ return a.len<b.len; } void init(ll n){ for(ll i=1;i<=n;i++){ unipar[i]=i; unilen[i]=0; } } ll root(ll n){ if(unipar[n]==n)return n; return unipar[n]=root(unipar[n]); } void unit(ll a,ll b){ a=root(a); b=root(b); if(a==b)return; if(unilen[a]<unilen[b]){ unipar[a]=b; } else{ unipar[b]=a; if(unipar[b]==unipar[a])unilen[a]++; } } int main(){ ll n,m;cin>>n>>m; vector<edge> v; for(ll i=0;i<m;i++){ ll a,b,c;cin>>a>>b>>c; v.push_back((edge){c,a,b}); } sort(v.begin(),v.end(),cmp); init(n); ll now=0; ll sum=0; vector<pll> vn[n+1]; for(ll i=0;i<m;i++){ edge e=v[i]; ll a=e.from,b=e.to; if(root(a)!=root(b)){ unit(a,b); sum+=e.len; vn[a].push_back(make_pair(b,c)); vn[b].push_back(make_pair(a,c)); now++; } if(now==n-1)break; }
a.cc: In function 'int main()': a.cc:40:24: warning: narrowing conversion of 'c' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 40 | v.push_back((edge){c,a,b}); | ^ a.cc:40:26: warning: narrowing conversion of 'a' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 40 | v.push_back((edge){c,a,b}); | ^ a.cc:40:28: warning: narrowing conversion of 'b' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing] 40 | v.push_back((edge){c,a,b}); | ^ a.cc:53:35: error: 'c' was not declared in this scope 53 | vn[a].push_back(make_pair(b,c)); | ^ a.cc:58:4: error: expected '}' at end of input 58 | } | ^ a.cc:35:11: note: to match this '{' 35 | int main(){ | ^
s822143203
p03903
C++
#include <iostream> #include <queue> #include <tuple> #include <vector> using namespace std; using ll = long long; const int MAX_V = 5000; class UnionFind { public: // コンストラクタ explicit UnionFind(int N) : V_NUM(N) { for (int i = 0; i < V_NUM; ++i) { par[i] = i; } fill(rank, rank + V_NUM, 0); } // xの親を返す+更新 int find(int x) { if (par[x] == x) { return x; } else { return par[x] = find(par[x]); } } // xとyを含むグループを統合する void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; // rank[x] >= rank[y]にする if (rank[x] < rank[y]) swap(x, y); par[y] = x; if (rank[x] == rank[y]) ++rank[x]; } // xとyが同じグループに属するか判定 bool same(int x, int y) { return find(x) == find(y); } int V_NUM; int par[MAX_V], rank[MAX_V]; }; int main() { int N, M; cin >> N >> M; tuple<ll, int, int> edges[M]; for (int i = 0; i < M; ++i) { int a, b; ll c; cin >> a >> b >> c; edges[i] = make_tuple(c, --a, --b); } sort(edges, edges + M); UnionFind uf(N); // 最小全域木の辺とコスト vector<pair<int, ll>> path[N]; ll total = 0; // Kruskalで最小全域木を構築 for (int i = 0; i < M; ++i) { int a, b; ll c; tie(c, a, b) = edges[i]; if (uf.same(a, b)) continue; uf.unite(a, b); total += c; path[a].push_back(make_pair(b, c)); path[b].push_back(make_pair(a, c)); } ll emax[N][N]; // emax[i][j] = iからjのパス上で最大コストの辺のコスト // 各頂点始点のBFS for (int r = 0; r < N; ++r) { fill(emax[r], emax[r] + N, -1); emax[r][r] = 0; queue<int> que; que.push(r); while (!que.empty()) { int v = que.front(); que.pop(); for (auto p : path[v]) { int sv; ll cost; tie(sv, cost) = p; if (emax[r][sv] >= 0) continue; emax[r][sv] = max(emax[r][v], cost); que.push(sv); } } } // クエリ処理 int Q; cin >> Q; for (int q = 0; q < Q; ++q) { int s, t; cin >> s >> t; cout << total - emax[--s][--t] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:65:5: error: 'sort' was not declared in this scope; did you mean 'short'? 65 | sort(edges, edges + M); | ^~~~ | short
s683232515
p03903
C
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <string> #include <sstream> #include <complex> #include <vector> #include <list> #include <queue> #include <deque> #include <stack> #include <map> #include <set> using namespace std; #define mod 1000000007 #define FOR(x,to) for(int x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define long long long inline int rei(){int x;cin>>x;return x;} inline long rel(){long x;cin>>x;return x;} inline string res(){string x;cin>>x;return x;} //------------------------------------------------------- template<class T> struct SparseTable{ vector<T> st[21]; void Init(int N,vector<T> data){ if(N<=0) return; int h = 1; while ((1 << h) < N) h++; for(int i=0;i<N;i++) st[0].push_back(data[i]); for(int j=1;j<=h;j++){ for(int i=0;i<N-(1<<j)+1;i++){ st[j].push_back(min(st[j - 1][i], st[j - 1][i + (1 << (j - 1))])); } } } inline int TopBit(int t){ return 31-__builtin_clz(t); } T GetMin(int b,int e){ int diff = TopBit(e-b); return min(st[diff][b], st[diff][e - (1 << diff)]); } }; struct LowestCommonAncestor{ int N; vector<int> path, depth, in_order, out_order; std::vector<pair<int,int>> dat; SparseTable<pair<int,int>> table; LowestCommonAncestor(const vector<vector<int>> G,int root) : N(G.size()), path(N * 2 - 1), depth(N * 2 - 1), in_order(N), out_order(N) { int k = 0; dfs(G, root, -1, 0, k); for (int i = 0; i < (int)depth.size(); ++i){ dat.push_back(make_pair(depth[i],i)); } table.Init(dat.size(),dat); } int Querry(int u,int v) { int l = min(in_order[u], in_order[v]); int r = max(in_order[u], in_order[v]) + 1; auto res = table.GetMin(l,r); return path[res.second]; } void dfs(const vector<vector<int>> G,int v,int f,int d,int &k) { in_order[v] = k; path[k] = v; depth[k++] = d; for (auto &e : G[v]){ if (e != f) { dfs(G,e,v,d+1,k); path[k] = v; depth[k++] = d; } } out_order[v] = k-1; } }; struct UnionFind{ vector<int> par; UnionFind(int N){ par.resize(N); for(int i=0;i<N;i++){ par[i] = i; } } void Union(int x,int y){ par[Get(x)] = Get(y); } bool Same(int x,int y){ return Get(x) == Get(y); } int Get(int x){ if(x != par[x]){ par[x] = Get(par[x]); } return par[x]; } }; pair<long,pair<int,int>> Edge[400000]; long cost[3999]; int leader[4000]; void Calc(){ int N = rei(); int M = rei(); for(int i=0;i<M;i++){ int f = rei()-1; int t = rei()-1; Edge[i] = {rel(),{f,t}}; } for(int i=0;i<N;i++){ leader[i] = i+N-1; } sort(Edge,Edge+M); vector<vector<int>> G(2*N-1); UnionFind U(N); int c = N-2; long ans = 0; for(int i=0;i<M;i++){ int f = Edge[i].second.first; int t = Edge[i].second.second; if(!U.Same(f,t)){ cost[c] = Edge[i].first; ans += Edge[i].first; G[c].push_back(leader[U.Get(f)]); G[c].push_back(leader[U.Get(t)]); U.Union(f,t); leader[U.Get(f)] = c--; } } LowestCommonAncestor LCA(G,0); int Q = rei(); for(int i=0;i<Q;i++){ int s = rei()-1; int t = rei()-1; cout << ans - cost[LCA.Querry(s+N-1,t+N-1)] << endl;; } } int main(int argc,char** argv){ ios::sync_with_stdio(false), cin.tie(0); cout.tie(0); Calc(); return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s782344712
p03903
Java
import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main implements Runnable { public static void main(String[] args) { new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start(); } public void run() { solver(); } class DJSet { int[] upper; public DJSet(int n) { upper = new int[n]; Arrays.fill(upper, -1); } int root(int x) { return upper[x] < 0 ? x : (upper[x] = root(upper[x])); } boolean equiv(int x, int y) { return root(x) == root(y); } void union(int x, int y) { x = root(x); y = root(y); if (x == y) return; if (upper[x] < upper[y]) { x ^= y; y ^= x; x ^= y; } upper[y] += upper[x]; upper[x] = y; } } class Edge implements Comparable<Edge> { int u, v; int cost; public Edge(int u_, int v_, int cost_) { u = u_; v = v_; cost = cost_; } @Override public int compareTo(Edge arg0) { return Integer.compare(cost, arg0.cost); } } int[][] max; void dfs(int cur, int par, int src, int ma, ArrayList<Edge>[] g) { max[src][cur] = Math.max(max[src][cur], ma); for (Edge e : g[cur]) { if (e.v == par) continue; dfs(e.v, cur, src, Math.max(ma, e.cost), g); } } void solver() { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); int M = Integer.parseInt(sc.next()); ArrayList<Edge>[] g = new ArrayList[N]; int[][] es = new int[M][3]; for (int i = 0; i < g.length; ++i) g[i] = new ArrayList(); for (int i = 0; i < M; ++i) { int u = Integer.parseInt(sc.next()); int v = Integer.parseInt(sc.next()); int c = Integer.parseInt(sc.next()); --u; --v; es[i] = new int[] { u, v, c }; } Arrays.sort(es, new Comparator<int[]>() { @Override public int compare(int[] arg0, int[] arg1) { return Integer.compare(arg0[2], arg1[2]); } }); { DJSet ds = new DJSet(N); long ans = 0; for (int[] e : es) { if (!ds.equiv(e[0], e[1])) { ans += e[2]; g[e[0]].add(new Edge(e[0], e[1], e[2])); g[e[1]].add(new Edge(e[1], e[0], e[2])); ds.union(e[0], e[1]); } } } System.gc(); max = new int[N][N]; for (int i = 0; i < N; ++i) { dfs(i, -1, i, 0, g); } PrintWriter pw = new PrintWriter(System.out); int Q = Integer.parseInt(sc.next()); for (int i = 0; i < Q; ++i) { int s = Integer.parseInt(sc.next()); int d = Integer.parseInt(sc.next()); --s; --d; pw.println(ans - max[s][d]); } pw.close(); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }
Main.java:120: error: cannot find symbol pw.println(ans - max[s][d]); ^ symbol: variable ans location: class Main Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s195246283
p03903
C++
#include<bits/stdc++.h> using namespace std; using Int = long long; struct edge{ Int from,to,cost,used; edge(){} edge(Int from,Int to,Int cost):from(from),to(to),cost(cost),used(0){} bool operator<(const edge& e) const{ return cost<e.cost; } }; struct Kruskal{ struct UnionFind{ Int n; vector<Int> r,p; UnionFind(){} UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);} Int find(Int x){ return (x==p[x]?x:p[x]=find(p[x])); } bool same(Int x,Int y){ return find(x)==find(y); } void unite(Int x,Int y){ x=find(x);y=find(y); if(x==y) return; if(r[x]<r[y]) swap(x,y); r[x]+=r[y]; p[y]=x; } }; Int n; vector<edge> edges; Kruskal(){} Kruskal(Int sz):n(sz){} void add_edge(Int u,Int v,Int c){ edges.push_back(edge(u,v,c)); } void input(Int m,Int offset=0){ Int a,b,c; for(Int i=0;i<m;i++){ cin>>a>>b>>c; add_edge(a+offset,b+offset,c); } } Int build(){ sort(edges.begin(),edges.end()); UnionFind uf(n+1); Int res=0; for(Int i=0;i<(Int)edges.size();i++){ edge &e=edges[i]; if(!uf.same(e.from,e.to)){ res+=e.cost; uf.unite(e.from,e.to); e.used=1; } } return res; } }; struct HLDecomposition { Int n,pos; vector<vector<Int> > G; vector<Int> vid, head, sub, hvy, par, dep, inv, type; HLDecomposition(){} HLDecomposition(Int sz): n(sz),pos(0),G(n), vid(n,-1),head(n),sub(n,1),hvy(n,-1), par(n),dep(n),inv(n),type(n){} void add_edge(Int u, Int v) { G[u].push_back(v); G[v].push_back(u); } void build(vector<Int> rs={0}) { Int c=0; for(Int r:rs){ dfs(r); bfs(r, c++); } } void dfs(Int rt) { using T = pair<Int,int>; stack<T> st; par[rt]=-1; dep[rt]=0; st.emplace(rt,0); while(!st.empty()){ Int v=st.top().first; Int &i=st.top().second; if(i<(Int)G[v].size()){ Int u=G[v][i++]; if(u==par[v]) continue; par[u]=v; dep[u]=dep[v]+1; st.emplace(u,0); }else{ st.pop(); Int res=0; for(Int u:G[v]){ if(u==par[v]) continue; sub[v]+=sub[u]; if(res<sub[u]) res=sub[u],hvy[v]=u; } } } } void bfs(Int r,Int c) { Int &k=pos; queue<Int> q({r}); while(!q.empty()){ Int h=q.front();q.pop(); for(Int i=h;i!=-1;i=hvy[i]) { type[i]=c; vid[i]=k++; inv[vid[i]]=i; head[i]=h; for(Int j:G[i]) if(j!=par[i]&&j!=hvy[i]) q.push(j); } } } // for_each(vertex) // [l,r] <- attention!! void for_each(Int u, Int v, const function<void(Int, Int)>& f) { while(1){ if(vid[u]>vid[v]) swap(u,v); f(max(vid[head[v]],vid[u]),vid[v]); if(head[u]!=head[v]) v=par[head[v]]; else break; } } // for_each(edge) // [l,r] <- attention!! void for_each_edge(Int u, Int v, const function<void(Int, Int)>& f) { while(1){ if(vid[u]>vid[v]) swap(u,v); if(head[u]!=head[v]){ f(vid[head[v]],vid[v]); v=par[head[v]]; } else{ if(u!=v) f(vid[u]+1,vid[v]); break; } } } Int lca(Int u,Int v){ while(1){ if(vid[u]>vid[v]) swap(u,v); if(head[u]==head[v]) return u; v=par[head[v]]; } } Int distance(Int u,Int v){ return dep[u]+dep[v]-2*dep[lca(u,v)]; } }; template <typename T,typename E> struct SegmentTree{ typedef function<T(T,T)> F; typedef function<T(T,E)> G; Int n; F f; G g; T d1; E d0; vector<T> dat; SegmentTree(){}; SegmentTree(Int n_,F f,G g,T d1, vector<T> v=vector<T>()): f(f),g(g),d1(d1){ init(n_); if(n_==(Int)v.size()) build(n_,v); } void init(Int n_){ n=1; while(n<n_) n*=2; dat.clear(); dat.resize(2*n-1,d1); } void build(Int n_, vector<T> v){ for(Int i=0;i<n_;i++) dat[i+n-1]=v[i]; for(Int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]); } void update(Int k,E a){ k+=n-1; dat[k]=g(dat[k],a); while(k>0){ k=(k-1)/2; dat[k]=f(dat[k*2+1],dat[k*2+2]); } } inline T query(Int a,Int b){ T vl=d1,vr=d1; for(Int l=a+n,r=b+n;l<r;l>>=1,r>>=1) { if(l&1) vl=f(vl,dat[(l++)-1]); if(r&1) vr=f(dat[(--r)-1],vr); } return f(vl,vr); } }; signed main(){ Int n,m; cin>>n>>m; Kruskal k(n); k.input(m,-1); Int val=k.build(); auto es=k.edges; es.erase(remove_if(es.begin(),es.end(),[](edge e){return !e.used;}),es.end()); //cout<<es.size()<<endl; //for(auto e:es) cout<<e.used<<endl; HLDecomposition hld(n); for(auto e:es) hld.add_edge(e.from, e.to); hld.build(); SegmentTree<Int, Int> seg(n, [](Int a,Int b){return max(a,b);}, [](Int a,Int b){return b;}, 0); for(auto e:es){ Int u=e.from,v=e.to,c=e.cost; if(hld.dep[u]>hld.dep[v]) swap(u,v); seg.update(hld.vid[v],c); } Int q; cin>>q; //if(q>3000) exit(1); for(Int i=0;i<q;i++){ Int s,t; cin>>s>>t; s--;t--; Int x=0; hld.for_each_edge(s,t,[&](Int l,Int r){ x=max(x,seg.query(l,r+1)); }); cout<<val-x<<endl; } return 0; }
a.cc: In member function 'void HLDecomposition::dfs(Int)': a.cc:105:23: error: cannot bind non-const lvalue reference of type 'Int&' {aka 'long long int&'} to a value of type 'int' 105 | Int &i=st.top().second; | ~~~~~~~~~^~~~~~
s840079280
p03903
C++
#include <algorithm> #include <cassert> #include <cfloat> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> #define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i)) #define rep(i,n) FOR(i,0,n) #define all(v) begin(v), end(v) #define debug(x) cerr<< #x <<": "<<x<<endl #define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vector<int> > vvi; typedef vector<ll> vll; typedef vector<vector<ll> > vvll; typedef deque<bool> db; template<class T> using vv=vector<vector< T > >; class UF { private: vector<int> data; // parent or size vector<int> next; vector<int> last; void init(int n) { data.assign(n, -1); next.assign(n, -1); last.resize(n); for (int i = 0; i < n; ++i) { last[i] = i; } } public: UF() {} UF(int n) { init(n); } int root(int x) { if (data[x] < 0) return x; return data[x] = root(data[x]); } bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (data[x] > data[y]) swap(x, y); // data[x] and data[y] are negative. data[x] += data[y]; data[y] = x; next[last[x]] = y; last[x] = last[y]; return true; } int size(int x) { return -data[root(x)]; } bool same(int x, int y) { return root(x) == root(y); } int get_next(int x) { return next[x]; } }; int main() { int n, m; scanf("%d%d", &n, &m) vvi edge(m, vi(3)); rep (i, m) { scanf("%d%d%d", &edge[i][1], &edge[i][2], &edge[i][0]); edge[i][1] -= 1; edge[i][2] -= 1; } sort(all(edge)); UF uf(n); vvi maxcost(n, vi(n)); ll cost = 0; cost += edge[0][0]; uf.unite(edge[0][1], edge[0][2]); maxcost[edge[0][1]][edge[0][2]] = maxcost[edge[0][2]][edge[0][1]] = edge[0][0]; FOR (i, 1, m) { int x = edge[i][1]; int y = edge[i][2]; if (!(uf.same(x, y))) { cost += edge[i][0]; for (int j = uf.root(x); j != -1; j = uf.get_next(j)) { for (int k = uf.root(y); k != -1; k = uf.get_next(k)) { maxcost[j][k] = maxcost[k][j] = edge[i][0]; } } uf.unite(x, y); } } int q; cin >> q; vll ans(q, 0); rep (j, q) { int s, t; cin >> s >> t; s -= 1; t -= 1; ans[j] = cost - maxcost[s][t]; } rep (i, q) { printf("%lld\n", ans[i]); } return 0; }
a.cc: In function 'int main()': a.cc:83:24: error: expected ';' before 'vvi' 83 | scanf("%d%d", &n, &m) | ^ | ; 84 | vvi edge(m, vi(3)); | ~~~ a.cc:86:22: error: 'edge' was not declared in this scope 86 | scanf("%d%d%d", &edge[i][1], &edge[i][2], &edge[i][0]); | ^~~~ a.cc:89:12: error: 'edge' was not declared in this scope 89 | sort(all(edge)); | ^~~~ a.cc:22:22: note: in definition of macro 'all' 22 | #define all(v) begin(v), end(v) | ^
s512173850
p03903
C++
w#include <cstdio> #include <vector> #include <algorithm> using namespace std; int n, m; struct uni { vector<int> p; uni(int n) : p(n, -1) {} int root(int a) { return p[a] < 0 ? a : (p[a] = root(p[a])); } bool find(int a, int b) { return root(a) == root(b); } bool merge(int a, int b) { a = root(a); b = root(b); if (a == b) return false; p[a] = b; return true; } }; struct edge { int f, t, c; edge() {} edge(int f, int t, int c) : f(f), t(t), c(c) {} bool operator<(const edge& e) const { return c < e.c; } }; edge e[444444]; vector<edge> g[4444]; int res[4444][4444]; void solve(int f, int v, int p, int c) { res[f][v] = c; for (int i = 0; i < int(g[v].size()); i++) { if (g[v][i].t == p) continue; solve(f, g[v][i].t, v, max(c, g[v][i].c)); } } int main(void) { scanf("%d%d", &n, &m); uni u(n); for (int i = 0; i < m; i++) { scanf("%d%d%d", &e[i].f, &e[i].t, &e[i].c); --e[i].f; --e[i].t; } sort(e, e+m); long long c = 0; for (int i = 0; i < m; i++) { if (u.merge(e[i].f, e[i].t)) { c += e[i].c; g[e[i].f].push_back(edge(e[i].f, e[i].t, e[i].c)); g[e[i].t].push_back(edge(e[i].t, e[i].f, e[i].c)); } } for (int i = 0; i < n; i++) { solve(i, i, -1, 0); } int q; scanf("%d", &q); for (int i = 0; i < q; i++) { int s, t; scanf("%d%d", &s, &t); --s; --t; printf("%lld\n", c-res[s][t]); } return 0; }
a.cc:1:2: error: stray '#' in program 1 | w#include <cstdio> | ^ a.cc:1:1: error: 'w' does not name a type 1 | w#include <cstdio> | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 |
s023014503
p03903
C++
#include <vector> #include <queue> #include <cstdio> using namespace std; typedef long long Weight; struct Edge { int src, dst; Weight weight; Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) { } }; bool operator < (const Edge &e, const Edge &f) { return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!! e.src != f.src ? e.src < f.src : e.dst < f.dst; } typedef vector<Edge> Edges; typedef vector<Edges> Graph; struct UnionFind { vector<int> data; UnionFind(int size) : data(size, -1) { } bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } }; Graph opt; //optimal edges for minimum-spanning vector<vector<int>> max_edge; Weight minimumSpanningForest(const Graph &g) { int n = g.size(); priority_queue<Edge> Q; for(int u=0;u<n;u++) for(auto &e: g[u]) /*if (u < e->dst)*/ Q.push(*e); UnionFind uf(n); Weight total = 0; Edges F; while (F.size() < n-1 && !Q.empty()) { Edge e = Q.top(); Q.pop(); if (uf.unionSet(e.src, e.dst)) { F.push_back(e); total += e.weight; opt[e.src].emplace_back(e.src,e.dst,e.weight); opt[e.dst].emplace_back(e.dst,e.src,e.weight); } } return total; //pair<Weight, Edges>(total, F); } void dfs(int z,int c,long long k,vector<int>&v){ max_edge[z][c]=k; v[c]=1; for(auto &e:opt[c])if(!v[e.dst])dfs(z,e.dst,max(k,e.weight),v); } int main(){ int N,M,Q,a,b,c; scanf("%d%d",&N,&M); opt.resize(N); Weight w; { Graph g(N); for(;M--;){ scanf("%d%d%d",&a,&b,&c); g[a-1].emplace_back(a-1,b-1,c); } w=minimumSpanningForest(g); } max_edge.resize(N); for(int i=0;i<N;i++)max_edge[i].resize(N); for(int i=0;i<N;i++){ vector<int>v(N); dfs(i,i,0,v); } scanf("%d",&Q); for(;Q--;){ scanf("%d%d",&a,&b); printf("%lld\n",w-max_edge[a-1][b-1]); } }
a.cc: In function 'Weight minimumSpanningForest(const Graph&)': a.cc:47:70: error: no match for 'operator*' (operand type is 'const Edge') 47 | for(int u=0;u<n;u++) for(auto &e: g[u]) /*if (u < e->dst)*/ Q.push(*e); | ^~
s350119027
p03903
C++
#include "inspect.hpp" #include <vector> #include <queue> #include <cstdio> using namespace std; #define REP(i,n) for(int i=0;i<(int)n;++i) #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) #define ALL(c) (c).begin(), (c).end() typedef long long Weight; struct Edge { int src, dst; Weight weight; Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) { } }; bool operator < (const Edge &e, const Edge &f) { return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!! e.src != f.src ? e.src < f.src : e.dst < f.dst; } typedef vector<Edge> Edges; typedef vector<Edges> Graph; struct UnionFind { vector<int> data; UnionFind(int size) : data(size, -1) { } bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } }; Graph opt; //optimal edges for minimum-spanning vector<vector<int>> max_edge; Weight minimumSpanningForest(const Graph &g) { int n = g.size(); priority_queue<Edge> Q; REP(u, n) FOR(e, g[u]) /*if (u < e->dst)*/ Q.push(*e); UnionFind uf(n); Weight total = 0; Edges F; while (F.size() < n-1 && !Q.empty()) { Edge e = Q.top(); Q.pop(); if (uf.unionSet(e.src, e.dst)) { F.push_back(e); total += e.weight; opt[e.src].emplace_back(e.src,e.dst,e.weight); opt[e.dst].emplace_back(e.dst,e.src,e.weight); } } return total; //pair<Weight, Edges>(total, F); } void dfs(int z,int c,long long k,vector<int>&v){ max_edge[z][c]=k; v[c]=1; for(auto &e:opt[c])if(!v[e.dst])dfs(z,e.dst,max(k,e.weight),v); } int main(){ int N,M,Q,a,b,c; scanf("%d%d",&N,&M); opt.resize(N); Weight w; { Graph g(N); for(;M--;){ scanf("%d%d%d",&a,&b,&c); g[a-1].emplace_back(a-1,b-1,c); } w=minimumSpanningForest(g); } max_edge.resize(N); for(int i=0;i<N;i++)max_edge[i].resize(N); for(int i=0;i<N;i++){ vector<int>v(N); dfs(i,i,0,v); } scanf("%d",&Q); for(;Q--;){ scanf("%d%d",&a,&b); printf("%lld\n",w-max_edge[a-1][b-1]); } }
a.cc:1:10: fatal error: inspect.hpp: No such file or directory 1 | #include "inspect.hpp" | ^~~~~~~~~~~~~ compilation terminated.
s039637549
p03903
C++
4 6 1 3 5 4 1 10 2 4 6 3 2 2 3 4 5 2 1 3 1 2 3
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 4 6 | ^
s101657597
p03903
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<cstdio> #include<sstream> #include<iomanip> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define mp make_pair #define all(in) in.begin(),in.end() #define shosu(x) fixed<<setprecision(x) using namespace std; //kaewasuretyuui typedef int long long; //typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef pair<int,pii> pip; typedef vector<pip>vip; const double PI=acos(-1); const double EPS=1e-8; const int inf=1e8; struct UnionFind{ vector<int> data; UnionFind(int size) : data(size, -1) {} bool unionSet(int x,int y){ x=root(x);y=root(y); if(x==y)return 0; if(data[y]<data[x])swap(x,y); data[x]+=data[y],data[y]=x; return 1; } bool findSet(int x,int y){ return root(x)==root(y); } int root(int x){ return data[x]<0 ? x : data[x]=root(data[x]); } int size(int x){ return -data[root(x)]; } }; class KRK{//c++11 public: struct edge{ int from,to,cost; }; vector<edge>G,tG; int n; KRK(int size){ n=size; } void add_edge(int a,int b,int c){ edge e={a,b,c}; G.pb(e); } int krk(){ int sum=0; sort(all(G),[](edge a,edge b){ return a.cost<b.cost; }); UnionFind uf(n); rep(i,G.size()){ edge e=G[i]; if(!uf.findSet(e.from,e.to)){ sum+=e.cost; tG.pb(e); uf.unionSet(e.from,e.to); } } return sum; } void solve(){ int out=krk(); // rep(i,tG.size())cout<<tG[i].from<<" "<<tG[i].to<<endl; int ma=0; rep(i,tG.size())ma=max(ma,tG[i].cost); map<pii,int>m; rep(i,tG.size())m[pii(tG[i].to,tG[i].from)]=m[pii(tG[i].from,tG[i].to)]=tG[i].cost; int q; cin>>q; while(q--){ int a,b; cin>>a>>b; a--;b--; if(m[pii(a,b)])cout<<out-m[pii(a,b)]<<endl; else cout<<out-ma<<endl; } } }; signed main(){ int n,m; cin>>n>>m; KRK krk(n); while(m--){ int a,b,c; cin>>a>>b>>c; a--;b--; krk.add_edge(a,b,c); } krk.solve(); }
a.cc:23:18: error: declaration does not declare anything [-fpermissive] 23 | typedef int long long; | ^~~~
s176397395
p03903
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf=1e9; const int64_t inf64=1e18; const double eps=1e-9; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } class union_find{ private: vector<int> parent,rank,gs; int size; public: int count_group; union_find()=default; union_find(int n){ init(n); } void init(int n){ size=n; count_group=n; parent.resize(size); rank.assign(size,0); gs.assign(size,1); for(int i=0; i<size; ++i) parent[i]=i; } int find(int x){ if(parent[x]==x) return x; else return parent[x]=find(parent[x]); } void unite(int x,int y){ x=find(x); y=find(y); if(x==y) return; if(rank[x]<rank[y]){ parent[x]=y; gs[y]+=gs[x]; } else { parent[y]=x; gs[x]+=gs[y]; if(rank[x]==rank[y]) ++rank[x]; } --count_group; } bool is_same_group(int x,int y){ return find(x)==find(y); } int group_size(int x){ return gs[find(x)]; }; }; struct edge{ int from,to,cost; bool operator<(const edge& other)const{ return cost<other.cost; } }; class lca_solver{ public: vector<vector<int>> children; int root; // if root,parent is -1. vector<int> parent; vector<int> depth; vector<vector<int>> parent_pow2; lca_solver(vector<vector<int>> &children_,int root_) : children(children_),root(root_){ calc_parent_and_depth(); calc_parent_pow2(); }; int lca(int u,int v)const{ // make sure depth(u) > depth(v). if(depth[u] < depth[v]) swap(u,v); for(size_t k=0;k<parent_pow2.size();k++){ if(((depth[u] - depth[v]) >> k) & 1){ u = parent_pow2[k][u]; } } if(u == v) return u; for(int k=(int)parent_pow2.size()-1;k>=0;k--){ if(parent_pow2[k][u] != parent_pow2[k][v]){ u = parent_pow2[k][u]; v = parent_pow2[k][v]; } } return parent_pow2[0][u]; } private: void calc_parent_and_depth(){ parent = vector<int>(children.size(),-1); depth = vector<int>(children.size(),-1); sub_calc_parent_and_depth(root,-1,0); } void sub_calc_parent_and_depth(int cur,int par,int dep){ parent[cur] = par; depth[cur] = dep; for(int child : children[cur]){ if(child != par){ sub_calc_parent_and_depth(child,cur,dep+1); } } } void calc_parent_pow2(){ // parent_pow2[k][i] = 2^k parent of node i. parent_pow2 = vector<vector<int>>(ceil(log(children.size())/log(2)+1), vector<int>(children.size(),-1)); parent_pow2[0] = parent; for(size_t k=0;k+1<parent_pow2.size();k++){ for(size_t v=0;v<children.size();v++){ if(parent_pow2[k][v] >= 0){ parent_pow2[k+1][v] = parent_pow2[k][parent_pow2[k][v]]; } } } } }; template<class T> class segtree{ public: int n,size_; vector<T> dat; function<T(T,T)> fun_; T id_; segtree()=default; segtree(int size,function<T(T,T)> fun,T id,T initial_value){ init(size,fun,id,initial_value); } void init(int size,function<T(T,T)> fun,T id,T initial_value){ size_=size; fun_=fun; id_=id; n=1; while(n<size) n*=2; dat.assign(2*n-1,id); for(int i=0; i<size; ++i) update(i,initial_value); } int size()const{ return size_; } void update(int k, T a) { k+=n-1; // leaf dat[k]=a; while(k>0) { k=(k-1)/2; dat[k]=fun_(dat[k*2+1],dat[k*2+2]); } } T at(int index){ return dat[index+n-1]; } void add(int k,T a){ update(k,at(k)+a); } T query(int a,int b) { return query(a,b,0,0,n); } T query(int a,int b,int k,int l,int r) { if(r<=a or b<=l) return id_; if(a<=l and r<=b) return dat[k]; int m=(l+r)/2; return fun_(query(a,b,k*2+1,l,m),query(a,b,k*2+2,m,r)); } }; template<class T> class max_cost_on_path{ public: const int max_pow=20; vector<vector<T>> max_cost; const lca_solver const* ls; max_cost_on_path(const lca_solver &ls_,std::vector<std::unordered_map<int,T>> &cost):ls(&ls_),max_cost(max_pow){ const int n=ls->children.size(); for(int i=0; i<n; ++i) max_cost[i].resize(n); for(int i=0; i<n; ++i){ if(i==ls->root) continue; int j=ls->parent_pow2[0][i]; max_cost[0][i]=cost[i][j]; } for(int i=1; i<max_pow; ++i){ for(int j=0; j<n; ++j){ if(ls->depth[j]-(1<<i)<0) continue; max_cost[i][j]=std::max(max_cost[i-1][j],max_cost[i-1][ls->parent_pow2[i-1][j]]); } } } T sub(int u,int v)const{ T res=0; for(int i=max_pow-1; i>=0; --i){ if(ls->depth[u]-ls->depth[v]>=(1<<i)){ res=max(res,max_cost[i][u]); u=ls->parent_pow2[i][u]; } } return res; } T calc(int u,int v)const{ int lca=ls->lca(u,v); return max(sub(u,lca),sub(v,lca)); } }; void solve(){ int n,m; cin >> n >> m; vector<edge> edges; vector<unordered_map<int,int>> cost(n); rep(i,0,m){ int a,b,c; cin >> a >> b >> c; --a; --b; edges.push_back(edge({a,b,c})); cost[a][b]=cost[b][a]=c; } sort(edges.begin(),edges.end()); union_find uf(n); int64_t sum_cost=0; vector<vector<int>> mst(n); rep(i,0,m){ edge &e=edges[i]; if(uf.is_same_group(e.to,e.from)) continue; uf.unite(e.to,e.from); sum_cost+=e.cost; mst[e.from].push_back(e.to); mst[e.to].push_back(e.from); } int root=0; vector<vector<int>> children(n); function<void(int,int)> dfs=[&](int u,int p){ for(int v:mst[u]){ if(v==p) continue; children[u].push_back(v); dfs(v,u); } }; dfs(root,-1); lca_solver ls(children,root); max_cost_on_path<int> mcop(ls,cost); int q; cin >> q; rep(i,0,q){ int s,t; cin >> s >> t; --s; --t; cout << sum_cost-mcop.calc(s,t) << endl; } } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; }
a.cc:178:22: error: duplicate 'const' 178 | const lca_solver const* ls; | ^~~~~ | -----
s920219659
p03904
C++
#pragma GCC target("avx2,avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <atcoder/all> using namespace atcoder; //using mint = modint998244353; //using mint = modint1000000007; #include <bits/stdc++.h> using namespace std; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //using i128 = __int128_t; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<long long, long long>; #define rep(i, n) for(int i = 0; i < (n); ++i) #define all(x) (x).begin(),(x).end() #define SZ(x) ((int)(x).size()) constexpr char ln = '\n'; template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;} template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;} inline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);} inline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);} inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);} inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);} inline int popcount(int x) {return __builtin_popcount(x);} inline int popcount(long long x) {return __builtin_popcountll(x);} inline int kthbit(long long x, int k) {return (x>>k)&1;} inline void print() {cout << "\n";} template<class T> inline void print(const vector<T> &v) { for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << " "; print(); } template<class T, class... Args> inline void print(const T &x, const Args &... args) { cout << x << " "; print(args...); } #ifdef MINATO_LOCAL #define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl; inline void debug() {cerr << endl;} template<class T> inline void debug(const vector<T> &v) { for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << " "; debug(); } template<class T, class... Args> inline void debug(const T &x, const Args &... args) { cerr << x << " "; debug(args...); } #else #define dump(x) void(0) inline void debug() {} template<class T> inline void debug(const vector<T> &v) {} template<class T, class... Args> inline void debug(const T &x, const Args &... args) {} #endif struct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int main() { int K; cin >> K; string S; cin >> S; int N = S.size(); int p = N/(K+1);//Sを長さがpとP+1の文字列に分ける int q = N%(K+1);//長さがp+1の文字列の個数 auto SA = suffix_array(S); vector<int> SAinv(N); rep(i,N) SAinv[SA[i]] = i; if (q==0) { int MAX = 0; rep(i,N) { if (i%p==0) chmax(MAX,SAinv[i]); } cout << S.substr(SA[MAX],p) << ln; return 0; } auto check=[&](int mid) { vector<int> dp(N+1,-1e9); dp[0] = 0; rep(i,N) { if (N-i >= p) { chmax(dp[i+p],dp[i]); } if (N-i >= p+1) { if (SAinv[i]<=mid) chmax(dp[i+p+1],dp[i]+1); } } return dp[N] >= q; }; int ok = N-1; int ng = -1; while (ok-ng>1) { int mid = (ok+ng)/2; (check(mid) ? ok : ng) = mid; } cout << S.substr(SA[ok],p+1) << ln; }
a.cc:4:10: fatal error: atcoder/all: No such file or directory 4 | #include <atcoder/all> | ^~~~~~~~~~~~~ compilation terminated.
s671675967
p03904
C++
#include <iostream> #include <set> #include <queue> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <cstring> #include <climits> #include <sstream> #include <iomanip> #include <map> #include <stack> #include <numeric> using namespace std; /*-----------------------------------------------------------------------------  定義 -----------------------------------------------------------------------------*/ #define ALL(x) (x).begin(),(x).end() #define REP(i, n) for (int (i) = 0 ; (i) < (ll)(n) ; ++(i)) #define REPN(i, m, n) for (int (i) = m ; (i) < (ll)(n) ; ++(i)) #define INF (int)2e9 #define MOD (1000 * 1000 * 1000 + 7) #define Ceil(x, n) (((((x))+((n)-1))/n)) /* Nの倍数に切り上げ割り算 */ #define CeilN(x, n) (((((x))+((n)-1))/n)*n) /* Nの倍数に切り上げ */ #define FloorN(x, n) ((x)-(x)%(n)) /* Nの倍数に切り下げ */ #define IsOdd(x) (((x)&0x01UL) == 0x01UL) #define IsEven(x) (!IsOdd((x))) #define M_PI 3.14159265358979323846 typedef long long ll; typedef unsigned long ul; typedef unsigned long long ull; typedef pair<int, int> P; /*-----------------------------------------------------------------------------  処理 -----------------------------------------------------------------------------*/ class SuffixArray { public: int m_strLen; string srcStr; vector<int> sa; private: vector<int> rank; int m_i; bool lb_substr(const string &pat, int si = 0, int ti = 0) { int sn = m_strLen; int tn = pat.size(); while (si < sn && ti < tn) { if (srcStr[si] < pat[ti]) return true; if (srcStr[si] > pat[ti]) return false; si++, ti++; } return (si >= sn) && (ti < tn); } public: SuffixArray(const string &s) { srcStr = s; m_strLen = s.size(); /// @param i 元の文字列Sの位置i S[i:] /// @param j 元の文字列Sの位置j S[j:] auto compare_sa = [&](int a, int b) { int rnkA = rank[a]; int rnkB = rank[b]; if (rnkA != rnkB) { return (rnkA < rnkB); } else { int aIdx = a + m_i; int bIdx = b + m_i; a = (aIdx < m_strLen) ? rank[aIdx] : -1; b = (bIdx < m_strLen) ? rank[bIdx] : -1; return a < b; } }; // 最初は1文字 sa.resize(m_strLen + 1); for (int i = 0; i <= m_strLen; i++) { sa[i] = i; } // ランクは文字コード rank.resize(m_strLen + 1); for (int i = 0; i < m_strLen; i++) { rank[i] = s[i]; } rank[m_strLen] = -1; // 空文字 // i文字についてソートされてるところから2*i文字でソートする for (m_i = 1; m_i < m_strLen; m_i *= 2) { sort(sa.begin(), sa.end(), compare_sa); auto nextRank = rank; nextRank[sa[0]] = 0; for (int j = 1; j < m_strLen; j++) { nextRank[sa[j]] = nextRank[sa[j - 1]] + compare_sa(sa[j - 1], sa[j]); } rank = nextRank; } } // 文字列検索 bool contain(const string &contStr) { int contStrLen = contStr.length(); int lb = 0; int lu = m_strLen + 1; int mid = 0; while ((lb + 1) != lu) { mid = (lb + lu) / 2; if (srcStr.compare(sa[mid], contStrLen, contStr) < 0) { lb = mid; } else { lu = mid; } } return (srcStr.compare(sa[lu], contStrLen, contStr) == 0); } /// @param pat 文字列パターン /// @details 1 ~ n 正常(0は空文字) /// @details n + 1 .end() /// @details SA[high:]が下限 int lower_bound(const string &pat) { int low = 0; int high = m_strLen + 1; while (high - low > 1) { int mid = (low + high) / 2; if (lb_substr(pat, sa[mid])) low = mid; else high = mid; } return high; } /// @param pat 文字列パターン /// @details 1 ~ n 正常(0は空文字) /// @details n + 1 .end() /// @details SA[:high)が上限 int upper_bound(string &pat) { int low = 0; int high = m_strLen + 1; pat.back()++; while (high - low > 1) { int mid = (low + high) / 2; if (lb_substr(pat, sa[mid])) low = mid; else high = mid; } pat.back()--; return high; } void dumpSaStr() { int idx = 0; for (auto strIdx : sa) { cout<< idx++ << " " << strIdx << " " << srcStr.substr(strIdx) << endl; } } }; string getMidStr(const string &lowStr, const string &highStr) { string aveStr; REP(i, lowStr.size()) { int aNum = lowStr[i] - '0'; int bNum = highStr[i] - '0'; int sumNum = (aNum + bNum) / 2; aveStr += sumNum + '0'; } if (aveStr == lowStr) { REP(i, aveStr.size()) { if (aveStr[i] != highStr[i]) { aveStr[i] = highStr[i]; break; } } } return aveStr; } bool compExec(SuffixArray &sa, const string &mid, int subStrNum) { vector<int> used(sa.m_strLen, false); int saIdx = sa.lower_bound(mid); int enaCnt = 0; for (int i = saIdx - 1; i >= 0; i--) { int startIdx = sa.sa[i]; int endIdx = mid.size() + startIdx - 1; if (sa.m_strLen <= endIdx) { continue; } bool bRet = true; for (int j = startIdx; j <= endIdx; j++) { if (used[j]) { bRet = false; break; } } if (bRet) { enaCnt++; fill(used.begin() + startIdx, used.begin() + endIdx + 1, true); } } return (subStrNum <= enaCnt); } ### int main() { int K; string S; cin >> K >> S; int subStrLen; int subStrNum; K++; if ((S.size() % K) == 0) { subStrLen = S.size() / K; subStrNum = K; } else { subStrLen = S.size() / K + 1; subStrNum = S.size() % K; } SuffixArray sa(S); sa.dumpSaStr(); string lb(subStrLen, '0'); string lu(subStrLen, '9'); string mid(subStrLen, '0'); while (lb < lu) { mid = getMidStr(lb, lu); if (!compExec(sa, mid, subStrNum)) { lb = mid; } else { lu = mid; } } cout << lu << endl; return 0; }
a.cc:223:1: error: stray '##' in program 223 | ### | ^~ a.cc:223:3: error: stray '#' in program 223 | ### | ^
s679719683
p03904
C++
#include <iostream> #include <set> #include <queue> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <cstring> #include <climits> #include <sstream> #include <iomanip> #include <map> #include <stack> #include <numeric> using namespace std; /*-----------------------------------------------------------------------------  定義 -----------------------------------------------------------------------------*/ #define ALL(x) (x).begin(),(x).end() #define REP(i, n) for (int (i) = 0 ; (i) < (ll)(n) ; ++(i)) #define REPN(i, m, n) for (int (i) = m ; (i) < (ll)(n) ; ++(i)) #define INF (int)2e9 #define MOD (1000 * 1000 * 1000 + 7) #define Ceil(x, n) (((((x))+((n)-1))/n)) /* Nの倍数に切り上げ割り算 */ #define CeilN(x, n) (((((x))+((n)-1))/n)*n) /* Nの倍数に切り上げ */ #define FloorN(x, n) ((x)-(x)%(n)) /* Nの倍数に切り下げ */ #define IsOdd(x) (((x)&0x01UL) == 0x01UL) #define IsEven(x) (!IsOdd((x))) #define M_PI 3.14159265358979323846 typedef long long ll; typedef unsigned long ul; typedef unsigned long long ull; typedef pair<int, int> P; /*-----------------------------------------------------------------------------  処理 -----------------------------------------------------------------------------*/ class SuffixArray { public: int m_strLen; string srcStr; vector<int> sa; private: vector<int> rank; int m_i; bool lb_substr(const string &pat, int si = 0, int ti = 0) { int sn = m_strLen; int tn = pat.size(); while (si < sn && ti < tn) { if (srcStr[si] < pat[ti]) return true; if (srcStr[si] > pat[ti]) return false; si++, ti++; } return (si >= sn) && (ti < tn); } public: SuffixArray(const string &s) { srcStr = s; m_strLen = s.size(); /// @param i 元の文字列Sの位置i S[i:] /// @param j 元の文字列Sの位置j S[j:] auto compare_sa = [&](int a, int b) { int rnkA = rank[a]; int rnkB = rank[b]; if (rnkA != rnkB) { return (rnkA < rnkB); } else { int aIdx = a + m_i; int bIdx = b + m_i; a = (aIdx < m_strLen) ? rank[aIdx] : -1; b = (bIdx < m_strLen) ? rank[bIdx] : -1; return a < b; } }; // 最初は1文字 sa.resize(m_strLen + 1); for (int i = 0; i <= m_strLen; i++) { sa[i] = i; } // ランクは文字コード rank.resize(m_strLen + 1); for (int i = 0; i < m_strLen; i++) { rank[i] = s[i]; } rank[m_strLen] = -1; // 空文字 // i文字についてソートされてるところから2*i文字でソートする for (m_i = 1; m_i < m_strLen; m_i *= 2) { sort(sa.begin(), sa.end(), compare_sa); auto nextRank = rank; nextRank[sa[0]] = 0; for (int j = 1; j < m_strLen; j++) { nextRank[sa[j]] = nextRank[sa[j - 1]] + compare_sa(sa[j - 1], sa[j]); } rank = nextRank; } } // 文字列検索 bool contain(const string &contStr) { int contStrLen = contStr.length(); int lb = 0; int lu = m_strLen + 1; int mid = 0; while ((lb + 1) != lu) { mid = (lb + lu) / 2; if (srcStr.compare(sa[mid], contStrLen, contStr) < 0) { lb = mid; } else { lu = mid; } } return (srcStr.compare(sa[lu], contStrLen, contStr) == 0); } /// @param pat 文字列パターン /// @details 1 ~ n 正常(0は空文字) /// @details n + 1 .end() /// @details SA[high:]が下限 int lower_bound(const string &pat) { int low = 0; int high = m_strLen + 1; while (high - low > 1) { int mid = (low + high) / 2; if (lb_substr(pat, sa[mid])) low = mid; else high = mid; } return high; } /// @param pat 文字列パターン /// @details 1 ~ n 正常(0は空文字) /// @details n + 1 .end() /// @details SA[:high)が上限 int upper_bound(string &pat) { int low = 0; int high = m_strLen + 1; pat.back()++; while (high - low > 1) { int mid = (low + high) / 2; if (lb_substr(pat, sa[mid])) low = mid; else high = mid; } pat.back()--; return high; } }; string getMidStr(const string &a, const string &b) { string aveStr; REP(i, a.size()) { int aNum = a[i] - '0'; int bNum = b[i] - '0'; int sumNum = (aNum + bNum) / 2; aveStr += sumNum + '0'; } return aveStr; } ### bool compExec(SuffixArray &sa, const string &mid, int subStrNum) { vector<int> used(sa.m_strLen, false); int saIdx = sa.lower_bound(mid); int enaCnt = 0; for (int i = saIdx; i >= 0; i--) { int startIdx = sa.sa[i]; int endIdx = min((int)sa.m_strLen, (int)(mid.size() + startIdx)); if ((mid.size() + startIdx) != endIdx) { continue; } bool bRet = true; for (int j = startIdx; j < endIdx; j++) { if (used[j]) { bRet = false; break; } } if (bRet) { enaCnt++; fill(used.begin() + startIdx, used.begin() + endIdx, true); } } return (subStrNum <= enaCnt); } int main() { int K; string S; cin >> K >> S; int subStrLen; int subStrNum; K++; if ((S.size() % K) == 0) { subStrLen = S.size() / K; subStrNum = K; } else { subStrLen = S.size() / K + 1; subStrNum = S.size() % K; } SuffixArray sa(S); string lb(subStrLen, '0'); string lu(subStrLen, '9'); string mid(subStrLen, '0'); while (lb < lu) { mid = getMidStr(lb, lu); if (!compExec(sa, mid, subStrNum)) { lb = mid; } else { lu = mid; } } cout << lu << endl; return 0; }
a.cc:175:1: error: stray '##' in program 175 | ### | ^~ a.cc:175:3: error: stray '#' in program 175 | ### | ^
s244543917
p03904
C++
#include <iostream> #include <set> #include <queue> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <cstring> #include <climits> #include <sstream> #include <iomanip> #include <map> #include <stack> #include <numeric> using namespace std; /*-----------------------------------------------------------------------------  定義 -----------------------------------------------------------------------------*/ #define ALL(x) (x).begin(),(x).end() #define REP(i, n) for (int (i) = 0 ; (i) < (ll)(n) ; ++(i)) #define REPN(i, m, n) for (int (i) = m ; (i) < (ll)(n) ; ++(i)) #define INF (int)2e9 #define MOD (1000 * 1000 * 1000 + 7) #define Ceil(x, n) (((((x))+((n)-1))/n)) /* Nの倍数に切り上げ割り算 */ #define CeilN(x, n) (((((x))+((n)-1))/n)*n) /* Nの倍数に切り上げ */ #define FloorN(x, n) ((x)-(x)%(n)) /* Nの倍数に切り下げ */ #define IsOdd(x) (((x)&0x01UL) == 0x01UL) #define IsEven(x) (!IsOdd((x))) #define M_PI 3.14159265358979323846 typedef long long ll; typedef unsigned long ul; typedef unsigned long long ull; typedef pair<int, int> P; /*-----------------------------------------------------------------------------  処理 -----------------------------------------------------------------------------*/ class SuffixArray { private: int m_strLen; int m_i; string srcStr; vector<int> rank; vector<int> sa; bool lb_substr(const string &pat, int si = 0, int ti = 0) { int sn = m_strLen; int tn = pat.size(); while (si < sn && ti < tn) { if (srcStr[si] < pat[ti]) return true; if (srcStr[si] > pat[ti]) return false; si++, ti++; } return (si >= sn) && (ti < tn); } public: SuffixArray(const string &s) { srcStr = s; m_strLen = s.size(); /// @param i 元の文字列Sの位置i S[i:] /// @param j 元の文字列Sの位置j S[j:] auto compare_sa = [&](int a, int b) { int rnkA = rank[a]; int rnkB = rank[b]; if (rnkA != rnkB) { return (rnkA < rnkB); } else { int aIdx = a + m_i; int bIdx = b + m_i; a = (aIdx < m_strLen) ? rank[aIdx] : -1; b = (bIdx < m_strLen) ? rank[bIdx] : -1; return a < b; } }; // 最初は1文字 sa.resize(m_strLen + 1); for (int i = 0; i <= m_strLen; i++) { sa[i] = i; } // ランクは文字コード rank.resize(m_strLen + 1); for (int i = 0; i < m_strLen; i++) { rank[i] = s[i]; } rank[m_strLen] = -1; // 空文字 // i文字についてソートされてるところから2*i文字でソートする for (m_i = 1; m_i < m_strLen; m_i *= 2) { sort(sa.begin(), sa.end(), compare_sa); auto nextRank = rank; nextRank[sa[0]] = 0; for (int j = 1; j < m_strLen; j++) { nextRank[sa[j]] = nextRank[sa[j - 1]] + compare_sa(sa[j - 1], sa[j]); } rank = nextRank; } } // 文字列検索 bool contain(const string &contStr) { int contStrLen = contStr.length(); int lb = 0; int lu = m_strLen + 1; int mid = 0; while ((lb + 1) != lu) { mid = (lb + lu) / 2; if (srcStr.compare(sa[mid], contStrLen, contStr) < 0) { lb = mid; } else { lu = mid; } } return (srcStr.compare(sa[lu], contStrLen, contStr) == 0); } /// @param pat 文字列パターン /// @details 1 ~ n 正常(0は空文字) /// @details n + 1 .end() /// @details SA[high:]が下限 int lower_bound(const string &pat) { int low = 0; int high = m_strLen + 1; while (high - low > 1) { int mid = (low + high) / 2; if (lb_substr(pat, sa[mid])) low = mid; else high = mid; } return high; } /// @param pat 文字列パターン /// @details 1 ~ n 正常(0は空文字) /// @details n + 1 .end() /// @details SA[:high)が上限 int upper_bound(string &pat) { int low = 0; int high = m_strLen + 1; pat.back()++; while (high - low > 1) { int mid = (low + high) / 2; if (lb_substr(pat, sa[mid])) low = mid; else high = mid; } pat.back()--; return high; } }; string getMidStr(const string &a, const string &b) { string aveStr; REP(i, a.size()) { int aNum = a[i] - '0'; int bNum = b[i] - '0'; int sumNum = (aNum + bNum) / 2; aveStr = sumNum + '0'; } return aveStr; } bool compExec(const SuffixArray &sa, const string &mid) { ### return true; } int main() { int K; string S; cin >> K >> S; int subStrLen; int subStrNum; if ((S.size() % K) == 0) { subStrLen = S.size() / K; subStrNum = K; } else { subStrLen = S.size() / K + 1; subStrNum = S.size() % K; } SuffixArray sa(S); string lb(subStrLen, '0'); string lu(subStrLen, '9'); string mid(subStrLen, '0'); while (lb < lu) { mid = getMidStr(lb, lu); if (!compExec(sa, mid)) { lb = mid; } else { lu = mid; } } cout << lu << endl; return 0; }
a.cc:177:1: error: stray '##' in program 177 | ### | ^~ a.cc:177:3: error: stray '#' in program 177 | ### | ^
s381085522
p03904
C++
#pragma GCC optimize ("O3") #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <queue> #include <set> #include <algorithm> #include <numeric> #include <list> using namespace std; using QWORD = uint64_t; using SQWORD = int64_t; using DWORD = uint32_t; using SDWORD = int32_t; using WORD = uint16_t; using SWORD = int16_t; using BYTE = uint8_t; using SBYTE = int8_t; using DOUBLE = double; using FLOAT = float; #define MIN_SDWORD (-2147483648) #define MAX_SDWORD (2147483647) #define MIN_SBYTE (-128) #define MAX_SBYTE (127) #define MIN_SQWORD (0x8000000000000000) #define MAX_SQWORD (0x7FFFFFFFFFFFFFFF) #define MAX_QWORD (0xFFFFFFFFFFFFFFFF) #define MAX_DWORD (0xFFFFFFFF) #define MAX_WORD (0xFFFF) #define MAX_BYTE (0xFF) #define MAX_DOUBLE (1.0e+308) #define DOUBLE_EPS (1.0e-12) #define MIN_DOUBLE_N (-1.0e+308) #define ArrayLength(a) (sizeof(a) / sizeof(a[0])) static inline DOUBLE MAX(DOUBLE a, DOUBLE b) { return a > b ? a : b; } static inline QWORD MAX(QWORD a, QWORD b) { return a > b ? a : b; } static inline DWORD MAX(DWORD a, DWORD b) { return a > b ? a : b; } static inline SDWORD MAX(SDWORD a, SDWORD b) { return a > b ? a : b; } static inline DOUBLE MIN(DOUBLE a, DOUBLE b) { return a < b ? a : b; } static inline QWORD MIN(QWORD a, QWORD b) { return a < b ? a : b; } static inline DWORD MIN(DWORD a, DWORD b) { return a < b ? a : b; } static inline SDWORD MIN(SDWORD a, SDWORD b) { return a < b ? a : b; } #define BYTE_BITS (8) #define WORD_BITS (16) #define DWORD_BITS (32) #define QWORD_BITS (64) static inline void inputStringSpSeparated(char *pcStr) { char *pcCur = pcStr; for (;;) { char c = getchar(); if (('\n' == c) || (EOF == c) || (' ' == c)) { break; } *pcCur = c; pcCur++; } *pcCur = '\0'; } static inline void inputString(char *pcStr) { char *pcCur = pcStr; for (;;) { char c = getchar(); if (('\n' == c) || (EOF == c)) { break; } *pcCur = c; pcCur++; } *pcCur = '\0'; } static inline SQWORD inputSQWORD(void) { SQWORD sqNumber = 0; SQWORD sqMultiplier = 1; bool bRead = false; for (;;) { char c = getchar(); if (!bRead) { if ('-' == c) { sqMultiplier = -1; } } if (('0' <= c) && (c <= '9')) { sqNumber *= 10LL; sqNumber += (SQWORD)(c - '0'); bRead = true; } else { if (bRead) { return sqNumber * sqMultiplier; } } } } static inline SDWORD inputSDWORD(void) { SDWORD lNumber = 0; SDWORD lMultiplier = 1; bool bRead = false; for (;;) { char c = getchar(); if (!bRead) { if ('-' == c) { lMultiplier = -1; } } if (('0' <= c) && (c <= '9')) { lNumber *= 10; lNumber += (c - '0'); bRead = true; } else { if (bRead) { return lNumber * lMultiplier; } } } } static inline DOUBLE inputFP(void) { DOUBLE dInt = 0.0; DOUBLE dFrac = 0.0; DOUBLE dMultiplier = 1.0; DWORD dwFpCnt = 0; DOUBLE *pdCur = &dInt; bool bRead = false; for (;;) { char c = getchar(); if (!bRead) { if ('-' == c) { dMultiplier = -1; } } if ('.' == c) { pdCur = &dFrac; } else if (('0' <= c) && (c <= '9')) { (*pdCur) *= 10; (*pdCur) += (DOUBLE)(c - '0'); bRead = true; if (pdCur == &dFrac) { dwFpCnt++; } } else { if (bRead) { return dMultiplier * (dInt + dFrac / (pow((DOUBLE)10.0 , (DOUBLE)dwFpCnt))); } } } } /*----------------------------------------------*/ /** * mod による操作ライブラリ */ #define ANS_MOD (1000000007) class MODINT { static SQWORD MOD; SQWORD m_x; public: MODINT(SQWORD val) { m_x = (val % MOD + MOD) % MOD; }; MODINT() { m_x = 0; } static void Init(SQWORD sqMod) { MOD = sqMod; } MODINT& operator+= (const MODINT a) { m_x = (m_x + a.m_x) % MOD; return *this; }; MODINT& operator-= (const MODINT a) { m_x = (m_x - a.m_x + MOD) % MOD; return *this; }; MODINT& operator*= (const MODINT a) { m_x = (m_x * a.m_x) % MOD; return *this; }; MODINT pow(SQWORD t) const { if (!t) return 1; MODINT a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } MODINT operator+ (const MODINT a) const { MODINT res(*this); return (res += a); } MODINT operator- (const MODINT a) const { MODINT res(*this); return (res -= a); } MODINT operator* (const MODINT a) const { MODINT res(*this); return (res *= a); } MODINT operator/ (const MODINT a) const { MODINT res(*this); return (res /= a); } /* 逆元 */ MODINT inv() const { return pow(MOD-2); } /* 除算 */ MODINT& operator/=(const MODINT a) { return (*this) *= a.inv(); } /* 整数版 */ MODINT& operator+= (const SQWORD a) {*this += MODINT(a); return *this;}; MODINT& operator-= (const SQWORD a) {*this -= MODINT(a); return *this;}; MODINT& operator*= (const SQWORD a) {*this *= MODINT(a); return *this;}; MODINT& operator/= (const SQWORD a) {*this /= MODINT(a); return *this;}; SQWORD getVal() { return m_x; }; }; SQWORD MODINT::MOD = ANS_MOD; /*----------------------------------------------*/ struct PARAMS { string strS; SQWORD sqN; SQWORD sqSingleLen; }; static bool compStr( const string &str1, const string &str2) { if (str2.size() < str1.size()) { return true; } for (SQWORD sqIdx = 0; sqIdx < str1.size(); sqIdx++) { if (str2[sqIdx] < str1[sqIdx]) { return true; } if (str2[sqIdx] > str1[sqIdx]) { return false; } } return true; } static string AddStr( const string &str1, const string &str2) { SQWORD sqLen1 = str1.size(); SQWORD sqLen2 = str2.size(); string strRet; SQWORD sqIdx1 = sqLen1 - 1; SQWORD sqIdx2 = sqLen2 - 1; SQWORD sqCarry = 0; while(1) { SQWORD sqNum1; SQWORD sqNum2; if (sqIdx1 < 0) { sqNum1 = 0; } else { sqNum1 = str1[sqIdx1] - '0'; } if (sqIdx2 < 0) { sqNum2 = 0; } else { sqNum2 = str2[sqIdx2] - '0'; } // printf("%lld %lld\n", sqNum1, sqNum2); SQWORD sqNum3 = sqNum1 + sqNum2 + sqCarry; if (10 <= sqNum3) { sqNum3 -= 10; sqCarry = 1; } else { sqCarry = 0; } strRet += (char)(sqNum3 + '0'); sqIdx1--; sqIdx2--; if ((sqIdx1 < 0) && (sqIdx1 < 0) && (0 == sqCarry)) { break; } } reverse(strRet.begin(), strRet.end()); return strRet; } static string DivStrBy2(const string &str) { SQWORD sqPtr = 0; string strRet = ""; SQWORD sqBorrow = 0; while(1) { SQWORD sqNum = (str[sqPtr] - '0') + 10 * sqBorrow; sqBorrow = sqNum % 2; SQWORD sqAns = sqNum / 2; if (0 == sqPtr) { if (0 < sqAns) { strRet += (char)('0' + sqAns); } } else { strRet += (char)('0' + sqAns); } sqPtr++; if (str.size() <= sqPtr) { break; } } return strRet; } bool isConfigurable( string &strJudge, const PARAMS *pstParam) { SQWORD sqStrLen = pstParam->strS.size(); SQWORD sqPtr = 0; SQWORD sqSepCnt = 0; for (;;) { if (sqStrLen <= sqPtr) { if (pstParam->sqN + 1 == sqSepCnt) { return true; } return false; } SQWORD sqLenH = min(pstParam->sqSingleLen + 1LL, (sqStrLen - sqPtr)); string strH = pstParam->strS.substr(sqPtr, sqLenH); if (compStr(strJudge, strH)) { sqPtr += sqLenH; sqSepCnt++; continue; } SQWORD sqLenL = min(pstParam->sqSingleLen, (sqStrLen - sqPtr)); string strL = pstParam->strS.substr(sqPtr, sqLenL).c_str(); if (compStr(strJudge, strL)) { sqPtr += sqLenL; sqSepCnt++; continue; } return false; } } static string binarySearch( bool (*pfJudge)(string&, const PARAMS*), const string &strInitLower, const string &strInitUpper, const PARAMS *pstParam) { string strOk = strInitUpper; string strNg = strInitLower; while (!(AddStr(strNg, "1") == strOk)) { string strMid = DivStrBy2(AddStr(strOk, strNg)); if (pfJudge(strMid, pstParam)) { strOk = strMid; } else { strNg = strMid; } } return strOk; } int main(void) { PARAMS stParam; stParam.sqN = inputSQWORD(); cin >> stParam.strS; SQWORD sqLen = stParam.strS.size(); stParam.sqSingleLen = sqLen / (stParam.sqN + 1); string strAns = binarySearch(isConfigurable, "0", stParam.strS, &stParam); cout << strAns; return 0; }
a.cc:19:16: error: 'uint64_t' does not name a type 19 | using QWORD = uint64_t; | ^~~~~~~~ a.cc:17:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 16 | #include <list> +++ |+#include <cstdint> 17 | using namespace std; a.cc:21:16: error: 'uint32_t' does not name a type 21 | using DWORD = uint32_t; | ^~~~~~~~ a.cc:21:16: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:23:16: error: 'uint16_t' does not name a type 23 | using WORD = uint16_t; | ^~~~~~~~ a.cc:23:16: note: 'uint16_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:25:16: error: 'uint8_t' does not name a type 25 | using BYTE = uint8_t; | ^~~~~~~ a.cc:25:16: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:50:15: error: 'QWORD' does not name a type; did you mean 'SWORD'? 50 | static inline QWORD MAX(QWORD a, QWORD b) { return a > b ? a : b; } | ^~~~~ | SWORD a.cc:51:15: error: 'DWORD' does not name a type; did you mean 'SWORD'? 51 | static inline DWORD MAX(DWORD a, DWORD b) { return a > b ? a : b; } | ^~~~~ | SWORD a.cc:54:15: error: 'QWORD' does not name a type; did you mean 'SWORD'? 54 | static inline QWORD MIN(QWORD a, QWORD b) { return a < b ? a : b; } | ^~~~~ | SWORD a.cc:55:15: error: 'DWORD' does not name a type; did you mean 'SWORD'? 55 | static inline DWORD MIN(DWORD a, DWORD b) { return a < b ? a : b; } | ^~~~~ | SWORD a.cc: In function 'DOUBLE inputFP()': a.cc:146:5: error: 'DWORD' was not declared in this scope; did you mean 'SWORD'? 146 | DWORD dwFpCnt = 0; | ^~~~~ | SWORD a.cc:163:17: error: 'dwFpCnt' was not declared in this scope 163 | dwFpCnt++; | ^~~~~~~ a.cc:167:82: error: 'dwFpCnt' was not declared in this scope 167 | return dMultiplier * (dInt + dFrac / (pow((DOUBLE)10.0 , (DOUBLE)dwFpCnt))); | ^~~~~~~ a.cc: In function 'bool isConfigurable(std::string&, const PARAMS*)': a.cc:373:28: error: no matching function for call to 'min(long long int, SQWORD)' 373 | SQWORD sqLenH = min(pstParam->sqSingleLen + 1LL, (sqStrLen - sqPtr)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:373:28: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'SQWORD' {aka 'long int'}) 373 | SQWORD sqLenH = min(pstParam->sqSingleLen + 1LL, (sqStrLen - sqPtr)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:14: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:373:28: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 373 | SQWORD sqLenH = min(pstParam->sqSingleLen + 1LL, (sqStrLen - sqPtr)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s616226337
p03904
C++
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i) #define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i) #define each(a,b) for(auto& (a): (b)) #define all(v) (v).begin(),(v).end() #define len(v) (int)(v).size() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define cmx(x,y) x=max(x,y) #define cmn(x,y) x=min(x,y) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)<<endl #define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl #define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl #define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl #define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl #define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl #define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl using namespace std; typedef pair<int,int> P; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<double> vd; typedef vector<P> vp; typedef vector<string> vs; const int MAX_N = 100005; class MPI : public vector<int> { private: static constexpr int root = 5; static constexpr int MOD_ = 924844033; bool sign; static void trim_sign(MPI& num){ if(num.isZero()) num.sign = false; } static void trim_digit(MPI& num){ while(num.back() == 0 && (int)num.size() >= 2) num.pop_back(); } bool abs_less(const MPI& a, const MPI& b) const { if(a.size() != b.size()) return a.size() < b.size(); for(int index = (int)a.size() - 1; index >= 0; index--){ if(a[index] != b[index]) return a[index] < b[index]; } return false; } void add(const MPI& a, const MPI& b, MPI& res) const { res = a; int mx = (int)max(a.size(), b.size()); res.resize(mx, 0); int carry = 0; for(int i = 0; i < mx; i++){ int val = res[i] + ((i < (int)b.size()) ? b[i] : 0) + carry; carry = val/10; res[i] = val%10; if(!carry && i >= (int)b.size() - 1) break; } if(carry) res.push_back(1); } void sub(const MPI& a, const MPI& b, MPI& res) const { res = a; int carry = 0; for(int i = 0; i < (int)res.size(); i++){ int val = res[i] - carry - ((i < (int)b.size()) ? b[i] : 0); if(val < 0){ carry = 1, val += 10; }else{ carry = 0; } if(!carry && i >= (int)b.size() - 1) break; res[i] = val; } trim_digit(res), trim_sign(res); } static int add_(const int x, const int y) { return (x + y < MOD_) ? x + y : x + y - MOD_; } static int mul_(const int x, const int y) { return (long long)x * y % MOD_; } static int power(int x, int n){ int res = 1; while(n > 0){ if(n & 1) res = mul_(res, x); x = mul_(x, x); n >>= 1; } return res; } static int inverse(const int x) { return power(x, MOD_ - 2); } static void ntt(vector<int>& a, const bool rev = false){ int i,j,k,s,t,v,w,wn; const int size = (int)a.size(); const int height = (int)log2(2 * size - 1); for(i = 0; i < size; i++){ j = 0; for(k = 0; k < height; k++) j |= (i >> k & 1) << (height - 1 - k); if(i < j) std::swap(a[i], a[j]); } for(i = 1; i < size; i *= 2) { w = power(root, (MOD_ - 1) / (i * 2)); if(rev) w = inverse(w); for(j = 0; j < size; j += i * 2){ wn = 1; for(k = 0; k < i; k++){ s = a[j + k], t = mul_(a[j + k + i], wn); a[j + k] = add_(s, t); a[j + k + i] = add_(s, MOD_ - t); wn = mul_(wn, w); } } } if(rev){ v = inverse(size); for (i = 0; i < size; i++) a[i] = mul_(a[i], v); } } static void mul(const MPI& a, const MPI& b, MPI& res){ const int size = (int)a.size() + (int)b.size() - 1; int t = 1; while (t < size) t <<= 1; vector<int> A(t, 0), B(t, 0); for(int i = 0; i < (int)a.size(); i++) A[i] = a[i]; for(int i = 0; i < (int)b.size(); i++) B[i] = b[i]; ntt(A), ntt(B); for(int i = 0; i < t; i++) A[i] = mul_(A[i], B[i]); ntt(A, true); res.resize(size); int carry = 0; for(int i = 0; i < size; i++){ int val = A[i] + carry; carry = val / 10; res[i] = val % 10; } if(carry) res.push_back(carry); trim_digit(res), trim_sign(res); } bool isZero() const { return (int)size() == 1 && (*this)[0] == 0; } static bool div_geq(const MPI& mod, const MPI& num){ if((int)mod.size() != (int)num.size()) return (int)mod.size() > (int)num.size(); int n = (int)mod.size(); for(int i = 0; i < n; i++){ if(mod[i] != num[n-1-i]){ return mod[i] > num[n-1-i]; } } return true; } void div_(const MPI& a, const MPI& b, MPI& quo, MPI& mod) const { vector<MPI> mult(9); mult[0] = b; for(int i = 0; i < 8; i++) mult[i+1] = mult[i] + b; for(int i = (int)a.size() - 1; i >= 0; i--){ if(mod.isZero()){ mod.back() = a[i]; }else{ mod.push_back(a[i]); } if(div_geq(mod, b)){ int l = 0, r = 9; reverse(mod.begin(), mod.end()); while(r-l>1){ int mid = (l+r)/2; if(mult[mid] > mod){ r = mid; }else{ l = mid; } } mod -= mult[l]; reverse(mod.begin(), mod.end()); quo.push_back(l+1); }else{ quo.push_back(0); } } reverse(quo.begin(), quo.end()); trim_digit(quo); reverse(mod.begin(), mod.end()); } public: MPI() : sign(false){ this->push_back(0); } MPI(long long val) : sign(false){ if(val == 0){ this->push_back(0); }else{ if(val < 0) sign = true, val = -val; while(val){ this->push_back(val%10); val /= 10; } } } MPI(const string& s) : sign(false){ if(s.empty()){ this->push_back(0); return; } if(s[0] == '-') sign = true; for(int i = (int)s.size() - 1; i >= sign; i--) this->push_back(s[i]-'0'); } long long to_ll() const { long long res = 0, dig = 1; for(int i = 0; i < (int)size(); i++){ res += dig * (*this)[i], dig *= 10; } if(sign) res = -res; return res; } string to_string() const { int n = (int)size() + sign; string s(n, ' '); if(sign) s[0] = '-'; for(int i = sign; i < n; i++) s[i] = (char)('0'+(*this)[n-1-i]); return s; } friend istream& operator>>(istream& is, MPI& num) { string s; is >> s; num = MPI(s); return is; } friend ostream& operator<<(ostream& os, const MPI& num) { if(num.sign) os << '-'; for(int i = (int)num.size()-1; i >= 0; i--) os << (char)('0'+num[i]); return os; } MPI& operator=(long long val) { *this = MPI(val); return *this; } bool operator<(const MPI& another) const { if(sign ^ another.sign) return sign; if(size() != another.size()) return (size() < another.size()) ^ sign; for(int index = (int)size() - 1; index >= 0; index--){ if((*this)[index] != another[index]) return ((*this)[index] < another[index]) ^ sign; } return false; } bool operator<(const long long num) const { return *this < MPI(num); } friend bool operator<(const long long num, const MPI& another){ return MPI(num) < another; } bool operator>(const MPI& another) const { return another < *this; } bool operator>(const long long num) const { return *this > MPI(num); } friend bool operator>(const long long num, const MPI& another){ return MPI(num) > another; } bool operator<=(const MPI& another) const { return !(*this > another); } bool operator<=(const long long num) const { return *this <= MPI(num); } friend bool operator<=(const long long num, const MPI& another){ return MPI(num) <= another; } bool operator>=(const MPI& another) const { return !(*this < another); } bool operator>=(const long long num) const { return *this >= MPI(num); } friend bool operator>=(const long long num, const MPI& another){ return MPI(num) >= another; } bool operator==(const MPI& another) const { if(sign ^ another.sign) return false; if(size() != another.size()) return false; for(int index = (int)size() - 1; index >= 0; index--){ if((*this)[index] != another[index]) return false; } return true; } bool operator==(const long long num) const { return *this == MPI(num); } friend bool operator==(const long long num, const MPI& another){ return MPI(num) == another; } bool operator!=(const MPI& another) const { return !(*this == another); } bool operator!=(const long long num) const { return *this != MPI(num); } friend bool operator!=(const long long num, const MPI& another){ return MPI(num) != another; } explicit operator bool() const noexcept { return !isZero(); } bool operator!() const noexcept { return !static_cast<bool>(*this); } explicit operator int() const noexcept { return (int)this->to_ll(); } explicit operator long long() const noexcept { return this->to_ll(); } MPI operator+() const { return *this; } MPI operator-() const { MPI res = *this; res.sign = !sign; return res; } friend MPI abs(const MPI& num){ MPI res = num; res.sign = false; return res; } MPI operator+(const MPI& num) const { MPI res; res.sign = sign; if(sign != num.sign){ if(abs_less(*this, num)){ res.sign = num.sign; sub(num, *this, res); return res; }else{ sub(*this, num, res); return res; } } add(*this, num, res); return res; } MPI operator+(long long num) const { return *this + MPI(num); } friend MPI operator+(long long a, const MPI& b){ return b + a; } MPI& operator+=(const MPI& num){ *this = *this + num; return *this; } MPI& operator+=(long long num){ *this = *this + num; return *this; } MPI& operator++(){ return *this += 1; } MPI operator++(int){ MPI res = *this; *this += 1; return res; } MPI operator-(const MPI& num) const { if(sign != num.sign){ MPI res; res.sign = sign; add(*this, num, res); return res; } MPI res; res.sign = (abs_less(*this, num) ^ sign); if(res.sign){ sub(num, *this, res); }else{ sub(*this, num, res); } return res; } MPI operator-(long long num) const { return *this - MPI(num); } friend MPI operator-(long long a, const MPI& b){ return b - a; } MPI& operator-=(const MPI& num){ *this = *this - num; return *this; } MPI& operator-=(long long num){ *this = *this - num; return *this; } MPI& operator--(){ return *this -= 1; } MPI operator--(int){ MPI res = *this; *this -= 1; return res; } MPI operator*(MPI num) const { MPI res; res.sign = (sign^num.sign); mul(*this, num, res); return res; } MPI operator*(long long num) const { return *this * MPI(num); } friend MPI operator*(long long a, const MPI& b){ return b * a; } MPI& operator*=(const MPI& num){ *this = *this * num; return *this; } MPI& operator*=(long long num){ *this = *this * num; return *this; } MPI operator/(const MPI& num) const { MPI num_ = abs(num); MPI a, b; div_(*this, num_, a, b); a.sign = (sign^num.sign); trim_sign(a); return a; } MPI operator/(long long num) const { return *this / MPI(num); } friend MPI operator/(long long a, const MPI& b){ return b / a; } MPI& operator/=(const MPI& num){ *this = *this / num; return *this; } MPI& operator/=(long long num){ *this = *this / num; return *this; } MPI operator%(const MPI& num) const { MPI num_ = abs(num); MPI a, b; div_(*this, num_, a, b); b.sign = sign; trim_sign(b); return b; } MPI operator%(long long num) const { return *this % MPI(num); } friend MPI operator%(long long a, const MPI& b){ return b % a; } MPI& operator%=(const MPI& num){ *this = *this % num; return *this; } MPI& operator%=(long long num){ *this = *this % num; return *this; } MPI div2() const { MPI res; res.sign = sign; int n = (int)this->size(), carry = 0; for(int i = n-1; i >= 0; i--){ int val = (*this)[i]+carry*10; carry = val%2; if(i != n-1 || val >= 2) res.push_back(val/2); } reverse(res.begin(), res.end()); trim_digit(res); return res; } friend MPI sqrt(const MPI& x){ if(x <= MPI(0)) return MPI(0); MPI s = 1, t = x; while(s < t){ s = s + s, t = t.div2(); } do{ t = s, s = (x / s + s).div2(); }while(s < t); return t; } friend MPI log10(const MPI& x){ assert(x > MPI(0)); return MPI((int)x.size()); } friend MPI pow(MPI a, MPI b){ assert(b >= 0); MPI res(1); while(b){ if(b[0] % 2){ res *= a; } a *= a; b = b.div2(); } return res; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> K; cin >> s; n = len(s); int mx = (n-1) / (K+1) + 1; MPI l(""), r(""); rep(i,mx-1){ l.pb(0), r.pb(0); } l.pb(1), r.pb(0), r.pb(1); l -= 1, r -= 1; while(r - l > 1){ MPI mid = (l+r).div2(); if(possible(mid)){ r = mid; }else{ l = mid; } } cout << r << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:569:12: error: 'K' was not declared in this scope 569 | cin >> K; | ^ a.cc:570:12: error: 's' was not declared in this scope; did you mean 'vs'? 570 | cin >> s; | ^ | vs a.cc:571:5: error: 'n' was not declared in this scope; did you mean 'yn'? 571 | n = len(s); | ^ | yn a.cc:581:12: error: 'possible' was not declared in this scope 581 | if(possible(mid)){ | ^~~~~~~~
s639905768
p03904
C++
#include <bits/stdc++.h> using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) using ll = long long; using P = std::tuple<int,int>; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; std::string S; int K; const std::string INF(100, '9'); std::string bigger(const std::string& a, const std::string& b){ if(a.size() > b.size()){return a;} else if(a.size() < b.size()){return b;} return a > b ? a : b; } std::string smaller(const std::string& a, const std::string& b){ if(a.size() < b.size()){return a;} else if(a.size() > b.size()){return b;} return a < b ? a : b; } std::string solve200(){ int S_size = S.size(); int unitSize = S_size / K; std::function<std::string(int,int,std::string)> loop = [&](int position, int n, std::string mx){ if(position == S_size || n == K){ if(position == S_size && n == K){ return mx; } return INF; } std::string s1 = loop(position + unitSize, n + 1, bigger(mx, S.substr(position, unitSize))), s2 = position + unitSize + 1 > S_size ? INF : loop(position + unitSize + 1, n + 1, bigger(mx, S.substr(position, unitSize + 1))); return smaller(s1, s2); }; return loop(0, 0, ""); } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cin >> K; std::cin >> S; ++K; if(S_size <= 16){ std::cout << solve200() << std::endl; return 0; } std::cout << "-1" << std::endl; }
a.cc: In function 'int main()': a.cc:61:8: error: 'S_size' was not declared in this scope; did you mean 'dysize'? 61 | if(S_size <= 16){ | ^~~~~~ | dysize
s598216501
p03904
C++
##include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> #include <functional> #include <set> #include <ctime> #include <random> #include <chrono> #include <cassert> #include <tuple> #include <utility> using namespace std; namespace { using Integer = long long; //__int128; template<class T, class S> istream& operator >> (istream& is, pair<T,S>& p){return is >> p.first >> p.second;} template<class T> istream& operator >> (istream& is, vector<T>& vec){for(T& val: vec) is >> val; return is;} template<class T> istream& operator , (istream& is, T& val){ return is >> val;} template<class T, class S> ostream& operator << (ostream& os, const pair<T,S>& p){return os << p.first << " " << p.second;} template<class T> ostream& operator << (ostream& os, const vector<T>& vec){for(size_t i=0; i<vec.size(); i++) os << vec[i] << (i==vec.size()-1?"":" "); return os;} template<class T> ostream& operator , (ostream& os, const T& val){ return os << " " << val;} template<class H> void print(const H& head){ cout << head; } template<class H, class ... T> void print(const H& head, const T& ... tail){ cout << head << " "; print(tail...); } template<class ... T> void println(const T& ... values){ print(values...); cout << endl; } template<class H> void eprint(const H& head){ cerr << head; } template<class H, class ... T> void eprint(const H& head, const T& ... tail){ cerr << head << " "; eprint(tail...); } template<class ... T> void eprintln(const T& ... values){ eprint(values...); cerr << endl; } class range{ Integer start_, end_, step_; public: struct range_iterator{ Integer val, step_; range_iterator(Integer v, Integer step) : val(v), step_(step) {} Integer operator * (){return val;} void operator ++ (){val += step_;} bool operator != (range_iterator& x){return step_ > 0 ? val < x.val : val > x.val;} }; range(Integer len) : start_(0), end_(len), step_(1) {} range(Integer start, Integer end) : start_(start), end_(end), step_(1) {} range(Integer start, Integer end, Integer step) : start_(start), end_(end), step_(step) {} range_iterator begin(){ return range_iterator(start_, step_); } range_iterator end(){ return range_iterator( end_, step_); } }; inline string operator "" _s (const char* str, size_t size){ return move(string(str)); } constexpr Integer my_pow(Integer x, Integer k, Integer z=1){return k==0 ? z : k==1 ? z*x : (k&1) ? my_pow(x*x,k>>1,z*x) : my_pow(x*x,k>>1,z);} constexpr Integer my_pow_mod(Integer x, Integer k, Integer M, Integer z=1){return k==0 ? z%M : k==1 ? z*x%M : (k&1) ? my_pow_mod(x*x%M,k>>1,M,z*x%M) : my_pow_mod(x*x%M,k>>1,M,z);} constexpr unsigned long long operator "" _ten (unsigned long long value){ return my_pow(10,value); } inline int k_bit(Integer x, int k){return (x>>k)&1;} //0-indexed mt19937 mt(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()); template<class T> string join(const vector<T>& v, const string& sep){ stringstream ss; for(size_t i=0; i<v.size(); i++){ if(i>0) ss << sep; ss << v[i]; } return ss.str(); } inline string operator * (string s, int k){ string ret; while(k){ if(k&1) ret += s; s += s; k >>= 1; } return ret; } } constexpr long long mod = 9_ten + 7; class SuffixArray{ public: vector<int> sa; vector<int> lcp; vector<int> rank; SuffixArray(const string& SS) : S(SS), len(SS.size()), sa(SS.size()+1), lcp(SS.size()+1), rank(SS.size()+1) { constract_sa(); constract_lcp(); } void dbg_print(){ for(int i=0; i<=len; i++){ cerr << S.substr(sa[i]) << " " << lcp[i] << endl; } } private: const string& S; int len; //Manber & Myers //O(len (logN)^2) void constract_sa(){ //first character for(int i=0; i<=len; i++){ sa[i] = i; rank[i] = (i<len) ? S[i] : -1; } vector<int> tmp(len+1); for(int k=1; k<=len; k *= 2){ auto cmp_func = [&](int x, int y) -> bool{ if(rank[x] != rank[y]) return rank[x] < rank[y]; int l = (x+k <= len) ? rank[x+k] : -1; int r = (y+k <= len) ? rank[y+k] : -1; return l < r; }; sort(sa.begin(), sa.end(), cmp_func); tmp[sa[0]] = 0; for(int i=1; i<=len; i++){ tmp[sa[i]] = tmp[sa[i-1]] + (cmp_func(sa[i-1],sa[i])==true?1:0); } for(int i=0; i<=len; i++){ rank[i] = tmp[i]; } } } void constract_lcp(){ for(int i=0; i<=len; i++) rank[sa[i]] = i; int h=0; lcp[0] = 0; for(int i=0; i<len; i++){ int j=sa[rank[i]-1]; if(h>0) h--; for(; j+h<len && i+h<len; h++){ if(S[j+h] != S[i+h]) break; } lcp[rank[i] - 1] = h; } } }; int main(){ int k; string s; cin >> k,s; if(k==0){ println(s); return 0; } int l = (s.size()+k)/(k+1); //l int t = s.size()%(k+1); //cnt l if(t==0){ vector<string> ss(k+1); for(int i=0; i<ss.size(); i++){ ss[i] = s.substr(i*l, l); } sort(ss.rbegin(), ss.rend()); println(*ss.begin()); return 0; } SuffixArray sa(s); //sa.dbg_print(); vector<pair<int,int>> r; for(int i : range(sa.rank.size()-k)){ r.push_back({sa.rank[i], i}); } sort(r.begin(), r.end()); auto check = [&](int x){ int u = t; int v = k+1-t; for(int i=0; i<s.size();){ if(u && sa.rank[i] <= r[x].first){ i += l; u--; }else{ if(v>0){ v--; i+=l-1; }else{ return false; } } } return true; }; long long lb = -1; long long ub = r.size()-1; while(ub-lb>1){ long long mid = (lb+ub)/2; bool ok = check(mid); (ok? ub : lb) = mid; } println( s.substr(r[ub].second, l) ); return 0; }
a.cc:1:1: error: stray '##' in program 1 | ##include <iostream> | ^~ a.cc:1:3: error: 'include' does not name a type 1 | ##include <iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is
s133188880
p03904
C++
#include <cassert> #include <iostream> #include <string> #include <vector> #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef vector<int> VI; /* * Suffix Array. * Required Headers: algorithm, cassert, string, vector * Verified by: http://arc050.contest.atcoder.jp/submissions/818745 * Reference: http://mayokoex.hatenablog.com/entry/2016/04/03/145845 */ struct compare_sa { const std::vector<int> &rank; int n, k; compare_sa(const std::vector<int> &rank, int n, int k) : rank(rank), n(n), k(k) {} bool operator () (int i, int j) { if (rank[i] != rank[j]) { return rank[i] < rank[j]; } int ri = i + k <= n ? rank[i + k] : -1; int rj = j + k <= n ? rank[j + k] : -1; return ri < rj; } }; std::vector<int> create_sa(const std::string& s) { int n = s.length(); std::vector<int> sa(n + 1, -1); std::vector<int> rank(n + 1, -1); std::vector<int> tmp(n + 1, -1); for (int i = 0; i <= n; ++i) { sa[i] = i; rank[i] = i < n ? s[i] : -1; } for (int k = 1; k <= n; k *= 2) { compare_sa cp = compare_sa(rank, n, k); std::sort(sa.begin(), sa.begin() + n + 1, cp); tmp[sa[0]] = 0; for (int i = 1; i <= n; ++i) { tmp[sa[i]] = tmp[sa[i - 1]] + (cp(sa[i - 1], sa[i]) ? 1 : 0); } for (int i = 0; i <= n; ++i) { rank[i] = tmp[i]; } } return sa; } int main(void){ int k; string s; cin >> k >> s; if (k == 0) { cout << s << endl; return 0; } int n = s.length(); VI sa = create_sa(s); VI sa_inv(n + 1); REP(i, 0, n + 1) { sa_inv[sa[i]] = i; } VI sat; int q = (n + k) / (k + 1); int r = q * (k + 1) - n; // 0 <= r <= k REP(i, 0, sa.size()) { int w = sa[i]; if (w <= n - q) { sat.push_back(w); } } int lo = -1; int hi = n - q + 1; while (hi - lo > 1) { int mid = (hi + lo) / 2; // try to divide, so that all the divided strings <= s[sat[mid]..] // We want to avoid making more than r strings of length q - 1. int rem = r; REP(i, 0, k + 1) { if (rem < 0) { break; } int idx = i * q - r + rem; if (idx >= n - q + 1) { break; } if (sa_inv[idx] > sa_inv[sat[mid]]) { rem--; } } if (rem >= 0) { hi = mid; } else { lo = mid; } } cout << s.substr(sat[hi], q) << endl; }
a.cc: In function 'std::vector<int> create_sa(const std::string&)': a.cc:44:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 44 | std::sort(sa.begin(), sa.begin() + n + 1, cp); | ^~~~ | qsort
s814053255
p03904
C++
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Numerics; namespace PriorityQueue { class Program { static bool ok(string s, int k, BigInteger maxi) { BigInteger sum = 0; foreach (char c in s) { int x = c - '0'; sum = sum * 10 + x; if (sum > maxi) { sum = x; k--; } } return k >= 0 && sum <= maxi; } static void Main() { int k = int.Parse(Console.ReadLine()); string s = Console.ReadLine(); BigInteger left = -1, right = BigInteger.Parse(s); while (left + 1 < right) { var mid = (left + right) / 2; if (ok(s, k, mid)) right = mid; else left = mid; } Console.WriteLine(right); Console.ReadKey(); } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System.Collections.Generic; | ^~~~~~ a.cc:4:7: error: expected nested-name-specifier before 'System' 4 | using System.Diagnostics; | ^~~~~~ a.cc:5:7: error: expected nested-name-specifier before 'System' 5 | using System.Linq; | ^~~~~~ a.cc:6:7: error: expected nested-name-specifier before 'System' 6 | using System.Text; | ^~~~~~ a.cc:7:7: error: expected nested-name-specifier before 'System' 7 | using System.Threading.Tasks; | ^~~~~~ a.cc:8:7: error: expected nested-name-specifier before 'System' 8 | using System.Numerics; | ^~~~~~ a.cc:14:24: error: 'string' has not been declared 14 | static bool ok(string s, int k, BigInteger maxi) | ^~~~~~ a.cc:14:41: error: 'BigInteger' has not been declared 14 | static bool ok(string s, int k, BigInteger maxi) | ^~~~~~~~~~ a.cc:45:6: error: expected ';' after class definition 45 | } | ^ | ; a.cc: In static member function 'static bool PriorityQueue::Program::ok(int, int, int)': a.cc:16:13: error: 'BigInteger' was not declared in this scope 16 | BigInteger sum = 0; | ^~~~~~~~~~ a.cc:17:22: error: expected primary-expression before 'char' 17 | foreach (char c in s) | ^~~~ a.cc:17:13: error: 'foreach' was not declared in this scope 17 | foreach (char c in s) | ^~~~~~~ a.cc:27:30: error: 'sum' was not declared in this scope 27 | return k >= 0 && sum <= maxi; | ^~~ a.cc: In static member function 'static void PriorityQueue::Program::Main()': a.cc:33:21: error: expected primary-expression before 'int' 33 | int k = int.Parse(Console.ReadLine()); | ^~~ a.cc:34:13: error: 'string' was not declared in this scope 34 | string s = Console.ReadLine(); | ^~~~~~ a.cc:35:13: error: 'BigInteger' was not declared in this scope 35 | BigInteger left = -1, right = BigInteger.Parse(s); | ^~~~~~~~~~ a.cc:36:20: error: 'left' was not declared in this scope 36 | while (left + 1 < right) | ^~~~ a.cc:36:31: error: 'right' was not declared in this scope 36 | while (left + 1 < right) | ^~~~~ a.cc:38:17: error: 'var' was not declared in this scope 38 | var mid = (left + right) / 2; | ^~~ a.cc:39:24: error: 's' was not declared in this scope 39 | if (ok(s, k, mid)) right = mid; | ^ a.cc:39:30: error: 'mid' was not declared in this scope 39 | if (ok(s, k, mid)) right = mid; | ^~~ a.cc:42:13: error: 'Console' was not declared in this scope 42 | Console.WriteLine(right); | ^~~~~~~ a.cc:42:31: error: 'right' was not declared in this scope 42 | Console.WriteLine(right); | ^~~~~
s375258598
p03904
C++
#include <cstdio> #include <algorithm> #include <cmath> #include <queue> #include <vector> #include <map> #include <set> using namespace std; typedef pair<int , int> P2; typedef pair<pair<int , int> , int> P3; typedef pair<pair<int , int> , pair<int , int> > P4; #define Fst first #define Snd second #define PB(a) push_back(a) #define MP(a , b) make_pair((a) , (b)) #define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c)) #define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d))) #define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i) #define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i) #define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it) int K; char S[100010]; int dp[2010][2010]; const int INF = 1e9 + 7; int main(){ scanf("%d" , &K); scanf(" %s" , S); int n = 0; while(S[n] != 0) ++n; if(n <= 2){ if(K == 0){ printf("%s\n" , s); } else if(K == 1){ printf("%s\n" , s[0] < s[1] ? s[0] : s[1]); } } else { printf("%s\n" , s); } return 0; }
a.cc: In function 'int main()': a.cc:36:41: error: 's' was not declared in this scope 36 | printf("%s\n" , s); | ^ a.cc:38:41: error: 's' was not declared in this scope 38 | printf("%s\n" , s[0] < s[1] ? s[0] : s[1]); | ^ a.cc:41:33: error: 's' was not declared in this scope 41 | printf("%s\n" , s); | ^
s549759033
p03904
C++
#include <stdio.h> #include <string.h> int ctoi(char c) { switch (c) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; default: return -1; } } char S[5]; int K; int main(){ scanf("%d",&K); scanf("%s",&S); if(K!=0){ if(strlen(S)==2){ if(ctoi(S[0])>=ctoi(S[1])){printf("%d¥n",ctoi(S[0]));} else{printf("%d¥n",ctoi(S[1]));} } else{printf("%d¥n",ctoi(S[0]));} } else{printf("%d¥n",atoi(S));} return 0; }
a.cc: In function 'int main()': a.cc:35:20: error: 'atoi' was not declared in this scope; did you mean 'ctoi'? 35 | else{printf("%d¥n",atoi(S));} | ^~~~ | ctoi
s535828800
p03904
C++
#include <stdio.h> int ctoi(char c) { switch (c) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; default: return -1; } } char S[5]; int K; int main(){ scanf("%d",&K); scanf("%s",&S); if(K!=0){ if(strlen(S)==2){ if(ctoi(S[0])>=ctoi(S[1])){printf("%d¥n",ctoi(S[0]));} else{printf("%d¥n",ctoi(S[1]));} } else{printf("%d¥n",ctoi(S[0]));} } else{printf("%d¥n",atoi(S));} return 0; }
a.cc: In function 'int main()': a.cc:27:4: error: 'strlen' was not declared in this scope 27 | if(strlen(S)==2){ | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <stdio.h> +++ |+#include <cstring> 2 | a.cc:34:20: error: 'atoi' was not declared in this scope; did you mean 'ctoi'? 34 | else{printf("%d¥n",atoi(S));} | ^~~~ | ctoi
s402194110
p03904
C++
#include <stdio.h> int ctoi(char c) { switch (c) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; default: return -1; } } char S[5]; int K; int main(){ scanf("%d",&K) scanf("%s",&S); if(K!=0){ if(strlen(S)==2){ if(ctoi(S[0])>=ctoi(S[1])){printf("%d¥n",ctoi(S[0]));} else{printf("%d¥n",ctoi(S[1]));} } else{printf("%d¥n",ctoi(S[0]));} } else{printf("%d¥n",atoi(S));} return 0; }
a.cc: In function 'int main()': a.cc:23:15: error: expected ';' before 'scanf' 23 | scanf("%d",&K) | ^ | ; 24 | scanf("%s",&S); | ~~~~~ a.cc:27:4: error: 'strlen' was not declared in this scope 27 | if(strlen(S)==2){ | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <stdio.h> +++ |+#include <cstring> 2 | a.cc:34:20: error: 'atoi' was not declared in this scope; did you mean 'ctoi'? 34 | else{printf("%d¥n",atoi(S));} | ^~~~ | ctoi
s722155038
p03905
C++
#include<bits/stdc++.h> using namespace std; const int maxn=100005; struct SHIT { int one,two; bool operator<(const SHIT &b)const { if(this->one!=b.one) return (this->one<b.one); return (this->two<b.two); } }shit[maxn]; bool cmp(SHIT a,SHIT b) { if(a.one+a.two!=b.one+b.two) return a.one+a.two<b.one+b.two; return a.one<b.one; } map<SHIT,bool>mp; int main() { int n; mp.clear(); scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d%d",&shit[i].one,&shit[i].two); mp[shit[i]]=1; } if(!(shit[1].one==shit[2].two&&shit[1].two==shit[2].one&&shit[1].one==0&&shit[1].two!=0)){ puts("-1"); return 0; } int mn=shit[1].two; int ans=2*n-2; for(int i=3;i<=n;i++) { if(shit[i].one==0||shit[i].two==0||shit[i].one+shit[i].two<mn){ puts("-1"); return 0; } } sort(shit+1,shit+n+1,cmp); for(int i=1,j;i<=n;i=j) { j=i+1; while(j<=n&&shit[j].one+shit[j].two==shit[i].one+shit[i].two) j++; for(int k=i;k<j;k++) mp[shit[k]]=1; int last=0,left=0; for(int k=i,tk;k<j;k=tk) { tk=k+1; while(tk<j&&shit[tk].one==shit[k].one){ tk++; } int now=tk-k; bool one=0,two=0; SHIT tmp1,tmp2; tmp1.one=shit[k].one-1; tmp1.two=shit[k].two-1; if(mp.count(tmp1)){ ans-=now; now=min(now,left); ast=shit[k].one; left=now; continue; one=1;two=1; } tmp1.one=shit[k].one-1; tmp1.two=shit[k].two+1; tmp2.one=shit[k].one+1; tmp2.two=shit[k].two-1; one=one|mp.count(tmp1); two=two|mp.count(tmp2); tmp1.two--; tmp2.one--; one=one|mp.count(tmp1); two=two|mp.count(tmp2); if(shit[k].one==0)one=1; if(shit[k].two==0) two=1; if(one==0||two==0){ puts("-1"); return 0; } int del=0; if(last+1==shit[k].one){ del=min(now,left); ans-=del; } tmp1.two--; last=shit[k].one; left=now; } } printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:65:17: error: 'ast' was not declared in this scope; did you mean 'last'? 65 | ast=shit[k].one; | ^~~ | last
s899976147
p03905
C++
#include <bits/stdc++.h> #define xx first #define yy second #define mp make_pair #define pb push_back #define fill( x, y ) memset( x, y, sizeof x ) #define copy( x, y ) memcpy( x, y, sizeof x ) using namespace std; typedef long long LL; typedef pair < int, int > pa; inline int read() { int sc = 0, f = 1; char ch = getchar(); while( ch < '0' || ch > '9' ) { if( ch == '-' ) f = -1; ch = getchar(); } while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar(); return sc * f; } const int MAXN = 100005; int n, a[MAXN], b[MAXN]; map < pa, bool > cnt; pa c[MAXN]; inline void GG() { puts( "-1" ); exit( 0 ); } int main() { #ifdef wxh010910 freopen( "data.in", "r", stdin ); #endif n = read(); for( int i = 1 ; i <= n ; i++ ) { a[ i ] = read(), b[ i ] = read(), c[ i ] = mp( a[ i ] + b[ i ], b[ i ] ); if( !a[ i ] && i != 1 ) GG(); if( !b[ i ] && i != 2 ) GG(); cnt[ mp( a[ i ], b[ i ] ) ] = 1; } if( a[ 1 ] || b[ 2 ] ) GG(); sort( c + 1, c + n + 1 ); int ret = n - 1 << 1; for( int l = 1, r = 1 ; l <= n ; l = r ) { while( r <= n && c[ r ].xx == c[ l ].xx ) { int x = c[ r ].xx - c[ r ].yy, y = c[ r ].yy; if( x ) { bool flag = false; for( int d = -1 ; d <= 1 ; d++ ) if( cnt.find( mp( x - 1, y + d ) ) != cnt.end() ) flag = true; if( !flag ) GG(); } if( y ) { bool flag = false; for( int d = -1 ; d <= 1 ; d++ ) if( cnt.find( mp( x + d, y - 1 ) ) != cnt.end() ) flag = true; if( !flag ) GG(); } r++; } for( int i = l, j = l, last = 0, left = 0 ; i < r ; i = j ) { while( j < r && c[ j ].yy == c[ i ].yy ) j++; int now = j - i, del = 0; if( cnt.find( mp( c[ i ].xx - c[ i ].yy - 1, c[ i ].yy - 1 ) ) != cnt.end() ) ret -= now, last=c[i].yy,left=min(now,left),continue;; if( c[ i ].yy == last + 1 ) del = min( now, left ), ret -= del; last = c[ i ].yy; left = now; } } return printf( "%d\n", ret ), 0; }
a.cc: In function 'int main()': a.cc:69:147: error: expected primary-expression before 'continue' 69 | if( cnt.find( mp( c[ i ].xx - c[ i ].yy - 1, c[ i ].yy - 1 ) ) != cnt.end() ) ret -= now, last=c[i].yy,left=min(now,left),continue;; | ^~~~~~~~
s558620935
p03905
C++
#include<bits/stdc++.h> using namespace std; const int maxn=100005; struct SHIT { int one,two; bool operator<(const SHIT &b)const { if(this->one!=b.one) return (this->one<b.one); return (this->two<b.two); } }shit[maxn]; bool cmp(SHIT a,SHIT b) { if(a.one+a.two!=b.one+b.two) return a.one+a.two<b.one+b.two; return a.one<b.one; } map<SHIT,bool>mp; int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d%d",&shit[i].one,&shit[i].two); } if(!(shit[1].one==shit[2].two&&shit[1].one==0&&shit[1].two!=0)){ puts("-1"); return 0; } int mn=shit[1].two; int ans=0; if(mn==1) ans++; if(n==2){ if(mn==1){ puts("1"); } else{ puts("-1"); } return 0; } for(int i=3;i<=n;i++) { if(shit[i].one==0||shit[i].two==0||shit[i].one+shit[i].two<mn){ puts("-1"); return 0; } } sort(shit+3,shit+n+1,cmp); mp.clear(); mp[shit[1]]=1; mp[shit[2]]=1; for(int i=3;i<=n;) { int j=i+1; while(j<=n&&shit[j].one+shit[j].two==shit[i].one+shit[i].two) j++; for(int k=i;k<j;k++) mp[shit[k]]=1; if(shit[i].one+shit[i].two==mn){ for(int k=i;k<j;k++) { SHIT tmp1,tmp2; tmp1.one=shit[k].one-1; tmp1.two=shit[k].two+1; tmp2.one=shit[k].one+1; tmp2.two=shit[k].two-1; //printf("%d %d\n",mp.count(tmp1),mp.count(tmp2)); if(mp.count(tmp1)&&mp.count(tmp2)){ continue; } else{ puts("-1"); return 0; } } ans=ans+(j-i-mn+1)*2+mn; } else{ for(int k=i;k<j;k++) { SHIT tmp1,tmp2; tmp1.one=shit[k].one-1; tmp1.two=shit[k].two-1; if(mp.count(tmp1)){ ans++; continue; } if(shit[k].one==shit[k-1].one&&shit[k].two==shit[k-1].two){ ans+=2; continue; } bool one=0,two=0; tmp1.one=shit[k].one-1; tmp1.two=shit[k].two+1; tmp2.one=shit[k].one+1; tmp2.two=shit[k].two-1; if(mp.count(tmp1)&&mp.count(tmp2)&&tmp1.one==shit[k-1].one&&tmp1.two=shit[k-1].two){ ans=ans+1; continue; } one=one|mp.count(tmp1); tmp1.two--; one=one|mp.count(tmp1); two=two|mp.count(tmp2); tmp2.one--; two=two|mp.count(tmp2); if(one&&two){ ans+=2;continue; } puts("-1"); return 0; } } i=j; } printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:101:75: error: lvalue required as left operand of assignment 101 | if(mp.count(tmp1)&&mp.count(tmp2)&&tmp1.one==shit[k-1].one&&tmp1.two=shit[k-1].two){ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
s880905463
p03907
C++
#include <vector> #include <cstdio> #include <algorithm> #include <map> using namespace std; int main() { int N; scanf("%d", &N); vector<pair<int, int> > A; for(int i=0; i<N; ++i) { int a, b; scanf("%d%d", &a, &b); A.emplace_back(a, b); } if(A[0].first!=0 || A[1].second!=0 || A[1].first!=A[0].second) { printf("-1\n"); return 0; } int ab = A[0].second; int sum = ab; { vector<int> vec(ab+1); for(auto & p : A) { if(p.first+p.second==ab) { ++vec[p.first]; } if(p.first+p.second<ab) { printf("-1\n"); return 0; } } if(vec[0]!=1 || vec[ab]!=1) { printf("-1\n"); return 0; } for(int i : vec) { if(i==0) { printf("-1\n"); return 0; } if(2<=i) { sum += (i-1)*2; } } } { vector<pair<int, int> > vec; vector<pair<int, int> > vec2; for(auto & p : A) { if(ab<p.first+p.second) { int aa = p.first+p.second - ab; int aaHalf = (aa+1)>>1; int aaa = p.first-aaHalf; if(aa&1) { vec2.emplace_back(p.first-aaHalf, aaHalf); ++sum; } else { vec.emplace_back(p.first-aaHalf, aaHalf); ++sum; } } } sort(vec.begin(), vec.end()); sort(vec2.begin(), vec2.end()); { int beforeF = -1; int beforeS = 0; for(auto & p : vec) { if(p.first!=beforeF) { beforeF = p.first; beforeS = 0; } if(p.second!=beforeS && p.second!=beforeS+1) { printf("-1\n"); return 0; } beforeS = p.second; } } { int beforeF = -10; int beforeS = 0; for(auto & p : vec2) { if(p.first!=beforeF) { if(s.first!=beforeF+1) { ++sum; } beforeF = p.first; beforeS = 0; } if(p.second!=beforeS && p.second!=beforeS+1) { printf("-1\n"); return 0; } beforeS = p.second; } } } printf("%d\n", sum); return 0; }
a.cc: In function 'int main()': a.cc:88:44: error: 's' was not declared in this scope 88 | if(s.first!=beforeF+1) { | ^
s136986357
p03907
C++
#include <stdio.h> #include <string.h> #include <algorithm> long long int N; char A[1000000000000]; int f[12], ans = 0; int ctoi(char c) { switch (c) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; default: return -1; } } int main(void) { scanf("%lld", &N); int cou = 0; for (int i = 0; i < N; ++i) { scanf("%s", &A); for (int j = strlen(A) - 1; j >= 0; --j) { f[cou] = std::max(f[cou], ctoi(A[j])); ++cou; } } for (int i = 0; i < cou; ++i) { ans += f[i]; } printf("%d\n", ans); return 0; }
/tmp/ccjY87ua.o: in function `main': a.cc:(.text+0x11f): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccjY87ua.o a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccjY87ua.o a.cc:(.text+0x190): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccjY87ua.o a.cc:(.text+0x199): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccjY87ua.o a.cc:(.text+0x1a1): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccjY87ua.o a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccjY87ua.o collect2: error: ld returned 1 exit status
s610159156
p03907
C++
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N; int A[101010],B[101010]; int L; int did[101010]; int ok[101010]; set<pair<int,int>> S; void solve() { int i,j,k,l,r,x,y; string s; cin>>N; FOR(i,N) cin>>A[i]>>B[i]; if(A[0]!=0) return _P("-1\n"); if(B[1]!=0) return _P("-1\n"); if(A[1]!=B[0]) return _P("-1\n"); L=A[1]; ok[0]=ok[L]=1; did[0]=did[1]=1; S.insert({0,L}); S.insert({L,0}); vector<pair<int,int>> V; int ret=1; for(i=2;i<N;i++) { if(A[i]==0 || B[i]==0) return _P("-1\n"); if(A[i]+B[i]<L) return _P("-1\n"); if(A[i]+B[i]==L) { did[i]=1; if(ok[A[i]]==1) ret++; ok[A[i]]=1; ret++; S.insert({A[i],B[i]}); } else { V.push_back({A[i]+B[i],i}); } } FOR(i,L+1) if(ok[i]==0) return _P("-1\n"); sort(ALL(V)); FORR(r,V) { x = r.second; if(S.count({A[x]-1,B[x]-1})) { ret++; } else if(S.count({A[x]-1,B[x]}) && S.count({A[x],B[x]-1})) { ret+=2; } else { return _P("-1\n"); } S.insert({A[x],B[x]}); } aseert(0); _P("%d\n",ret); } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:69:9: error: 'aseert' was not declared in this scope; did you mean 'assert'? 69 | aseert(0); | ^~~~~~ | assert