submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s575390051 | p03652 | C++ | #include <bits/stdc++.h>
using namespace std;
const int N=505;
int n,m;
int a[N][N],num[N];
bool vis[N];
void work()
{
int ans=n;
for(int _=1;_<=m;_++){
memset(cnt,0,sizeof(cnt));
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
if(vis[a[i][j]]) num[a[i][j]]++;
break;
}
int mx=0,id=0;
for(int i=1;i<=m;i++) if(num[i]>=mx) mx=num[i],id=i;
ans=min(ans,mx);
vis[id]=0;
}
cout<<ans<<endl;
}
void init()
{
cin>>n>>m;
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>a[i][j];
for(int i=1;i<=m;i++) vis[i]=1;
}
int main()
{
init();
work();
return 0;
}
| a.cc: In function 'void work()':
a.cc:14:24: error: 'cnt' was not declared in this scope; did you mean 'int'?
14 | memset(cnt,0,sizeof(cnt));
| ^~~
| int
|
s615093766 | p03652 | C++ | #include<bits/stdc++.h>
#define ll long long
#define FOr(i,x,y) for(ll i=x;i>=y;--i)
#define For(i,x,y) for(ll i=x;i<=y;++i)
using namespace std;
namespace SHENZHEBEI{
#ifdef LOCAL
struct szb{ szb(){ freopen("shenzhebei.in","r",stdin); } }shenzhebei;
#endif
#define NEG 1
const int L=2333333;
char SZB[L],*S=SZB,*T=SZB;
inline char gc(){ if (S==T){ T=(S=SZB)+fread(SZB,1,L,stdin); if (S==T) return '\n'; } return *S++; }
#if NEG
inline ll readint(){ ll x=0,f=1; char ch=gc(); for (;!isdigit(ch);ch=gc()) if (ch=='-') f=-1; for (;isdigit(ch);ch=gc()) x=x*10-48+ch; return x*f; }
inline void write(ll x){ if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10); putchar(x%10+'0'); }
#else
inline ll readint(){ ll x=0; char ch=gc(); for (;!isdigit(ch);ch=gc()); for (;isdigit(ch);ch=gc()) x=x*10-48+ch; return x; }
inline void write(ll x){ if (x>=10) write(x/10); putchar(x%10+'0'); }
#endif
inline char readchar(){ char ch=gc(); for(;isspace(ch);ch=gc()); return ch; }
inline ll readstr(char *s){ char ch=gc(); int cur=0; for(;isspace(ch);ch=gc()); for(;!isspace(ch);ch=gc()) s[cur++]=ch; s[cur]='\0'; return cur; }
inline void writeln(ll x){ write(x); puts(""); }
}using namespace SHENZHEBEI;
const ll N=310;
ll a[N][N],del[N],is[N],sum[N],n,m;
bool calc(ll x){
memset(vis,0,sizeof vis);
memset(sum,0,sizeof sum);
memset(del,0,sizeof del);
For(j,1,m){
For(i,1,n) if (!vis[i]&&!del[a[i][j]]) ++sum[vis[i]=a[i][j]];
For(i,1,m) if (sum[i]>x) sum[i]=0,del[i]=1;
For(i,1,n) if (sum[vis[i]]==0) vis[i]=0;
}
For(i,1,n) if (!vis[i]) return 0;
return 1;
}
int main(){
n=readint(); m=readint();
For(i,1,n) For(j,1,m) a[i][m-readint()+1]=j;
ll l=0,r=n,ans=n;
while(l<=r){
ll mid=(l+r)>>1;
if (calc(mid)) r=mid-1,ans=mid;
else l=mid+1;
}writeln(ans);
} | a.cc: In function 'bool calc(long long int)':
a.cc:28:16: error: 'vis' was not declared in this scope; did you mean 'is'?
28 | memset(vis,0,sizeof vis);
| ^~~
| is
|
s462022297 | p03652 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
using namespace std;
using ll = long long;
int main() {
int n, m, ans = 1e9, p , cnt;
int a[310][310] = { 0 };
int sum[310] = { 0 };
bool jud[310][310] = { false };
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
jud[i][j] = true;
}
}
for (int k = 1; k <= n; k++) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (jud[i][j] == true) {
sum[a[i][j]]++; // 数え上げ
break;
}
}
}
p = 0;
for (int i = 1; i <= m; i++) {
if (p < sum[i]) {
p = sum[i];
cnt = i;
}
}
memset(sum, 0, sizeof(sum));
ans = min(p, ans);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == cnt) {
jud[i][j] = false;
break;
}
}
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:49:17: error: 'memset' was not declared in this scope
49 | memset(sum, 0, sizeof(sum));
| ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
10 | #include <stack>
+++ |+#include <cstring>
11 |
|
s559125033 | p03652 | C++ | 3 3
2 1 3
2 1 3
2 1 3 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 3 3
| ^
|
s136915359 | p03652 | Java | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
TaskB solver = new TaskB();
solver.solve(1, in, out);
out.close();
}
static class TaskB {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n = in.nextInt();
int m = in.nextInt();
int[][] a = new int[n][m];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
a[i][j] = in.nextInt() - 1;
}
}
boolean[] used = new boolean[m];
Arrays.fill(used, true);
int ans = n;
for (int step = 0; step < m; ++step) {
int[] cnt = new int[m];
for (int i = 0; i < n; ++i) {
int pos = 0;
while (pos < m && !used[a[i][pos]]) {
pos++;
}
if (pos == m) {
throw new RuntimeException();
}
cnt[a[i][pos]]++;
}
int pos = 0;
for (int i = 1; i < m; ++i) {
if (cnt[i] > cnt[pos]) {
pos = i;
}
}
ans = Math.min(ans, cnt[pos]);
used[pos] = false;
}
out.println(ans);
}
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
if (numChars == -1)
throw new UnknownError();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new UnknownError();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public int nextInt() {
return Integer.parseInt(next());
}
public String next() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuffer res = new StringBuffer();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
| Main.java:104: error: reached end of file while parsing
}
^
1 error
|
s113733873 | p03652 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <stack>
#include <queue>
using namespace std;
int main()
{
int N, M;
cin >> N >> M;
int** arr = new int*[N];
for (int i = 0; i < N; i++)
{
arr[i] = new int[M];
for (int j = 0; j < M; j++)
{
int tmp;
cin >> tmp;
arr[i][j] = tmp;
}
}
//init point
int* point = new int[N];
bool* deleted = new bool[N];
for (int i = 0; i < N; i++)
{
point[i] = 0;
deleted[i] = true;
}
//compute
int min_people = 0x0fffffff;
for (int i = 0; i < M; i++)
{
vector<int> people(M, 0);
int max_people = -1;
int max_event = -1;
for (int j = 0; j < N; j++)
{
while (!deleted[arr[j][point[j]]-1])
point[j]++;
if (max_people < ++people[arr[j][point[j]] - 1])
{
max_people = people[arr[j][point[j]] - 1];
max_event = arr[j][point[j]] - 1;
}
}
min_people = min(min_people, max_people);
deleted[max_event] = false;
}
cout << min_people << endl;
} | a.cc:27:1: error: extended character is not valid in an identifier
27 |
| ^
a.cc:36:1: error: extended character is not valid in an identifier
36 |
| ^
a.cc:39:1: error: extended character is not valid in an identifier
39 |
| ^
a.cc:58:1: error: extended character is not valid in an identifier
58 |
| ^
a.cc: In function 'int main()':
a.cc:27:1: error: '\U000000a0' was not declared in this scope
27 |
| ^
a.cc:33:17: error: 'point' was not declared in this scope
33 | point[i] = 0;
| ^~~~~
a.cc:36:2: error: expected ';' before 'int'
36 |
| ^
| ;
37 | //compute
38 | int min_people = 0x0fffffff;
| ~~~
a.cc:39:2: error: expected ';' before 'for'
39 |
| ^
| ;
40 | for (int i = 0; i < M; i++)
| ~~~
a.cc:40:25: error: 'i' was not declared in this scope
40 | for (int i = 0; i < M; i++)
| ^
a.cc:58:2: error: expected ';' before 'cout'
58 |
| ^
| ;
59 | cout << min_people << endl;
| ~~~~
|
s319490494 | p03652 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <stack>
#include <queue>
using namespace std;
int main()
{
int N, M;
cin >> N >> M;
int** arr = new int*[N];
for (int i = 0; i < N; i++)
{
arr[i] = new int[M];
for (int j = 0; j < M; j++)
{
int tmp;
cin >> tmp;
arr[i][j] = tmp;
}
}
//init point
int* point = new int[N];
bool* deleted = new bool[N];
for (int i = 0; i < N; i++)
{
point[i] = 0;
deleted[i] = true;
}
//compute
int min_people = 0x0fffffff;
for (int i = 0; i < M; i++)
{
vector<int> people(M, 0);
int max_people = -1;
int max_event = -1;
for (int j = 0; j < N; j++)
{
while (!deleted[arr[j][point[j]]-1])
point[j]++;
if (max_people < ++people[arr[j][point[j]] - 1])
{
max_people = people[arr[j][point[j]] - 1];
max_event = arr[j][point[j]] - 1;
}
}
min_people = min(min_people, max_people);
deleted[max_event] = false;
}
cout << min_people << endl;
} | a.cc:12:1: error: extended character is not valid in an identifier
12 |
| ^
a.cc:28:1: error: extended character is not valid in an identifier
28 |
| ^
a.cc:37:1: error: extended character is not valid in an identifier
37 |
| ^
a.cc:40:1: error: extended character is not valid in an identifier
40 |
| ^
a.cc:59:1: error: extended character is not valid in an identifier
59 |
| ^
a.cc:12:1: error: '\U000000a0' does not name a type
12 |
| ^
|
s174706629 | p03652 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#define SIZE 305
using namespace std;
bool vi[SIZE];
int cnt[SIZE];
int a[SIZE][SIZE];
int main()
{
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j];
int ans = n;
for (int i = 1; i <= m; i++) {
memset(cnt, 0, sizeof(cnt));
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= m; k++) {
if (!vi[a[j][k]]) {
cnt[a[j][k]]++;
break;
}
}
}
int index = -1;
int n_max = -1;
for (int j = 1; j <= m; j++) {
if (cnt[j] > n_max) {
n_max = cnt[j];
index = j;
}
}
ans = min(ans, n_max);
vi[index] = true;
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:18:17: error: 'memset' was not declared in this scope
18 | memset(cnt, 0, sizeof(cnt));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <vector>
+++ |+#include <cstring>
4 | #define SIZE 305
|
s901689801 | p03652 | C++ | #include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
#define ZERO(a) memset(a,0,sizeof(a))
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
#define exists find_if
#define forall all_of
using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double; using vld = vector<ld>;
using vi = vector<int>; using vvi = vector<vi>; vll conv(vi& v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; }
using Pos = complex<double>;
template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args>
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; o << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]"; return o; }
template <typename T> ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; }
template <typename T, typename U> ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; }
template <typename T, typename U, typename V> ostream &operator<<(ostream &o, const unordered_map<T, U, V> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]"; return o; }
vector<int> range(const int x, const int y) { vector<int> v(y - x + 1); iota(v.begin(), v.end(), x); return v; }
template <typename T> istream& operator>>(istream& i, vector<T>& o) { rep(j, o.size()) i >> o[j]; return i;}
string bits_to_string(ll input, ll n=64) { string s; rep(i, n) s += '0' + !!(input & (1ll << i)); reverse(all(s)); return s; }
template <typename T> unordered_map<T, ll> counter(vector<T> vec){unordered_map<T, ll> ret; for (auto&& x : vec) ret[x]++; return ret;};
string substr(string s, P x) {return s.substr(x.fi, x.se - x.fi); }
struct ci : public iterator<forward_iterator_tag, ll> { ll n; ci(const ll n) : n(n) { } bool operator==(const ci& x) { return n == x.n; } bool operator!=(const ci& x) { return !(*this == x); } ci &operator++() { n++; return *this; } ll operator*() const { return n; } };
size_t random_seed; namespace std { using argument_type = P; template<> struct hash<argument_type> { size_t operator()(argument_type const& x) const { size_t seed = random_seed; seed ^= hash<ll>{}(x.fi); seed ^= (hash<ll>{}(x.se) << 1); return seed; } }; }; // hash for various class
namespace myhash{ const int Bsizes[]={3,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81}; const int xor_nums[]={0x100007d1,0x5ff049c9,0x14560859,0x07087fef,0x3e277d49,0x4dba1f17,0x709c5988,0x05904258,0x1aa71872,0x238819b3,0x7b002bb7,0x1cf91302,0x0012290a,0x1083576b,0x76473e49,0x3d86295b,0x20536814,0x08634f4d,0x115405e8,0x0e6359f2}; const int hash_key=xor_nums[rand()%20]; const int mod_key=xor_nums[rand()%20]; template <typename T> struct myhash{ std::size_t operator()(const T& val) const { return (hash<T>{}(val)%mod_key)^hash_key; } }; };
template <typename T> class uset:public std::unordered_set<T,myhash::myhash<T>> { using SET=std::unordered_set<T,myhash::myhash<T>>; public: uset():SET(){SET::rehash(myhash::Bsizes[rand()%20]);} };
template <typename T,typename U> class umap:public std::unordered_map<T,U,myhash::myhash<T>> { public: using MAP=std::unordered_map<T,U,myhash::myhash<T>>; umap():MAP(){MAP::rehash(myhash::Bsizes[rand()%20]);} };
struct timeval start; double sec() { struct timeval tv; gettimeofday(&tv, NULL); return (tv.tv_sec - start.tv_sec) + (tv.tv_usec - start.tv_usec) * 1e-6; }
struct init_{init_(){ gettimeofday(&start, NULL); ios::sync_with_stdio(false); cin.tie(0); srand((unsigned int)time(NULL)); random_seed = RAND_MAX / 2 + rand() / 2; }} init__;
static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;
#define ldout fixed << setprecision(40)
const int nmax = 300;
int ret = INF;
int n, m;
vvint a;
void print(void) {
cout << "#############" << endl;
rep(i, a.size()) {
rep(j, a[i].size()) {
cout << a[i][j] + 1 << " ";
}
cout << endl;
}
}
void dfs(void) {
if (!a[0].size()) return;
// print();
// cout << a[0].size() << endl;
int counter[nmax] = {};
rep(i, n)
counter[a[i][0]]++;
int M = -1;
rep(i, nmax)
chmax(M, counter[i]);
chmin(ret, M);
vvint a_org = a;
rep(i, nmax) if (counter[i] == M) {
vvint a_next(n);
rep(j, n) rep(h, a_org[j].size()) if (a_org[j][h] != i) {
a_next[j].pb(a_org[j][h]);
}
a = a_next;
dfs();
a = a_org;
break;
}
}
int main(void) {
cin >> n >> m;
rep(i, n) {
vector<int> tmp;
rep(i, m) {
int x; cin >> x; x--;
tmp.pb(x);
}
a.pb(tmp);
}
dfs();
cout << ret << endl;
return 0;
}
| a.cc:41:20: warning: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Wdeprecated-declarations]
41 | struct ci : public iterator<forward_iterator_tag, ll> { ll n; ci(const ll n) : n(n) { } bool operator==(const ci& x) { return n == x.n; } bool operator!=(const ci& x) { return !(*this == x); } ci &operator++() { n++; return *this; } ll operator*() const { return n; } };
| ^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65,
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_iterator_base_types.h:127:34: note: declared here
127 | struct _GLIBCXX17_DEPRECATED iterator
| ^~~~~~~~
a.cc:58:11: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
58 | int ret = INF;
| ^~~
a.cc:60:1: error: 'vvint' does not name a type; did you mean 'vvi'?
60 | vvint a;
| ^~~~~
| vvi
a.cc: In function 'void print()':
a.cc:63:12: error: 'a' was not declared in this scope
63 | rep(i, a.size()) {
| ^
a.cc:5:55: note: in definition of macro 'rep'
5 | #define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
| ^
a.cc: In function 'void dfs()':
a.cc:71:10: error: 'a' was not declared in this scope
71 | if (!a[0].size()) return;
| ^
a.cc:77:17: error: 'a' was not declared in this scope
77 | counter[a[i][0]]++;
| ^
a.cc:85:5: error: 'vvint' was not declared in this scope; did you mean 'vvi'?
85 | vvint a_org = a;
| ^~~~~
| vvi
a.cc:87:14: error: expected ';' before 'a_next'
87 | vvint a_next(n);
| ^~~~~~~
| ;
a.cc:88:26: error: 'a_org' was not declared in this scope
88 | rep(j, n) rep(h, a_org[j].size()) if (a_org[j][h] != i) {
| ^~~~~
a.cc:5:55: note: in definition of macro 'rep'
5 | #define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
| ^
a.cc:89:13: error: 'a_next' was not declared in this scope
89 | a_next[j].pb(a_org[j][h]);
| ^~~~~~
a.cc:91:9: error: 'a' was not declared in this scope
91 | a = a_next;
| ^
a.cc:91:13: error: 'a_next' was not declared in this scope
91 | a = a_next;
| ^~~~~~
a.cc:93:13: error: 'a_org' was not declared in this scope
93 | a = a_org;
| ^~~~~
a.cc: In function 'int main()':
a.cc:106:9: error: 'a' was not declared in this scope
106 | a.pb(tmp);
| ^
|
s194433066 | p03652 | C++ | #include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<int>> bar;
vector<int> count;
vector<int> cur;
void forward(int index) {
while (count[ bar[index][cur[index]] ] == -1)
++ cur[index];
}
int main()
{
cin >> N >> M;
bar = vector<vector<int>> (N, vector<int>(M, 0));
for (int i = 0; i < N; ++ i) {
for (int j = 0; j < M; ++ j) {
cin >> bar[i][j];
-- bar[i][j];
}
}
count = vector<int> (M, 0);
cur = vector<int> (N, 0);
int ans = 100000;
for (int round = 0; round < M; ++ round) {
for (int i = 0; i < N; ++ i) {
count[ bar[i][cur[i]] ] ++;
}
int maxv = -1, maxi = -1;
for (int i = 0; i < M; ++ i) {
if (count[i] != -1 && count[i] > maxv) {
maxi = i;
maxv = count[i];
}
}
ans = min(ans, maxv);
count[maxi] = -1;
for (int i = 0; i < M; ++ i) count[i] == -1 ? -1 : 0;
for (int i = 0; i < N; ++ i) forward(i);
}
return 0;
} | a.cc: In function 'void forward(int)':
a.cc:10:10: error: reference to 'count' is ambiguous
10 | while (count[ bar[index][cur[index]] ] == -1)
| ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:6:13: note: 'std::vector<int> count'
6 | vector<int> count;
| ^~~~~
a.cc: In function 'int main()':
a.cc:25:3: error: reference to 'count' is ambiguous
25 | count = vector<int> (M, 0);
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:6:13: note: 'std::vector<int> count'
6 | vector<int> count;
| ^~~~~
a.cc:31:7: error: reference to 'count' is ambiguous
31 | count[ bar[i][cur[i]] ] ++;
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:6:13: note: 'std::vector<int> count'
6 | vector<int> count;
| ^~~~~
a.cc:35:11: error: reference to 'count' is ambiguous
35 | if (count[i] != -1 && count[i] > maxv) {
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:6:13: note: 'std::vector<int> count'
6 | vector<int> count;
| ^~~~~
a.cc:35:29: error: reference to 'count' is ambiguous
35 | if (count[i] != -1 && count[i] > maxv) {
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:6:13: note: 'std::vector<int> count'
6 | vector<int> count;
| ^~~~~
a.cc:37:16: error: reference to 'count' is ambiguous
37 | maxv = count[i];
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:6:13: note: 'std::vector<int> count'
6 | vector<int> count;
| ^~~~~
a.cc:42:5: error: reference to 'count' is ambiguous
42 | count[maxi] = -1;
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:6:13: note: 'std::vector<int> count'
6 | vector<int> count;
| ^~~~~
a.cc:43:34: error: reference to 'count' is ambiguous
43 | for (int i = 0; i < M; ++ i) count[i] == -1 ? -1 : 0;
| ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
| ^~~~~
a.cc:6:13: note: 'std::vector<int> count'
6 | vector<int> count;
| ^~~~~
|
s917573865 | p03652 | C++ | 4 5
5 1 3 4 2
2 5 3 1 4
2 3 1 4 5
2 5 4 3 1
| a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 4 5
| ^
|
s829591443 | p03652 | C++ | #include <iostream>
#include <limits>
void solve(int a[310][310], int n, int m)
{
int values[310] = { 0 }, maxRating, maxValues = 0, maxIndex = 0, ans = INT_MAX;
bool visited[310] = { 0 };
maxRating = m;
while (maxRating--)
{
// std::cout << "\n";
int values[310] = { 0 }, popularSport = 0, indexOfPopularSport = 0;
for (int i = 0; i < n; ++i)
{
int chosenSport = INT_MAX, minOfChosenSport = INT_MAX;
for (int j = 0; j < m; ++j)
{
if (!visited[a[i][j]])
{
if (j < chosenSport)
{
chosenSport = j;
++values[a[i][j]];
if (values[a[i][j]] > popularSport)
{
popularSport = values[a[i][j]];
indexOfPopularSport = a[i][j];
}
}
}
}
}
if (popularSport < ans)
ans = popularSport;
visited[indexOfPopularSport] = true;
}
std::cout << ans;
}
int main()
{
int n, m, a[310][310], values[310] = { 0 }, maxRating = INT_MAX, maxValues = 0, maxIndex = 0;
bool visited[310] = { 0 };
std::cin >> n >> m;
maxRating = m;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
std::cin >> a[i][j];
if (a[i][j] == maxRating)
++values[i];
if (values[i] > maxValues)
{
maxValues = values[i];
maxIndex = maxValues;
}
}
}
solve(a, n, m);
} | a.cc: In function 'void solve(int (*)[310], int, int)':
a.cc:6:80: error: 'INT_MAX' was not declared in this scope
6 | int values[310] = { 0 }, maxRating, maxValues = 0, maxIndex = 0, ans = INT_MAX;
| ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
2 | #include <limits>
+++ |+#include <climits>
3 |
a.cc: In function 'int main()':
a.cc:47:65: error: 'INT_MAX' was not declared in this scope
47 | int n, m, a[310][310], values[310] = { 0 }, maxRating = INT_MAX, maxValues = 0, maxIndex = 0;
| ^~~~~~~
a.cc:47:65: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:59:41: error: 'maxValues' was not declared in this scope; did you mean 'values'?
59 | if (values[i] > maxValues)
| ^~~~~~~~~
| values
a.cc:62:33: error: 'maxIndex' was not declared in this scope
62 | maxIndex = maxValues;
| ^~~~~~~~
|
s984550445 | p03652 | C++ | //let's do it
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 100001
int n,m,a[305][305],cnt[305],ban[305],ptr[305];
int ok(int limit)
{
for(int i=1;i<=n;i++)
ptr[i]=1;
for(i=1;i<=m;i++)
{
cnt[i]=0;
ban[i]=0;
}
while(1)
{
for(int i=1;i<=m;i++)
cnt[i]=0;
int f=1;
for(int i=1;i<=n;i++)
{
if(ban[a[i][ptr[i]]])
{
f=0;
break;
}
cnt[a[i][ptr[i]]]++;
}
for(int i=1;i<=m;i++)
{
if(cnt[i]>limit)
{
f=0;
break;
}
}
if(f)
return 1;
for(int i=1;i<=n;i++)
{
if(cnt[a[i][ptr[i]]]>limit)
{
ban[a[i][ptr[i]]]=1;
ptr[i]++;
}
else if(ban[a[i][ptr[i]]])
ptr[i]++;
}
for(int i=1;i<=n;i++)
{
if(ptr[i]>m)
return 0;
}
}
}
int main()
{
boost1;boost2;
int i,j,lo,mid,hi;
cin>>n>>m;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
cin>>a[i][j];
}
lo=0;
hi=n;
while(hi-lo>1)
{
mid=(lo+hi)/2;
if(ok(mid))
hi=mid;
else
lo=mid;
}
cout<<hi;
return 0;
}
| a.cc: In function 'int ok(int)':
a.cc:25:13: error: 'i' was not declared in this scope
25 | for(i=1;i<=m;i++)
| ^
|
s972543661 | p03652 | C++ | #include <iostream>
#include <limits>
void solve(int a[310][310], int n, int m)
{
int values[310] = { 0 }, maxRating, maxValues = 0, maxIndex = 0, ans = INT_MAX;
bool visited[310] = { 0 };
maxRating = m;
while (maxRating--)
{
// std::cout << "\n";
int values[310] = { 0 }, popularSport = 0, indexOfPopularSport = 0;
for (int i = 0; i < n; ++i)
{
int chosenSport = 0, maxOfChosenSport = 0;
for (int j = 0; j < m; ++j)
{
if (a[i][j] > maxOfChosenSport && visited[j] == 0)
{
chosenSport = j;
maxOfChosenSport = a[i][j];
}
}
// std::cout << chosenSport << "\n";
++values[chosenSport];
if (values[chosenSport] > popularSport)
{
popularSport = values[chosenSport];
indexOfPopularSport = chosenSport;
}
}
if (popularSport < ans)
ans = popularSport;
visited[indexOfPopularSport] = true;
}
std::cout << ans;
}
int main()
{
int n, m, a[310][310], values[310] = { 0 }, maxRating = INT_MAX, maxValues = 0, maxIndex = 0;
bool visited[310] = { 0 };
std::cin >> n >> m;
maxRating = m;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
std::cin >> a[i][j];
if (a[i][j] == maxRating)
++values[i];
if (values[i] > maxValues)
{
maxValues = values[i];
maxIndex = maxValues;
}
}
}
solve(a, n, m);
} | a.cc: In function 'void solve(int (*)[310], int, int)':
a.cc:6:80: error: 'INT_MAX' was not declared in this scope
6 | int values[310] = { 0 }, maxRating, maxValues = 0, maxIndex = 0, ans = INT_MAX;
| ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
2 | #include <limits>
+++ |+#include <climits>
3 |
a.cc: In function 'int main()':
a.cc:46:65: error: 'INT_MAX' was not declared in this scope
46 | int n, m, a[310][310], values[310] = { 0 }, maxRating = INT_MAX, maxValues = 0, maxIndex = 0;
| ^~~~~~~
a.cc:46:65: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:58:41: error: 'maxValues' was not declared in this scope; did you mean 'values'?
58 | if (values[i] > maxValues)
| ^~~~~~~~~
| values
a.cc:61:33: error: 'maxIndex' was not declared in this scope
61 | maxIndex = maxValues;
| ^~~~~~~~
|
s226516946 | p03652 | C++ | #include<bits/stdc++.h>
using namespace std;
const int N = 305;
int N,M;
int p[333][333];
int pnt[333];
bool invalid[333];
int c[333];
bool ok(int x){
memset(invalid,0,sizeof(invalid));
for(int i=1; i<=N; i++)pnt[i] = 1;
while(1){
bool flag = false;
memset(c,0,sizeof(c));
for(int i=1; i<=N; i++){
while(pnt[i] <= M && invalid[p[i][pnt[i]]])pnt[i] ++;
if(pnt[i] > M)return false;
c[p[i][pnt[i]]] ++;
}
for(int i=1; i<=M; i++)
if(c[i] > x){
invalid[i] = true;
flag = true;
}
if(!flag)return true;
}
}
int main(){
scanf("%d%d",&N,&M);
for(int i=1; i<=N; i++)
for(int j=1; j<=M; j++)
scanf("%d",&p[i][j]);
int lo = 1, hi = N;
while(lo != hi){
int mi = (lo + hi)/2;
if(ok(mi))
hi = mi;
else
lo = mi+1;
}
printf("%d\n",lo);
return 0;
}
| a.cc:5:5: error: conflicting declaration 'int N'
5 | int N,M;
| ^
a.cc:4:11: note: previous declaration as 'const int N'
4 | const int N = 305;
| ^
|
s060304150 | p03652 | C++ | #include <bits/stdc++.h>
using namespace std;
int a[400][400];
int vis[400][400];
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for(int i = 0; i< n; i++)
{
int pos = 0, maxx = -1;
for(int j = 0; j < m; j++)
{
scanf("%d", &a[i][j]);
if(a[i][j] > maxx)
{
maxx = a[i][j];
pos = j;
}
}
vis[i][j] = 1;
}
int ans = 1;
for(int j= 0; j < m; j++)
{
int cnt = 0;
for(int i = 0; i < n; i++)
{
cnt += vis[i][j];
}
ans = max(ans, cnt);
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:21:16: error: 'j' was not declared in this scope
21 | vis[i][j] = 1;
| ^
|
s471291897 | p03652 | C++ | #include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdint>
using namespace std;
int main()
{
int N, M;
cin >> N >> M;
vector<vector<int>> A(N, vector<int>(M, 0));
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
cin >> A[i][j];
// A[i][j] --;
}
}
vector<bool> used(M, false);
int ans = INT_MAX;
for (int i = 0; i < M; ++i) {
vector<int> num(M, 0);
for (int j = 0; j < N; ++j) {
int max_v = -1;
int max_id = 0;
for (int k = 0; k < M; ++k) {
if (!used[k] && max_v < A[j][k]) {
max_v = A[j][k];
max_id = k;
}
}
num[max_id]++;
}
auto it = max_element(num.begin(), num.end());
int id = std::distance(num.begin(), it);
int k = *it;
// cout << id << ", " << k << endl;
used[id] = true;
ans = min(ans, k);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:15: error: 'INT_MAX' was not declared in this scope
22 | int ans = INT_MAX;
| ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include <cstdint>
+++ |+#include <climits>
6 | using namespace std;
|
s568949089 | p03652 | C++ | #include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
int main()
{
int N, M;
cin >> N >> M;
vector<vector<int>> A(N, vector<int>(M, 0));
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
cin >> A[i][j];
// A[i][j] --;
}
}
vector<bool> used(M, false);
int ans = INT_MAX;
for (int i = 0; i < M; ++i) {
vector<int> num(M, 0);
for (int j = 0; j < N; ++j) {
int max_v = -1;
int max_id = 0;
for (int k = 0; k < M; ++k) {
if (!used[k] && max_v < A[j][k]) {
max_v = A[j][k];
max_id = k;
}
}
num[max_id]++;
}
auto it = max_element(num.begin(), num.end());
int id = std::distance(num.begin(), it);
int k = *it;
// cout << id << ", " << k << endl;
used[id] = true;
ans = min(ans, k);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:15: error: 'INT_MAX' was not declared in this scope
21 | int ans = INT_MAX;
| ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
4 | #include <algorithm>
+++ |+#include <climits>
5 | using namespace std;
|
s466019770 | p03652 | C++ | #include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
vector<vector<int>> A(n, vector<int>(m, 0));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cin >> A[i][j];
A[i][j] --;
}
}
vector<bool> used(m, false);
int ans = n;
for (int i = 0; i < m; ++i)
{
vector<int> num(m, 0);
for (int j = 0; j < n; ++j) {
int max_v = -1;
int max_id = 0;
for (int k = 0; k < m; ++k) {
if (!used[k] && max_v < A[j][k]) {
max_v = A[j][k];
max_id = k;
}
}
num[max_id]++;
}
auto it = max_element(num.begin(), num.end());
int id = std::distance(num.begin(), it);
int k = *it;
// cout << id << ", " << k << endl;
used[id] = true;
ans = min(ans, k);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:35:19: error: 'max_element' was not declared in this scope
35 | auto it = max_element(num.begin(), num.end());
| ^~~~~~~~~~~
|
s650870095 | p03652 | C++ | #include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>
#include <unordered_map>
using namespace std;
#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<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define VS vector<string>
#define VI vector<ll>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define pii pair<ll,ll>
#define pcc pair<char,char>
#define pic pair<ll,char>
#define pci pair<char,ll>
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)
namespace {
struct input_returnner {
ll N; input_returnner(ll N_ = 0) :N(N_) {}
template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
template<typename T> operator T() const { T res; cin >> res; return res; }
template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
};
template<typename T> input_returnner in() { return in<T>(); }
input_returnner in() { return input_returnner(); }
input_returnner in(ll N) { return std::move(input_returnner(N)); }
}
const ll MOD = 1e9 + 7;
struct ModInt {
ll v = 0;
ModInt() {}
template<class T> ModInt(const T& right) {
v = right;
if (v >= 0) v %= MOD;
else v += ((-v) / MOD + 1)*MOD;
v %= MOD;
}
void operator = (const ModInt& right) { v = right.v; }
template<class T> void operator = (const T& right) {
v = right;
if (v >= 0) v %= MOD;
else v = v += ((-v) / MOD + 1)*MOD;
v %= MOD;
}
ModInt operator + (const ModInt& right) { return (v + right.v) % MOD; }
ModInt operator - (const ModInt& right) { return (MOD - (v - right.v)); }
ModInt operator * (const ModInt& right) { return (v * right.v) % MOD; }
ModInt operator / (const ModInt& right) { return v / right.v; }
void operator += (const ModInt& right) { v = (v + right.v) % MOD; }
void operator -= (const ModInt& right) { v = (MOD - (v - right.v)); }
void operator *= (const ModInt& right) { v = (v* right.v) % MOD; }
void operator /= (const ModInt& right) { v = v / right.v; }
bool operator == (const ModInt& right) { return v == right.v; }
};
ostream& operator << (ostream& os, const ModInt& value) {
os << value.v;
return os;
}
string YN[] = { "NO", "YES" };
int gcd ( int a, int b )
{
if ( a==0 ) return b;
return gcd ( b%a, a );
}
void solve();
/// ---template---
signed main(void) {
SETUP;
solve();
#ifdef _DEBUG
system("pause");
#endif
return 0;
}
int A[300][300] = {};
int N, M;
//checked: もう使ってはならない
//cnt: 各競技の参加人数 numを越えてはならない
//depth: 何人目を見ているか
//selected: どの競技を選択したのか
//return: ダメだった番号
//retrun: -1 OK
//retrun: -100 NG
int check(int num, vector<int>& cnt, vector<bool>& checked, int depth) {
if (depth == N) return -1;
REP(j, M) {
if (checked[A[depth][j]]) continue;
if (cnt[A[depth][j]] < num) {
// cout << "num(" << num << "), " << "depth(" << depth << "), " << "check:" << A[depth][j] << endl;
cnt[A[depth][j]]++;
}
else {
checked[A[depth][j]] = true;
return A[depth][j];
}
int c = check(num, cnt, checked, depth + 1);
if (c == -1) {
return -1;
}
//違ってた場合はダメだったやつが消えるまで遡る
else {
cnt[A[depth][j]]--;
// cout << "num(" << num << "), " << "depth(" << depth << "), " << "delete:" << A[depth][j] << endl;
if (cnt[c] > 0) return c;
}
}
return -100;
}
void solve() {
cin >> N >> M;
REP(i, N) REP(j, M) cin >> A[i][j];
vector<int> cnt(M+1);
vector<bool> checked(M+1);
int high = M;
int low = 0;
int mid;
for(int i=0;i<N+1;++i){
for (auto &c : checked) c = false;
for (auto &c : cnt) c = 0;
if (check(i, cnt, checked, 0) == -1) {
high = i;
break;
}
}
cout << high << endl;
} | a.cc: In function 'void solve()':
a.cc:179:32: error: cannot bind non-const lvalue reference of type 'std::_Bit_reference&' to an rvalue of type 'std::_Bit_iterator::reference'
179 | for (auto &c : checked) c = false;
| ^~~~~~~
|
s901339410 | p03652 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,m,ans = 1e9,cnt[303];
vector<priority_queue<pair<int,int> > > v(303);
set<int> del;
int main(){
cin >> n >> m;
for(int i = 0;i < n;++i){
for(int j = 0, x;j < m;++j){
scanf("%d",&x);
v[i].push({m-j,x});
}
}
for(int k = 0;k < m;++k){
memset(cnt,0,sizeof cnt);
int mx = 0, nxt;
for(int i = 0;i < n;++i){
auto t = v[i].top();
while(del.count(t.second)){
v[i].pop();
t = v[i].top();
}
cnt[t.second]++;
if(cnt[t.second] > mx){
mx = cnt[t.second];
nxt = t.second;
}
}
ans = min(ans,mx);
del.insert(nxt);
}
cout << ans << endl;
return 0;
} | a.cc:3:1: error: extended character is not valid in an identifier
3 |
| ^
a.cc:7:1: error: extended character is not valid in an identifier
7 |
| ^
a.cc:35:1: error: extended character is not valid in an identifier
35 |
| ^
a.cc:3:1: error: '\U000000a0' does not name a type
3 |
| ^
a.cc:7:1: error: '\U000000a0' does not name a type
7 |
| ^
|
s079355791 | p03652 | C++ | #include<stdio.h>
#include <iostream>
#include <vector>
#define MAX_N 200
#define MAX_M 300
using namespace std;
int N, M;
int A[MAX_N+1][MAX_M+1] = {};
int c[MAX_M+1][MAX_M+1] = {};
int calc(int dim, int aray[dim]){
int result[dim];
for(int i=0; i <dim; i++){
result[i] = 0;
}
for(int n_ind=0; n_ind < N; n_ind++){
for(int m_ind=0; m_ind < M; m_ind++){
bool isFound = false;
for(int aray_ind=0; aray_ind < dim; aray_ind++){
if(A[n_ind][m_ind] == aray[aray_ind]){
result[aray_ind] ++;
isFound = true;
break;
}
}
if(isFound)break;
}
}
int max = 0;
for(int i=0; i < dim; i++){
//printf("res:%d\n", result[i]);
if(max < result[i]) max = result[i];
}
return max;
}
void solve() {
cin >> N ;
cin >> M;
vector<int> sports(M+1);
for(int i=0; i<M; i++){
sports[i] = i+1;
}
for(int n_ind=0; n_ind < N; n_ind++){
for(int m_ind=0; m_ind < M; m_ind++){
int tmp;
cin >>tmp;
A[n_ind][m_ind] = tmp;
(c[m_ind][ tmp ] )++; //m番目に好きなものを種類別にカウント
}
}
vector<int> erased(M+1, 0);
int min_max = calc(sports.size(),&sports.front());
for(int m_ind=0; m_ind < M; m_ind++){
int sports_ind = -1;
int max_count =0 ;
//最大のスポーツを探し外す
for(int i=1; i<M+1; i++){
if(max_count < c[m_ind][i]){
sports_ind = i -1;
max_count = c[m_ind][i];
}
}
bool isFound1=false;
//printf("tag:%d :", sports_ind +1);
for(int erase_ind=0; erase_ind<sports.size(); erase_ind++){
//printf("%d ", sports[erase_ind]);
if(sports[erase_ind] == sports_ind+1) {
sports_ind = erase_ind;
isFound1 = true;
}
}
//printf("\n ");
if(isFound1)sports[sports_ind] = 0;//削除
int temp = calc(sports.size(),&sports.front());
if(min_max > temp && temp != 0) min_max= temp; //最小値更新
}
printf("%d\n", min_max);
}
int main(void) {
solve();
return 0;
}
| a.cc:14:31: error: use of parameter outside function body before ']' token
14 | int calc(int dim, int aray[dim]){
| ^
a.cc: In function 'int calc(...)':
a.cc:15:20: error: 'dim' was not declared in this scope; did you mean 'div'?
15 | int result[dim];
| ^~~
| div
a.cc:17:17: error: 'result' was not declared in this scope
17 | result[i] = 0;
| ^~~~~~
a.cc:24:55: error: 'aray' was not declared in this scope
24 | if(A[n_ind][m_ind] == aray[aray_ind]){
| ^~~~
a.cc:25:41: error: 'result' was not declared in this scope
25 | result[aray_ind] ++;
| ^~~~~~
a.cc:38:26: error: 'result' was not declared in this scope
38 | if(max < result[i]) max = result[i];
| ^~~~~~
|
s658587543 | p03652 | C++ | #include<stdio.h>
#include <iostream>
#include <vector>
#define MAX_N 200
#define MAX_M 300
using namespace std;
int N, M;
int A[MAX_N+1][MAX_M+1] = {};
int c[MAX_M+1][MAX_M+1] = {};
int calc(int dim, int aray[dim]);
void solve() {
cin >> N ;
cin >> M;
vector<int> sports(M+1);
for(int i=0; i<M; i++){
sports[i] = i+1;
}
for(int n_ind=0; n_ind < N; n_ind++){
for(int m_ind=0; m_ind < M; m_ind++){
int tmp;
cin >>tmp;
A[n_ind][m_ind] = tmp;
(c[m_ind][ tmp ] )++; //m番目に好きなものを種類別にカウント
}
}
vector<int> erased(M+1, 0);
int min_max = calc(sports.size(),&sports.front());
for(int m_ind=0; m_ind < M; m_ind++){
int sports_ind = -1;
int max_count =0 ;
//最大のスポーツを探し外す
for(int i=1; i<M+1; i++){
if(max_count < c[m_ind][i]){
sports_ind = i -1;
max_count = c[m_ind][i];
}
}
bool isFound1=false;
//printf("tag:%d :", sports_ind +1);
for(int erase_ind=0; erase_ind<sports.size(); erase_ind++){
//printf("%d ", sports[erase_ind]);
if(sports[erase_ind] == sports_ind+1) {
sports_ind = erase_ind;
isFound1 = true;
}
}
//printf("\n ");
if(isFound1)sports[sports_ind] = 0;//削除
int temp = calc(sports.size(),&sports.front());
if(min_max > temp && temp != 0) min_max= temp; //最小値更新
}
printf("%d\n", min_max);
}
int calc(int dim, int aray[dim]){
int result[dim];
for(int i=0; i <dim; i++){
result[i] = 0;
}
for(int n_ind=0; n_ind < N; n_ind++){
for(int m_ind=0; m_ind < M; m_ind++){
bool isFound = false;
for(int aray_ind=0; aray_ind < dim; aray_ind++){
if(A[n_ind][m_ind] == aray[aray_ind]){
result[aray_ind] ++;
isFound = true;
break;
}
}
if(isFound)break;
}
}
int max = 0;
for(int i=0; i < dim; i++){
//printf("res:%d\n", result[i]);
if(max < result[i]) max = result[i];
}
return max;
}
int main(void) {
solve();
return 0;
}
| a.cc:13:31: error: use of parameter outside function body before ']' token
13 | int calc(int dim, int aray[dim]);
| ^
a.cc:64:31: error: use of parameter outside function body before ']' token
64 | int calc(int dim, int aray[dim]){
| ^
a.cc: In function 'int calc(...)':
a.cc:65:20: error: 'dim' was not declared in this scope; did you mean 'div'?
65 | int result[dim];
| ^~~
| div
a.cc:67:17: error: 'result' was not declared in this scope
67 | result[i] = 0;
| ^~~~~~
a.cc:74:55: error: 'aray' was not declared in this scope
74 | if(A[n_ind][m_ind] == aray[aray_ind]){
| ^~~~
a.cc:75:41: error: 'result' was not declared in this scope
75 | result[aray_ind] ++;
| ^~~~~~
a.cc:88:26: error: 'result' was not declared in this scope
88 | if(max < result[i]) max = result[i];
| ^~~~~~
|
s477741119 | p03652 | C++ | #include<stdio.h>
#include <iostream>
#include <vector>
#define MAX_N 200
#define MAX_M 300
using namespace std;
int N, M;
int A[MAX_N+1][MAX_M+1] = {};
int c[MAX_M+1][MAX_M+1] = {};
int calc(int dim, int aray[dim]);
void solve() {
cin >> N ;
cin >> M;
vector<int> sports(M+1);
for(int i=0; i<M; i++){
sports[i] = i+1;
}
for(int n_ind=0; n_ind < N; n_ind++){
for(int m_ind=0; m_ind < M; m_ind++){
int tmp;
cin >>tmp;
A[n_ind][m_ind] = tmp;
(c[m_ind][ tmp ] )++; //m番目に好きなものを種類別にカウント
}
}
vector<int> erased(M+1, 0);
int min_max = calc(sports.size(),&sports.front());
for(int m_ind=0; m_ind < M; m_ind++){
int sports_ind = -1;
int max_count =0 ;
//最大のスポーツを探し外す
for(int i=1; i<M+1; i++){
if(max_count < c[m_ind][i]){
sports_ind = i -1;
max_count = c[m_ind][i];
}
}
bool isFound1=false;
//printf("tag:%d :", sports_ind +1);
for(int erase_ind=0; erase_ind<sports.size(); erase_ind++){
//printf("%d ", sports[erase_ind]);
if(sports[erase_ind] == sports_ind+1) {
sports_ind = erase_ind;
isFound1 = true;
}
}
//printf("\n ");
if(isFound1)sports[sports_ind] = 0;//削除
int temp = calc(sports.size(),&sports.front());
if(min_max > temp && temp != 0) min_max= temp; //最小値更新
}
printf("%d\n", min_max);
}
int calc(int dim, int aray[dim]){
int result[dim];
for(int i=0; i <dim; i++){
result[i] = 0;
}
for(int n_ind=0; n_ind < N; n_ind++){
for(int m_ind=0; m_ind < M; m_ind++){
bool isFound = false;
for(int aray_ind=0; aray_ind < dim; aray_ind++){
if(A[n_ind][m_ind] == aray[aray_ind]){
result[aray_ind] ++;
isFound = true;
break;
}
}
if(isFound)break;
}
}
int max = 0;
for(int i=0; i < dim; i++){
//printf("res:%d\n", result[i]);
if(max < result[i]) max = result[i];
}
return max;
}
int main(void) {
solve();
return 0;
}
| a.cc:13:31: error: use of parameter outside function body before ']' token
13 | int calc(int dim, int aray[dim]);
| ^
a.cc:64:31: error: use of parameter outside function body before ']' token
64 | int calc(int dim, int aray[dim]){
| ^
a.cc: In function 'int calc(...)':
a.cc:65:20: error: 'dim' was not declared in this scope; did you mean 'div'?
65 | int result[dim];
| ^~~
| div
a.cc:67:17: error: 'result' was not declared in this scope
67 | result[i] = 0;
| ^~~~~~
a.cc:74:55: error: 'aray' was not declared in this scope
74 | if(A[n_ind][m_ind] == aray[aray_ind]){
| ^~~~
a.cc:75:41: error: 'result' was not declared in this scope
75 | result[aray_ind] ++;
| ^~~~~~
a.cc:88:26: error: 'result' was not declared in this scope
88 | if(max < result[i]) max = result[i];
| ^~~~~~
|
s255273237 | p03652 | C++ | #include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
// #define int long long // %d=>%lld, 1<<n => 1LL<<n
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
return firstEl.second > secondEl.second;
}
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;
const int MAX_n = 300;
const int MAX_m = 300;
int n, m, a[MAX_n][MAX_m];
int tmp;
freq[MAX_m+1];
queue a[MAX_n];
signed main(){
cin >> n >> m;
for(int i = 0;i < n;i++){
for(int j = 0;j < m;j++){
cin >> tmp;
a[i].push(tmp)
}
}
int ans = INF;
for(int i = 0;i < m-1;i++){
int ans_t=0;
fill(freq,0);
for(int j = 0;j < n;j++){
freq[que[j].front()]++;
}
int f_n = * max_elememt(freq,freq+301);
for(int j = 0;j < n;j++){
ans_t++;
if(que[j].front() == f_n){
que[j].pop();
}
}
ans = min(ans, ans_t);
}
int ans_t=0;
fill(freq,0);
for(int j = 0;j < n;j++){
freq[que[j].front()]++;
}
int f_n = * max_elememt(freq,freq+301);
for(int j = 0;j < n;j++){
ans_t++;
}
ans = min(ans, ans_t);
cout<< ans<< endl;
return 0;
} | a.cc:35:1: error: 'freq' does not name a type
35 | freq[MAX_m+1];
| ^~~~
a.cc:37:1: error: missing template argument list after 'std::queue'; for deduction, template placeholder must be followed by a simple declarator-id
37 | queue a[MAX_n];
| ^~~~~
| <>
In file included from /usr/include/c++/14/queue:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'template<class _Tp, class _Sequence> class std::queue' declared here
96 | class queue
| ^~~~~
a.cc: In function 'int main()':
a.cc:46:18: error: request for member 'push' in 'a[i]', which is of non-class type 'int [300]'
46 | a[i].push(tmp)
| ^~~~
a.cc:53:14: error: 'freq' was not declared in this scope; did you mean 'free'?
53 | fill(freq,0);
| ^~~~
| free
a.cc:55:18: error: 'que' was not declared in this scope
55 | freq[que[j].front()]++;
| ^~~
a.cc:57:22: error: 'max_elememt' was not declared in this scope
57 | int f_n = * max_elememt(freq,freq+301);
| ^~~~~~~~~~~
a.cc:60:16: error: 'que' was not declared in this scope
60 | if(que[j].front() == f_n){
| ^~~
a.cc:69:10: error: 'freq' was not declared in this scope; did you mean 'free'?
69 | fill(freq,0);
| ^~~~
| free
a.cc:71:14: error: 'que' was not declared in this scope
71 | freq[que[j].front()]++;
| ^~~
a.cc:73:18: error: 'max_elememt' was not declared in this scope
73 | int f_n = * max_elememt(freq,freq+301);
| ^~~~~~~~~~~
|
s878401265 | p03652 | C++ | #include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define lson o<<1
#define rson o<<1|1
#define CLR(A, X) memset(A, X, sizeof(A))
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-10;
int dcmp(double x){if(fabs(x)<eps) return 0; return x<0?-1:1;}
const int N = 1e5+5;
const int INF = 0x3f3f3f3f;
int a[305][305], pri[305][305];
bool vis[305];
vector<int> g[305];
int n, m;
void dfs(int x) {
vector<int> gl;
int now = 0, y = INF;
for(int i = g[x].size()-1; i >= 0; i--) {
int u = g[x][i];
for(int j = 0; j < m; j++) if(!vis[a[u][j]]) {
g[a[u][j]].pb(u);
now = max(now, g[a[u][j]].size());
y = min(y, g[a[u][j]].size());
break;
}
gl.pb(u);
}
ans = min(ans, now);
if(y >= ans) return;
g[x].clear();
for(int j = 0; j < m; j++) if(!vis[j]) {
vis[j] = 1;
dfs(j);
vis[j] = 0;
}
for(int i = 0; i < gl.size(); i++) g[x].pb(gl[i]);
}
int main() {
scanf("%d%d", &n, &m);
ans = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
scanf("%d", &a[i][j]);
}
g[a[i][0]].pb(i);
ans = max(ans, g[a[i][0]].size());
}
CLR(vis, 0);
for(int i = 0; i < n; i++) {
vis[i] = 1;
dfs(i);
}
printf("%d\n", ans);
return 0;
}
| a.cc: In function 'void dfs(int)':
a.cc:29:22: error: no matching function for call to 'max(int&, std::vector<int>::size_type)'
29 | now = max(now, g[a[u][j]].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
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:29:22: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
29 | now = max(now, g[a[u][j]].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/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:29:22: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
29 | now = max(now, g[a[u][j]].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:30:20: error: no matching function for call to 'min(int&, std::vector<int>::size_type)'
30 | y = min(y, g[a[u][j]].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:30:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
30 | y = min(y, g[a[u][j]].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~
/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
/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:30:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
30 | y = min(y, g[a[u][j]].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:35:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
35 | ans = min(ans, now);
| ^~~
| abs
a.cc: In function 'int main()':
a.cc:49:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
49 | ans = 0;
| ^~~
| abs
|
s429403195 | p03652 | C++ | #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define For(i,a,b) for(int i=(int)a;i<=(int)b;++i)
#define Fordown(i,a,b) for(int i=(int)a;i>=(int)b;--i)
#define re read()
#define maxn 300+10
#define inf 2100000000
#define mem(a,b)memset(a,b,sizeof(a))
#define ll long long
int n,m;
int a[maxn][maxn];
int b[maxn],bb[maxn];
inline int read()
{
int flag=1,ans=0;
char ch=getchar();
while(!isdigit(ch)&&ch!='-')ch=getchar();
if(ch=='-'){flag=-1;ch=getchar();}
while(isdigit(ch)){ans=(ans<<3)+(ans<<1)+(ch-'0');ch=getchar();}
return ans*flag;
}
struct node
{
int id,sum;
node(){sum=0;}
}e[maxn];
void init()
{
n=re;m=re;
For(i,1,m)e[i].id=i;
For(i,1,n)
{
For(j,1,m)
{
a[i][j]=re;
e[a[i][j]].sum+=j;
}
}
}
bool cmp(node a,node b){return a.sum>=b.sum;}
int cal()
{
int ans=0;
mem(bb,0);
For(i,1,n)
{
For(j,1,m)
{
if(b[a[i][j]])
{
bb[a[i][j]]++;
ans=max(bb[a[i][j]],ans);
break;
}
}
}
return ans;
}
void work()
{4 5
5 1 3 4 2
2 5 3 1 4
2 3 1 4 5
2 5 4 3 1
int ans=n+1;
sort(e+1,e+m+1,cmp);
For(i,1,m)
{
b[e[i].id]=1;
ans=min(ans,cal());
}
printf("%d\n",ans);
}
int main()
{
init();
work();
return 0;
}
| a.cc: In function 'void work()':
a.cc:70:3: error: expected ';' before numeric constant
70 | {4 5
| ^~
| ;
a.cc:80:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
80 | ans=min(ans,cal());
| ^~~
| abs
a.cc:82:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
82 | printf("%d\n",ans);
| ^~~
| abs
|
s733597896 | p03652 | C++ | #include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
#include <random>
using namespace std;
#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 REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
int N,M;
int A[310][310];
int cnt[310];
bool sports[310];
int main() {
cin >> N >> M;
REP(i,N) REP(j,M) cin >> A[i][j];
REP(i,N) REP(j,M) A[i][j]--;
REP(i,310) sports[i] = true;
//---
int ans = 0;
REP(i,310) cnt[i] = 0;
REP(i,N) cnt[A[i][0]]++;
REP(i,M) ans = max(ans,cnt[i]);
//---
while (true && limit > 1) {
REP(i,310) cnt[i] = 0;
REP(i,N) {
int pri = 1e9;
int idx = -1;
REP(j,M) {
if(!sports[j]) continue;
if(pri > A[i][j]) {
idx = j;
pri = A[i][j];
}
}
cnt[idx]++;
}
int maxs = -1;
int spo = -1;
REP(i,M) {
if(maxs < cnt[i]) {
spo = i;
maxs = cnt[i];
}
}
// cout << maxs << " " << spo << endl;
sports[spo] = false;
// -----
REP(i,310) cnt[i] = 0;
REP(i,N) {
int pri = 1e9;
int idx = -1;
REP(j,M) {
if(!sports[j]) continue;
if(pri > A[i][j]) {
idx = j;
pri = A[i][j];
}
}
cnt[idx]++;
}
int sum = 0;
REP(i,M) sum += cnt[i];
if(sum != N) break;
// ----
int anst = 0;
REP(i,M) anst = max(anst,cnt[i]);
ans = min(ans,anst);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:44:20: error: 'limit' was not declared in this scope
44 | while (true && limit > 1) {
| ^~~~~
|
s809399368 | p03652 | C++ | #include <vector>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <iostream>
#include <cstdio>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1 ; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define FILL(a,b) memset(a , b , sizeof(a))
#define SZ(a) (int)a.size()
#define PB push_back
#define MP make_pair
typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VI;
const int MAX = 307;
const int INF = 1000000000;
int A[MAX][MAX];
int cnt[MAX];
int d[MAX];
int main()
{
//freopen("in.txt" , "r" , stdin);
int n , m;
cin >> n >> m;
FOR(i,0,n)
{
FOR(j,0,m)
{
cin >> A[i][j];
-- A[i][j];
}
}
int res = INF;
FOR(it,0,m)
{
FILL(cnt , 0);
FOR(i,0,n)
{
FOR(j,0,m)
{
if (!d[A[i][j]])
{
cnt[A[i][j]] ++ ;
break;
}
}
}
int mx = -1;
int id;
FOR(i,0,m)
{
if (cnt[i] > mx)
{
mx = cnt[i];
id = i;
}
}
res = min(res , mx);
d[id] = 1;
}
cout << res << endl;
}
| a.cc: In function 'int main()':
a.cc:17:19: error: 'memset' was not declared in this scope
17 | #define FILL(a,b) memset(a , b , sizeof(a))
| ^~~~~~
a.cc:53:17: note: in expansion of macro 'FILL'
53 | FILL(cnt , 0);
| ^~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
10 | #include <cstdio>
+++ |+#include <cstring>
11 |
|
s039354762 | p03652 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int val[310][310];
int main(){
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> r;
val[i][r] = j+1;
}
}
int ans = 100000;
int used[310];
for(int z = 0; z < m; z++){
used[z] = 1;
}
for(int z = 0; z < m; z++){
int freq[310];
for(int j = 0; j < m; j++){
freq[j] = 0;
}
for(int i = 0; i < n; i++){
int best = -1;
for(int j = 0; j < m; j++){
if(used[j] && (best == -1 || val[i][j] > val[i][best])){
best = j;
}
}
freq[best]++;
}
int sbest = -1;
for(int j = 0; j < m; j++){
if(used[j] && (sbest == -1 || freq[j] > freq[sbest])){
sbest = j;
}
}
ans = min(ans, freq[sbest]);
used[sbest] = 0;
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:10:32: error: 'r' was not declared in this scope
10 | cin >> r;
| ^
|
s529723120 | p03652 | C++ | if (t && t <= m) {
m = t;
best = g;
}
}
if (best < 0) {
cout << m << endl;
break;
}
// cout << "remove " << best << " because " << m << endl;
games.erase(best);
}
}
| a.cc:1:13: error: expected unqualified-id before 'if'
1 | if (t && t <= m) {
| ^~
a.cc:5:9: error: expected declaration before '}' token
5 | }
| ^
a.cc:6:9: error: expected unqualified-id before 'if'
6 | if (best < 0) {
| ^~
a.cc:11:9: error: 'games' does not name a type
11 | games.erase(best);
| ^~~~~
a.cc:12:5: error: expected declaration before '}' token
12 | }
| ^
a.cc:13:1: error: expected declaration before '}' token
13 | }
| ^
|
s410067501 | p03652 | C++ | #include<cstdio>
#include<iostream>
using namespace std;
int n,m,maxn,minn=400,k;
int a[305][305];
int t[305];
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
scanf("%d",&a[i][j]);
for(int i=1;i<=m;i++)
{
memset(t,0,sizeof(t));
maxn=0;
for(int j=1;j<=n;j++)
{
//p=i;
//while(a[j][p]==0)p++;
t[a[j][i]]++;
if(t[a[j][i]]>maxn)maxn=t[a[j][i]],k=a[j][i];
}
for(int ii=1;ii<=n;ii++)
for(int jj=1;jj<=m;jj++)
{
if(a[ii][jj]==k)
a[ii][jj]=a[ii][jj+1];
}
//del++;
minn=min(minn,maxn);
}
cout<<minn<<endl;
} | a.cc: In function 'int main()':
a.cc:15:17: error: 'memset' was not declared in this scope
15 | memset(t,0,sizeof(t));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<iostream>
+++ |+#include <cstring>
3 | using namespace std;
|
s802098996 | p03652 | C++ | #include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#define P 1000000007
using namespace std;
class Node {
public:
int id, sum;
Node(int i, int s) {
id = i;
sum = s;
}
bool operator<(const Node &rhs) const {
return this->sum > rhs.sum;
}
bool operator>(const Node &rhs) const {
return this->sum < rhs.sum;
}
};
vector<bool> b;
int n, m;
vector<vector<int>> a;
vector<int> cnt;
int f(int id) {
vector<Node> nd;
for(int j = 0; j < m; j++) {
Node nds(j, 0);
nd.push_back(nds);
}
for(int j = 0; j < n; j++) {
if(a[j][cnt[j]] == id) {
nd[a[j][cnt[j] + 1]].sum++;
} else {
nd[a[j][cnt[j]]].sum++;
}
}
sort(nd.begin(), nd.end());
return nd[0].sum;
}
int main() {
cin >> n >> m;
a.resize(n);
cnt.resize(n);
b.resize(n);
for(int i = 0; i < n; i++) {
a[i].resize(m);
b[i] = true;
for(int j = 0; j < m; j++){
cin >> a[i][j];
a[i][j]--;
}
}
int ans = n;
for(int i = 0; i < m - 1; i++) {
vector<Node> nd;
for(int j = 0; j < m; j++) {
Node nds(j, 0);
nd.push_back(nds);
}
for(int j = 0; j < n; j++) {
nd[a[j][cnt[j]]].sum++;
}
sort(nd.begin(), nd.end());
ans = min(ans, nd[0].sum);
int c == nd[0].sum, id = nd[0].id, mm = f(nd[0].id);
for(int j = 1; j < m && nd[j].sum == c; j++) {
int d = f(nd[j].id);
if(d < mm) {
mm = d;
id = nd[j].id;
}
}
if(mm > ans) {
break;
}
b[id] = false;
for(int j = 0; j < n; j++) {
if(a[j][cnt[j]] == id) {
cnt[j]++;
}
}
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:81:11: error: expected initializer before '==' token
81 | int c == nd[0].sum, id = nd[0].id, mm = f(nd[0].id);
| ^~
a.cc:83:42: error: 'c' was not declared in this scope
83 | for(int j = 1; j < m && nd[j].sum == c; j++) {
| ^
a.cc:85:14: error: 'mm' was not declared in this scope; did you mean 'tm'?
85 | if(d < mm) {
| ^~
| tm
a.cc:87:9: error: 'id' was not declared in this scope; did you mean 'd'?
87 | id = nd[j].id;
| ^~
| d
a.cc:90:8: error: 'mm' was not declared in this scope; did you mean 'tm'?
90 | if(mm > ans) {
| ^~
| tm
a.cc:93:7: error: 'id' was not declared in this scope; did you mean 'nd'?
93 | b[id] = false;
| ^~
| nd
|
s544219991 | p03652 | C++ | #include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#define P 1000000007
using namespace std;
class Node {
public:
int id, sum;
Node(int i, int s) {
id = i;
sum = s;
}
bool operator<(const Node &rhs) const {
return this->sum > rhs.sum;
}
bool operator>(const Node &rhs) const {
return this->sum < rhs.sum;
}
};
vector<bool> b;
int n, m;
vector<vector<int>> a;
vector<int> cnt;
int f(int id) {
vector<Node> nd;
for(int j = 0; j < m; j++) {
Node nds(j, 0);
nd.push_back(nds);
}
for(int j = 0; j < n; j++) {
if(a[j][cnt[j]] == id) {
nd[a[j][cnt[j] + 1]].sum++;
} else {
nd[a[j][cnt[j]]].sum++;
}
}
sort(nd.begin(), nd.end());
return nd[0].sum;
}
int main() {
cin >> n >> m;
a.resize(n);
cnt.resize(n);
b.resize(n);
for(int i = 0; i < n; i++) {
a[i].resize(m);
b[i] = true;
for(int j = 0; j < m; j++){
cin >> a[i][j];
a[i][j]--;
}
}
int ans = n;
for(int i = 0; i < m - 1; i++) {
vector<Node> nd;
for(int j = 0; j < m; j++) {
Node nds(j, 0);
nd.push_back(nds);
}
for(int j = 0; j < n; j++) {
nd[a[j][cnt[j]]].sum++;
}
sort(nd.begin(), nd.end());
ans = min(ans, nd[0].sum);
int id = nd[0].id, mm = f(nd[0].id);
for(int j = 1; j < m && nd[j].sum == c; j++) {
int d = f(nd[j].id);
if(d < mm) {
mm = d;
id = nd[j].id;
}
}
if(mm > ans) {
break;
}
b[id] = false;
for(int j = 0; j < n; j++) {
if(a[j][cnt[j]] == id) {
cnt[j]++;
}
}
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:83:42: error: 'c' was not declared in this scope
83 | for(int j = 1; j < m && nd[j].sum == c; j++) {
| ^
|
s588836213 | p03652 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int N, M;
int A[305][305];
int B[305];
bool removed[305];
int main()
{
cin >> N >> M;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
cin >> A[i][j];
A[i][j] --;
}
}
// int ans = *max_element(B+1, B+1+M);
int ans = INT_MAX;
for (int m = 0; m < M; ++m)
{
for (int j = 0; j < M; ++j) {
B[j] = 0;
}
for (int n = 0; n < N; ++n)
{
int max_idx = 0;
int max_v = -1;
for (int j = 0; j < M; ++j)
{
if (!removed[j] && max_v < A[n][j])
{
max_v = A[n][j];
max_idx = j;
}
}
B[max_idx] ++;
}
auto it = max_element(B, B+M);
int idx = std::distance(B, it);
int k = *it;
// cout << idx << ", " << k << endl;
removed[idx] = true;
ans = min(ans, k);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:15: error: 'INT_MAX' was not declared in this scope
21 | int ans = INT_MAX;
| ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
2 | #include <algorithm>
+++ |+#include <climits>
3 | using namespace std;
|
s267857306 | p03652 | C++ | #include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
bool test(int N, int M, const vector<vector<int>>& A, int k)
{
vector<bool> used(M, false);
vector<vector<int>::const_iterator> ps(N);
vector<vector<int>::const_iterator> ends(N);
for (int i = 0; i < N; ++i) {
ps[i] = A[i].begin();
ends[i] = A[i].end();
}
while (true) {
vector<int> cnt(M);
for (int i = 0; i < N; ++i) {
if (ps[i] != ends[i])
++cnt[*ps[i]];
}
vector<pair<int, int>> rank;
for (int i = 0; i < M; ++i) {
rank.push_back(make_pair(cnt[i], i));
}
sort(rank.begin(), rank.end(), greater<pair<int, int>>());
if (rank[0].first > k) {
for (auto pr : rank) {
int c = pr.first;
int i = pr.second;
if (c <= k)
break;
used[i] = true;
}
for (int i = 0; i < N; ++i) {
if (ps[i] == ends[i])
continue;
while (ps[i] != ends[i] && used[*ps[i]])
++ps[i];
if (ps[i] == ends[i])
return false;
}
} else {
break;
}
}
return true;
}
int main()
{
int N, M;
cin >> N >> M;
vector<vector<int>> A(N, vector<int>(M));
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
cin >> A[i][j];
--A[i][j];
}
}
int mn = 0;
int mx = 300;
while (mx - mn > 1) {
int mid = (mn + mx) / 2;
if (test(N, M, A, mid))
mx = mid;
else
mn = mid;
}
cout << mx << '\n';
return 0;
}
| a.cc: In function 'bool test(int, int, const std::vector<std::vector<int> >&, int)':
a.cc:35:9: error: 'sort' was not declared in this scope; did you mean 'short'?
35 | sort(rank.begin(), rank.end(), greater<pair<int, int>>());
| ^~~~
| short
|
s441511878 | p03652 | C++ | #include <iostream>
using namespace std;
int N, M;
int A[301][301];
int B[301];
bool removed[301];
int main()
{
cin >> N >> M;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
cin >> A[i][j];
if (A[i][j] == M)
B[j]++;
}
}
int ans = *max_element(B+1, B+1+M);
for (int m = 0; m < M-1; ++m)
{
auto it = max_element(B+1, B+1+M);
int idx = std::distance(B, it);
int k = *it;
// cout << k << endl;
removed[idx] = true;
ans = min(ans, k);
for (int j = 1; j <= M; ++j) {
B[j] = 0;
}
for (int n = 0; n < N; ++n)
{
int max_idx = 0;
int max_v = 0;
for (int j = 1; j <= M; ++j)
{
if (!removed[j] && max_v < A[n][j])
{
max_v = A[n][j];
max_idx = j;
}
}
B[max_idx] ++;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:20:16: error: 'max_element' was not declared in this scope
20 | int ans = *max_element(B+1, B+1+M);
| ^~~~~~~~~~~
|
s380089114 | p03652 | Java | import java.io.*;
import java.util.StringTokenizer;
public class SportsFestG18B {
public static void main(String[] args) throws IOException {
FastScanner in = new FastScanner();
int n = in.nextInt();
int m = in.nextInt();
int matrix[][] = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
matrix[i][j] = in.nextInt() - 1;
}
}
int curIndex[] = new int[n];
int numPlayers[] = new int[m];
int best = 301;
for (int i = 0; i < n; i++) numPlayers[matrix[i][0]]++;
for (int i = 0; i < n-1; i++) {
int curMax = 0;
int maxSport = -1;
for (int j = 0; j < m; j++) {
if (numPlayers[j] > curMax) {
curMax = numPlayers[j];
maxSport = j;
}
}
if (curMax < best) best = curMax;
numPlayers[maxSport] = -1;
for (int j = 0; j < m; j++) if (numPlayers[j] != -1) numPlayers[j] = 0;
for (int j = 0; j < n; j++) {
while (numPlayers[matrix[j][curIndex[j]]] == -1) curIndex[j]++;
numPlayers[matrix[j][curIndex[j]]]++;
}
}
System.out.println(best);
}
public static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(String s) {
try {
br = new BufferedReader(new FileReader(s));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String nextToken() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return st.nextToken();
}
String nextLine() {
st = null;
try {
return br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
int nextInt() {
return Integer.parseInt(nextToken());
}
long nextLong() {
return Long.parseLong(nextToken());
}
double nextDouble() {
return Double.parseDouble(nextToken());
}
}
}
| Main.java:4: error: class SportsFestG18B is public, should be declared in a file named SportsFestG18B.java
public class SportsFestG18B {
^
1 error
|
s301783206 | p03653 | C++ |
bool lf(const T& p,const T& q)
{
if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
return p.a-p.c<q.a-q.c;
}
struct Tpq
{
int id, d;
bool operator <(const Tpq& e)const
{
return e.d<d;
}
};
struct X
{
long long x, y;
};
X s[maxn];
void Enter()
{
cin>>x>>y>>z;
n=x+y+z;
for(int i=1;i<=n;i++)
cin>>t[i].a>>t[i].b>>t[i].c;
sort(t+1,t+n+1,lf);
}
void Solve()
{
priority_queue<Tpq> l, r;
long long sumx=0, sumy=0, sumz=0;
for(int i=1;i<=x+y;i++)
{
l.push({i,t[i].b-t[i].a});
sumy+=t[i].b;
if(l.size()>y)
{
sumx+=t[l.top().id].a;
sumy-=t[l.top().id].b;
l.pop();
}
s[i]={sumx,sumy};
}
sumx=0;
for(int i=n;i>n-x-z;i--)
{
r.push({i,t[i].c-t[i].a});
sumz+=t[i].c;
if(r.size()>z)
{
sumx+=t[r.top().id].a;
sumz-=t[r.top().id].c;
ans=max(ans,sumx+sumz+s[i-1].x+s[i-1].y);
r.pop();
}
}
cout<<ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if(fopen(tasknames".INP","r"))
{
freopen(tasknames".INP","r",stdin);
freopen(tasknames".OUT","w",stdout);
}
Enter();
Solve();
}
| a.cc:2:15: error: 'T' does not name a type
2 | bool lf(const T& p,const T& q)
| ^
a.cc:2:26: error: 'T' does not name a type
2 | bool lf(const T& p,const T& q)
| ^
a.cc: In function 'bool lf(const int&, const int&)':
a.cc:4:10: error: request for member 'b' in 'p', which is of non-class type 'const int'
4 | if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
| ^
a.cc:4:14: error: request for member 'c' in 'p', which is of non-class type 'const int'
4 | if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
| ^
a.cc:4:19: error: request for member 'b' in 'q', which is of non-class type 'const int'
4 | if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
| ^
a.cc:4:23: error: request for member 'c' in 'q', which is of non-class type 'const int'
4 | if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
| ^
a.cc:4:34: error: request for member 'b' in 'p', which is of non-class type 'const int'
4 | if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
| ^
a.cc:4:38: error: request for member 'c' in 'p', which is of non-class type 'const int'
4 | if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
| ^
a.cc:4:42: error: request for member 'b' in 'q', which is of non-class type 'const int'
4 | if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
| ^
a.cc:4:46: error: request for member 'c' in 'q', which is of non-class type 'const int'
4 | if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
| ^
a.cc:5:14: error: request for member 'a' in 'p', which is of non-class type 'const int'
5 | return p.a-p.c<q.a-q.c;
| ^
a.cc:5:18: error: request for member 'c' in 'p', which is of non-class type 'const int'
5 | return p.a-p.c<q.a-q.c;
| ^
a.cc:5:22: error: request for member 'a' in 'q', which is of non-class type 'const int'
5 | return p.a-p.c<q.a-q.c;
| ^
a.cc:5:26: error: request for member 'c' in 'q', which is of non-class type 'const int'
5 | return p.a-p.c<q.a-q.c;
| ^
a.cc: At global scope:
a.cc:21:5: error: 'maxn' was not declared in this scope
21 | X s[maxn];
| ^~~~
a.cc: In function 'void Enter()':
a.cc:25:5: error: 'cin' was not declared in this scope
25 | cin>>x>>y>>z;
| ^~~
a.cc:25:10: error: 'x' was not declared in this scope
25 | cin>>x>>y>>z;
| ^
a.cc:25:13: error: 'y' was not declared in this scope
25 | cin>>x>>y>>z;
| ^
a.cc:25:16: error: 'z' was not declared in this scope
25 | cin>>x>>y>>z;
| ^
a.cc:26:5: error: 'n' was not declared in this scope
26 | n=x+y+z;
| ^
a.cc:28:14: error: 't' was not declared in this scope
28 | cin>>t[i].a>>t[i].b>>t[i].c;
| ^
a.cc:29:10: error: 't' was not declared in this scope
29 | sort(t+1,t+n+1,lf);
| ^
a.cc:29:5: error: 'sort' was not declared in this scope; did you mean 'short'?
29 | sort(t+1,t+n+1,lf);
| ^~~~
| short
a.cc: In function 'void Solve()':
a.cc:34:5: error: 'priority_queue' was not declared in this scope
34 | priority_queue<Tpq> l, r;
| ^~~~~~~~~~~~~~
a.cc:34:23: error: expected primary-expression before '>' token
34 | priority_queue<Tpq> l, r;
| ^
a.cc:34:25: error: 'l' was not declared in this scope; did you mean 'lf'?
34 | priority_queue<Tpq> l, r;
| ^
| lf
a.cc:34:28: error: 'r' was not declared in this scope
34 | priority_queue<Tpq> l, r;
| ^
a.cc:36:20: error: 'x' was not declared in this scope
36 | for(int i=1;i<=x+y;i++)
| ^
a.cc:36:22: error: 'y' was not declared in this scope
36 | for(int i=1;i<=x+y;i++)
| ^
a.cc:38:19: error: 't' was not declared in this scope
38 | l.push({i,t[i].b-t[i].a});
| ^
a.cc:46:9: error: 's' was not declared in this scope
46 | s[i]={sumx,sumy};
| ^
a.cc:49:15: error: 'n' was not declared in this scope
49 | for(int i=n;i>n-x-z;i--)
| ^
a.cc:49:21: error: 'x' was not declared in this scope
49 | for(int i=n;i>n-x-z;i--)
| ^
a.cc:49:23: error: 'z' was not declared in this scope
49 | for(int i=n;i>n-x-z;i--)
| ^
a.cc:51:19: error: 't' was not declared in this scope
51 | r.push({i,t[i].c-t[i].a});
| ^
a.cc:57:13: error: 'ans' was not declared in this scope
57 | ans=max(ans,sumx+sumz+s[i-1].x+s[i-1].y);
| ^~~
a.cc:57:35: error: 's' was not declared in this scope
57 | ans=max(ans,sumx+sumz+s[i-1].x+s[i-1].y);
| ^
a.cc:57:17: error: 'max' was not declared in this scope
57 | ans=max(ans,sumx+sumz+s[i-1].x+s[i-1].y);
| ^~~
a.cc:61:5: error: 'cout' was not declared in this scope
61 | cout<<ans;
| ^~~~
a.cc:61:11: error: 'ans' was not declared in this scope
61 | cout<<ans;
| ^~~
a.cc: In function 'int main()':
a.cc:66:5: error: 'ios_base' has not been declared
66 | ios_base::sync_with_stdio(false);
| ^~~~~~~~
a.cc:67:5: error: 'cin' was not declared in this scope
67 | cin.tie(nullptr);
| ^~~
a.cc:68:14: error: 'tasknames' was not declared in this scope
68 | if(fopen(tasknames".INP","r"))
| ^~~~~~~~~
a.cc:68:8: error: 'fopen' was not declared in this scope
68 | if(fopen(tasknames".INP","r"))
| ^~~~~
a.cc:1:1: note: 'fopen' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 |
a.cc:70:26: error: expected ')' before string constant
70 | freopen(tasknames".INP","r",stdin);
| ~ ^~~~~~
| )
a.cc:70:37: error: 'stdin' was not declared in this scope
70 | freopen(tasknames".INP","r",stdin);
| ^~~~~
a.cc:70:37: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:70:9: error: 'freopen' was not declared in this scope
70 | freopen(tasknames".INP","r",stdin);
| ^~~~~~~
a.cc:71:26: error: expected ')' before string constant
71 | freopen(tasknames".OUT","w",stdout);
| ~ ^~~~~~
| )
a.cc:71:37: error: 'stdout' was not declared in this scope
71 | freopen(tasknames".OUT","w",stdout);
| ^~~~~~
a.cc:71:37: note: 'stdout' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
|
s018368777 | p03653 | C++ | 考察頑張れ | a.cc:1:1: error: '\U00008003\U00005bdf\U00009811\U00005f35\U0000308c' does not name a type
1 | 考察頑張れ
| ^~~~~~~~~~
|
s730048304 | p03653 | C++ | ///****In the name of ALLAH, most Gracious, most Compassionate****//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)
#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl
template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
os<<"{"<<p.first<<","<<p.second<<"}";
return os;
}
const ll N=1e6+5;
ll lft[N];
ll rht[N];
ll a[N];
ll b[N];
ll c[N];
bool a_b(ll l,ll r)
{
return a[l]-b[l] >= a[r]-b[r];
}
ll32_t main()
{
FastIO;
ll x,y,z;
cin>>x>>y>>z;
ll n = x+y+z;
vector < ll > p (n,0);
ll ans = 0;
for(ll i=0; i<n; i++)
{
cin>>a[i]>>b[i]>>c[i];
p[i] = i;
}
sort(ALL(p), a_b);
{
priority_queue<ll > pq;
ll now = 0, q = 0;
for(ll i=0; i<n; i++)
{
ll ii = p[i];
now+=c[ii];
ll d= a[ii]-c[ii];
q+=d;
pq.push(-d);
if(pq.size() > x)
{
// assert(pq.size());
q+=pq.top();
pq.pop();
}
lft[i] =now + q;
}
}
{
priority_queue<ll > pq;
ll now = 0, q = 0;
for(ll i=n-1; i>=0; i--)
{
ll ii = p[i];
now+=c[ii];
ll d= b[ii]-c[ii];
q+=d;
pq.push(-d);
if(pq.size() > y)
{
q+=pq.top();
pq.pop();
}
rht[i] =now + q;
}
}
for(ll i=0; i<n-1; i++)
{
if(i+1 >= x and n-i-1 >= y)
ans = max(ans, lft[i] + rht[i+1]);
}
cout<<ans<<"\n";
}
| a.cc:39:1: error: 'll32_t' does not name a type
39 | ll32_t main()
| ^~~~~~
|
s985217216 | p03653 | C++ | #include"bits/stdc++.h"
using namespace std;
typedef long long ll;
// run : ctrl + c
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T>bool chmin(T &a,T b){if(b<a){a=b;return 1;} return 0;}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
int x,y,z;
cin>>x>>y>>z;
int n = x+y+z;
ll a[n],b[n],c[n];
array<ll,3> v[n];
for(int i=0;i<n;i++){
cin>>a[i]>>b[i]>>c[i];
v[i] = {b[i] - a[i],c[i],a[i]};
}
sort(v,v+n);
ll pre[n]={}, pos[n]={};
priority_queue<ll> pq;
for(int i=0;i<x;i++){
pq.push(v[i][1] - v[i][2]);
pre[i] = v[i][2];
if(i) pre[i] += pre[i-1];
//cerr << pre[i] << endl;
}
for(int i=x;i<x+z;i++){
pq.push(v[i][1] - v[i][2]);
ll p = pq.top();
pq.pop();
pre[i] += v[i][2];
pre[i] += pre[i-1] + p;
//cerr << pre[i] << endl;
}
while(pq.size()) pq.pop();
for(int i=0;i<y;i++){
pq.push(v[n-1-i][1] - (v[n-1-i][0]+v[n-1-i][2]));
pos[n-1-i] = v[n-1-i][0] + v[n-1-i][2];
if(i) pos[n-1-i] += pos[n-i];
}
for(int i=y;i<z+y;i++){
pq.push(v[n-1-i][1] - (v[n-1-i][0] + v[n-1-i][2]));
ll p = pq.top();
pq.pop();
pos[n-1-i] = v[n-1-i][0] + v[n-1-i][2];
pos[n-1-i] += pos[n-i] + p;
}
ll ans = 0;
for(int i=x-1;i<x+z;i++){
chmax(ans,pre[i]+pos[i+1]));
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:57:35: error: expected ';' before ')' token
57 | chmax(ans,pre[i]+pos[i+1]));
| ^
| ;
|
s025149282 | p03653 | C++ | #include"bits/stdc++.h"
using namespace std;
typedef long long ll;
// run : ctrl + c
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T>bool chmin(T &a,T b){if(b<a){a=b;return 1;} return 0;}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
int x,y,z;
cin>>x>>y>>z;
int n = x+y+z;
ll a[n],b[n],c[n];
array<ll,3> v[n];
for(int i=0;i<n;i++){
cin>>a[i]>>b[i]>>c[i];
v[i] = {b[i] - a[i],c[i],a[i]};
}
sort(v,v+n);
ll pre[n]={}, pos[n]={};
priority_queue<ll> pq;
for(int i=0;i<x;i++){
pq.push(v[i][1] - v[i][2]);
pre[i] = v[i][2];
if(i) pre[i] += pre[i-1];
//cerr << pre[i] << endl;
}
for(int i=x;i<x+z;i++){
pq.push(v[i][1] - v[i][2]);
ll p = pq.top();
pq.pop();
pre[i] += v[i][2];
pre[i] += pre[i-1] + p;
//cerr << pre[i] << endl;
}
while(pq.size()) pq.pop();
for(int i=0;i<y;i++){
pq.push(v[n-1-i][1] - (v[n-1-i][0]+v[n-1-i][2]));
pos[n-1-i] = v[n-1-i][0] + v[n-1-i][2];
if(i) pos[n-1-i] += pos[n-i];
}
for(int i=y;i<z+y;i++){
pq.push(v[n-1-i][1] - (v[n-1-i][0] + v[n-1-i][2]));
ll p = pq.top();
pq.pop();
pos[n-1-i] = v[n-1-i][0] + v[n-1-i][2];
pos[n-1-i] += pos[n-i] + p;
}
ll ans = 0;
for(int i=x-1;i<x+z;i++){
chmax(ans,pre[i]+pos[i+1]))
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:57:35: error: expected ';' before ')' token
57 | chmax(ans,pre[i]+pos[i+1]))
| ^
| ;
|
s952840781 | p03653 | C++ | #define int long long
using namespace std;
int xa[100010],ya[100010],za[100010];
int x,y,z;
int n;
bool cmp(int i,int j){
if (ya[i]-xa[i] > ya[j]-xa[j]) return 1;
return 0;
}
vector<int> v;
int ans1[100010],ans2[100010];
void solve1(){
int base = 0;
multiset<int> use,rest;
for (int i = 1; i <= x; i++){
base += xa[v[i]];
rest.insert(za[v[i]]-xa[v[i]]);
}
ans1[x] = base;
int optdif = 0;
// cout << x << " " << ans1[x-1] << "\n";
for (int i = x+1; i <= x+z; i++){
rest.insert(za[v[i]]-xa[v[i]]);
int v1 = *(--rest.end());
base += xa[v[i]];
optdif += v1;
rest.erase(rest.find(v1));
use.insert(v1);
ans1[i] = base+optdif;
// cout << i << " " << ans1[i] << "\n";
}
}
void solve2(){
int base = 0;
multiset<int> use,rest;
for (int i = n; i > n-y; i--){
base += ya[v[i]];
rest.insert(za[v[i]]-ya[v[i]]);
}
//cout << n-y+1 << " " << ans2[n-y+1] << "\n";
ans2[n-y+1] = base;
int optdif = 0;
for (int i = n-y; i > n-y-z; i--){
rest.insert(za[v[i]]-ya[v[i]]);
int v1 = *(--rest.end());
base += ya[v[i]];
optdif += v1;
rest.erase(rest.find(v1));
use.insert(v1);
ans2[i] = base+optdif;
//cout << i << " " << ans2[i]<< "\n";
}
}
main(){
cin >> x >> y >> z;
n = x+y+z;
for (int i = 1; i <= n; i++) {
cin >> xa[i] >> ya[i] >> za[i];
v.push_back(i);
}
sort(v.begin(),v.end(),cmp);
v.push_back(0);
reverse(v.begin(),v.end());
//for (int i = 1; i <= n; i++) cout << v[i] << " ";
//cout << "\n";
solve1();
solve2();
int ans = 0;
for (int i = x; i <= n-y; i++) ans = max(ans1[i]+ans2[i+1],ans);
cout << ans;
} | a.cc:10:1: error: 'vector' does not name a type
10 | vector<int> v;
| ^~~~~~
a.cc: In function 'void solve1()':
a.cc:14:5: error: 'multiset' was not declared in this scope
14 | multiset<int> use,rest;
| ^~~~~~~~
a.cc:1:1: note: 'std::multiset' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
+++ |+#include <set>
1 | #define int long long
a.cc:1:13: error: expected primary-expression before 'long'
1 | #define int long long
| ^~~~
a.cc:14:14: note: in expansion of macro 'int'
14 | multiset<int> use,rest;
| ^~~
a.cc:16:20: error: 'v' was not declared in this scope
16 | base += xa[v[i]];
| ^
a.cc:17:9: error: 'rest' was not declared in this scope
17 | rest.insert(za[v[i]]-xa[v[i]]);
| ^~~~
a.cc:24:9: error: 'rest' was not declared in this scope
24 | rest.insert(za[v[i]]-xa[v[i]]);
| ^~~~
a.cc:24:24: error: 'v' was not declared in this scope
24 | rest.insert(za[v[i]]-xa[v[i]]);
| ^
a.cc:29:9: error: 'use' was not declared in this scope
29 | use.insert(v1);
| ^~~
a.cc: In function 'void solve2()':
a.cc:36:5: error: 'multiset' was not declared in this scope
36 | multiset<int> use,rest;
| ^~~~~~~~
a.cc:36:5: note: 'std::multiset' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
a.cc:1:13: error: expected primary-expression before 'long'
1 | #define int long long
| ^~~~
a.cc:36:14: note: in expansion of macro 'int'
36 | multiset<int> use,rest;
| ^~~
a.cc:38:20: error: 'v' was not declared in this scope
38 | base += ya[v[i]];
| ^
a.cc:39:9: error: 'rest' was not declared in this scope
39 | rest.insert(za[v[i]]-ya[v[i]]);
| ^~~~
a.cc:45:9: error: 'rest' was not declared in this scope
45 | rest.insert(za[v[i]]-ya[v[i]]);
| ^~~~
a.cc:45:24: error: 'v' was not declared in this scope
45 | rest.insert(za[v[i]]-ya[v[i]]);
| ^
a.cc:50:9: error: 'use' was not declared in this scope
50 | use.insert(v1);
| ^~~
a.cc: At global scope:
a.cc:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
55 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:56:5: error: 'cin' was not declared in this scope
56 | cin >> x >> y >> z;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | #define int long long
a.cc:60:9: error: 'v' was not declared in this scope
60 | v.push_back(i);
| ^
a.cc:62:10: error: 'v' was not declared in this scope
62 | sort(v.begin(),v.end(),cmp);
| ^
a.cc:62:5: error: 'sort' was not declared in this scope; did you mean 'short'?
62 | sort(v.begin(),v.end(),cmp);
| ^~~~
| short
a.cc:64:5: error: 'reverse' was not declared in this scope
64 | reverse(v.begin(),v.end());
| ^~~~~~~
a.cc:70:42: error: 'max' was not declared in this scope
70 | for (int i = x; i <= n-y; i++) ans = max(ans1[i]+ans2[i+1],ans);
| ^~~
a.cc:71:5: error: 'cout' was not declared in this scope
71 | cout << ans;
| ^~~~
a.cc:71:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s372782989 | p03653 | C++ | #include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
//#define i_7 (long long)(1e9+7)
#define i_7 998'244'353
long mod(long a){
long long c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
long long po(long a, long b){
if(b==0){
return 1;
}
long long z = po(a,b/2);
z = mod(z*z);
if(b%2!=0){
z = mod(a*z);
}
return z;
}
using namespace std;
//using namespace boost::multiprecision;
bool prime_(int n){
if(n==1){
return false;
}else if(n==2){
return true;
}else{
for(int i=2;i<=sqrt(n);i++){
if(n%i==0){
return false;
}
}
return true;
}
}
long long gcd_(long long a, long long b){
if(a<b){
swap(a,b);
}
if(a%b==0){
return b;
}else{
return gcd_(b,a%b);
}
}
long long lcm_(long long x, long long y){
return (x/gcd_(x,y))*y;
}
int main(){
int x,y,z;
cin>>x>>y>>z;
int n = x + y + z;
long long a[n],b[n],c[n];
typedef P pair<long long, long long>;
vector<pair<long long, P>> vec;
REP(i,n){
cin>>a[i]>>b[i]>>c[i];
long long d = a[i] - b[i];
long long ta = a[i] - c[i];
long long tb = b[i] - c[i];
vec.push_back(make_pair(d, P(ta,tb)));
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:73:11: error: 'P' does not name a type; did you mean 'PI'?
73 | typedef P pair<long long, long long>;
| ^
| PI
a.cc:74:26: error: 'P' was not declared in this scope
74 | vector<pair<long long, P>> vec;
| ^
a.cc:74:26: error: template argument 2 is invalid
a.cc:74:27: error: template argument 1 is invalid
74 | vector<pair<long long, P>> vec;
| ^~
a.cc:74:27: error: template argument 2 is invalid
a.cc:80:9: error: request for member 'push_back' in 'vec', which is of non-class type 'int'
80 | vec.push_back(make_pair(d, P(ta,tb)));
| ^~~~~~~~~
|
s033442588 | p03653 | C++ | #include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define For(i,a,b) for(int i=a;i>=b;i--)
#define Maxn 100002
#define inf 100002
#define int long long
using namespace std;
int read(){
char c=getchar(); int flag=1, x=0;
while(!isdigit(c)){ if(c=='-') flag=-1; c=getchar(); }
while( isdigit(c)){ x=x*10+(c-'0'); c=getchar(); }
return flag*x;
}
int X,Y,Z;
int S,T;
struct FYL{
struct LINE{
int st,en,lim,val,pre;
}line[Maxn*10+10];
int head[Maxn+10], tot=1;
void add(int a,int b,int z,int c){
line[++tot]=(LINE){ a,b,z,c,head[a] }; head[a]=tot;
}
#define make_pair mp
int visit[Maxn+10], dist[Maxn+10], last[Maxn+10], minflow[Maxn+10];
priority_queue < pair<int,int> > Q;
bool spfa(int S,int T){
//cout<<" Do \n";
//queue< int > Q;
//priority_queue< pair<int,int> > Q;
memset(visit,0,sizeof(visit));
memset(dist,0,sizeof(dist));
minflow[S]=inf;
Q.push(mp(0,S)); dist[S]=0; visit[S]=0; last[S]=0;
while(Q.size()){
int now=Q.top().second; Q.pop();
if(visit[now]) continue;
visit[now]=1;
for(int i=head[now];i;i=line[i].pre){
int E=line[i].en;
if(!line[i].lim) continue;
if(dist[now]+line[i].val>dist[E]){
dist[E]=dist[now]+line[i].val;
minflow[E]=min(minflow[now],line[i].lim);
last[E]=i;
Q.push(mk(dist[E],E));
//if(!visit[E]) Q.push(E), visit[E]=1;
}
}
}
if(dist[T]==dist[T+1]) return false;
return true;
//return dist[T];
}
int maxflow, ans;
void update(int S,int T){
int now=T;
while(now!=S){
int i=last[now];
line[i].lim-=minflow[T];
line[i^1].lim+=minflow[T];
now=line[i].st;
}
maxflow+=minflow[T];
ans+=dist[T]*minflow[T];
}
}deal;
void init(){
S=0, T=X+Y+Z+4;
deal.add(0,1,X,0); deal.add(1,0,0,0);
deal.add(0,2,Y,0); deal.add(2,0,0,0);
deal.add(0,3,Z,0); deal.add(3,0,0,0);
FOR(i,1,X+Y+Z){
deal.add(i+3,T,1,0), deal.add(T,i+3,0,0);
}
}
signed main(){
X=read(), Y=read(), Z=read();
init();
FOR(i,1,X+Y+Z){
int v1=read(), v2=read(), v3=read();
deal.add(1,i+3,1,v1), deal.add(i+3,1,0,-v1);
deal.add(2,i+3,1,v2), deal.add(i+3,2,0,-v2);
deal.add(3,i+3,1,v3), deal.add(i+3,3,0,-v3);
}
while( deal.spfa(S,T) ) deal.update(S,T);
cout<<-deal.ans<<endl;
return 0;
}
| a.cc: In member function 'bool FYL::spfa(long long int, long long int)':
a.cc:38:16: error: 'mp' was not declared in this scope
38 | Q.push(mp(0,S)); dist[S]=0; visit[S]=0; last[S]=0;
| ^~
a.cc:50:28: error: 'mk' was not declared in this scope
50 | Q.push(mk(dist[E],E));
| ^~
|
s308015999 | p03653 | C++ | #include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define For(i,a,b) for(int i=a;i>=b;i--)
#define Maxn 100002
#define inf 100002
#define int long long
using namespace std;
int read(){
char c=getchar(); int flag=1, x=0;
while(!isdigit(c)){ if(c=='-') flag=-1; c=getchar(); }
while( isdigit(c)){ x=x*10+(c-'0'); c=getchar(); }
return flag*x;
}
int X,Y,Z;
int S,T;
struct FYL{
struct LINE{
int st,en,lim,val,pre;
}line[Maxn*10+10];
int head[Maxn+10], tot=1;
void add(int a,int b,int z,int c){
line[++tot]=(LINE){ a,b,z,c,head[a] }; head[a]=tot;
}
#define make_pair mp
int visit[Maxn+10], dist[Maxn+10], last[Maxn+10], minflow[Maxn+10];
bool spfa(int S,int T){
//cout<<" Do \n";
//queue< int > Q;
priority_queue< pair<int,int> > Q;
memset(visit,0,sizeof(visit));
memset(dist,0,sizeof(dist));
minflow[S]=inf;
Q.push(mp(0,S)); dist[S]=0; visit[S]=0; last[S]=0;
while(Q.size()){
int now=Q.top().second; Q.pop();
if(visit[now]) continue;
visit[now]=1;
for(int i=head[now];i;i=line[i].pre){
int E=line[i].en;
if(!line[i].lim) continue;
if(dist[now]+line[i].val>dist[E]){
dist[E]=dist[now]+line[i].val;
minflow[E]=min(minflow[now],line[i].lim);
last[E]=i;
Q.push(mk(dist[E],E));
//if(!visit[E]) Q.push(E), visit[E]=1;
}
}
}
if(dist[T]==dist[T+1]) return false;
return true;
//return dist[T];
}
int maxflow, ans;
void update(int S,int T){
int now=T;
while(now!=S){
int i=last[now];
line[i].lim-=minflow[T];
line[i^1].lim+=minflow[T];
now=line[i].st;
}
maxflow+=minflow[T];
ans+=dist[T]*minflow[T];
}
}deal;
void init(){
S=0, T=X+Y+Z+4;
deal.add(0,1,X,0); deal.add(1,0,0,0);
deal.add(0,2,Y,0); deal.add(2,0,0,0);
deal.add(0,3,Z,0); deal.add(3,0,0,0);
FOR(i,1,X+Y+Z){
deal.add(i+3,T,1,0), deal.add(T,i+3,0,0);
}
}
signed main(){
X=read(), Y=read(), Z=read();
init();
FOR(i,1,X+Y+Z){
int v1=read(), v2=read(), v3=read();
deal.add(1,i+3,1,v1), deal.add(i+3,1,0,-v1);
deal.add(2,i+3,1,v2), deal.add(i+3,2,0,-v2);
deal.add(3,i+3,1,v3), deal.add(i+3,3,0,-v3);
}
while( deal.spfa(S,T) ) deal.update(S,T);
cout<<-deal.ans<<endl;
return 0;
}
| a.cc: In member function 'bool FYL::spfa(long long int, long long int)':
a.cc:37:16: error: 'mp' was not declared in this scope
37 | Q.push(mp(0,S)); dist[S]=0; visit[S]=0; last[S]=0;
| ^~
a.cc:49:28: error: 'mk' was not declared in this scope
49 | Q.push(mk(dist[E],E));
| ^~
|
s435972071 | p03653 | C++ | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct P{
int a, b, c;
P(int x, int y, int z){
a = x; b = y; c = z;
}
bool operator<(const P &x)const{
return a-b < x.a-x. b;
};
};
int main(void){
int x, y, z;
long long ans = 0, left[100000], right[100000];
vector<P> v;
priority_queue<int> q;
cin >> x >> y >> z;
for(int i=0;i<x+y+z;i++){
int a, b, c;
cin >> a >> b >> c;
v.push_back(P(a, b, c));
}
sort(v.begin(), v.end());
left[0] = 0;
for(int i=0;i<y;i++){
left[0] += v[i].b;
q.push(v[i].c-v[i].b);
}
for(int i=1;i<=z;i++){
int t = y-1+i;
left[i] = left[i-1] + v[t].b;
q.push(v[t].c - v[t].b);
left[i] += q.top();
q.pop();
}
while(!q.empty())q.pop();
right[0] = 0;
for(int i=y+z;i<x+y+z;i++){
right[0] += v[i].a;
q.push(v[i].c-v[i].a);
}
for(int i=1;i<=z;i++){
int t = y+z-i;
right[i] = right[i-1] + v[t].a;
q.push(v[t].c - v[t].a);
right[i] += q.top();
q.pop();
}
for(int i=0;i<=z;i++){
ans = max(ans, left[i] + right[z-i]);
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:25:5: error: 'sort' was not declared in this scope; did you mean 'short'?
25 | sort(v.begin(), v.end());
| ^~~~
| short
|
s339778441 | p03653 | C++ | // author: Saman Mahdanian
#include<bits/stdc++.h>
const int N = 1e5 + 10;
using namespace std;
struct person {
int a, b, c;
void read() {
cin >> a >> b >> c;
}
};
long long n, X, Y, Z, a[N], b[N], c[N], lsum[3], rsum[3];
set <pair <long long, int> > leftHand[3], rightHand[3];
person p[N];
int main() {
cin >> X >> Y >> Z;
n = X + Y + Z;
for (int i = 0; i < n; i++)
p[i].read();
sort (p, p + n, [] (person i, person j) {
return i.b - i.c > j.b - j.c;
});
for (int i = 0; i < n; i++)
a[i] = p[i].a, b[i] = p[i].b, c[i] = p[i].c;
long long curVal = 0;
for (int i = 0; i < Y; i++) {
leftHand[0].insert({b[i] - a[i], i});
curVal += b[i];
}
for (int i = Y; i < n; i++) {
rightHand[0].insert({c[i] - a[i], i});
curVal += c[i];
}
for (int i = 0; i < X; i++) {
auto h = *rightHand[0].begin();
rightHand[0].erase(h);
rightHand[1].insert(h);
curVal += a[h.second] - c[h.second];
}
long long ans = curVal;
for (int e = Y; e < Y + X; e++) {
bool flag = false;
for (auto i: {0, 1})
if (rightHand[i].find({c[e] - a[e], e}) != rightHand[i].end()) {
rightHand[i].erase({c[e] - a[e], e});
curVal -= (i == 0)? c[e] : a[e];
flag = true;
}
assert(flag);
leftHand[1].insert({b[e] - a[e], e});
curVal += a[e];
if (*leftHand[1].rbegin() > *leftHand[0].begin()) {
auto v = *leftHand[1].rbegin();
auto u = *leftHand[0].begin();
lsum[1] += a[u.second] - a[v.second];
lsum[0] += b[v.second] - b[u.second];
leftHand[1].insert(u);
leftHand[0].insert(v);
}
ans = max(ans, curVal());
}
cout << ans << endl;
}
// SamMHD :: May24-2019 :: Another Soale Jazzzzab... | a.cc: In function 'int main()':
a.cc:72:38: error: 'curVal' cannot be used as a function
72 | ans = max(ans, curVal());
| ~~~~~~^~
|
s965194914 | p03653 | C++ | from heapq import*
f=lambda*z:map(int,raw_input().split())
X,Y,Z=f()
P=[]
Q=[]
L=[0]
R=[0]
r=range(X+Y+Z)
A=sorted(map(f,r),key=lambda a:a[0]-a[1])
for i in r:L[i]-=i>Y and heappop(P);a=A[i];L+=[L[i]+a[1]];heappush(P,a[1]-a[2]);R[i]-=i>X and heappop(Q);a=A[~i];R+=[R[i]+a[0]];heappush(Q,a[0]-a[2])
#print max(L[i]+R[~i]for i in range(Y,Y+Z+1))
print max(Z<i-Y<0 or L[i]+R[~i]for i in r) | a.cc:11:2: error: invalid preprocessing directive #print
11 | #print max(L[i]+R[~i]for i in range(Y,Y+Z+1))
| ^~~~~
a.cc:1:1: error: 'from' does not name a type
1 | from heapq import*
| ^~~~
a.cc:10:37: error: 'a' does not name a type
10 | for i in r:L[i]-=i>Y and heappop(P);a=A[i];L+=[L[i]+a[1]];heappush(P,a[1]-a[2]);R[i]-=i>X and heappop(Q);a=A[~i];R+=[R[i]+a[0]];heappush(Q,a[0]-a[2])
| ^
a.cc:10:44: error: 'L' does not name a type
10 | for i in r:L[i]-=i>Y and heappop(P);a=A[i];L+=[L[i]+a[1]];heappush(P,a[1]-a[2]);R[i]-=i>X and heappop(Q);a=A[~i];R+=[R[i]+a[0]];heappush(Q,a[0]-a[2])
| ^
a.cc:10:67: error: expected constructor, destructor, or type conversion before '(' token
10 | for i in r:L[i]-=i>Y and heappop(P);a=A[i];L+=[L[i]+a[1]];heappush(P,a[1]-a[2]);R[i]-=i>X and heappop(Q);a=A[~i];R+=[R[i]+a[0]];heappush(Q,a[0]-a[2])
| ^
a.cc:10:81: error: 'R' does not name a type
10 | for i in r:L[i]-=i>Y and heappop(P);a=A[i];L+=[L[i]+a[1]];heappush(P,a[1]-a[2]);R[i]-=i>X and heappop(Q);a=A[~i];R+=[R[i]+a[0]];heappush(Q,a[0]-a[2])
| ^
a.cc:10:106: error: 'a' does not name a type
10 | for i in r:L[i]-=i>Y and heappop(P);a=A[i];L+=[L[i]+a[1]];heappush(P,a[1]-a[2]);R[i]-=i>X and heappop(Q);a=A[~i];R+=[R[i]+a[0]];heappush(Q,a[0]-a[2])
| ^
a.cc:10:114: error: 'R' does not name a type
10 | for i in r:L[i]-=i>Y and heappop(P);a=A[i];L+=[L[i]+a[1]];heappush(P,a[1]-a[2]);R[i]-=i>X and heappop(Q);a=A[~i];R+=[R[i]+a[0]];heappush(Q,a[0]-a[2])
| ^
a.cc:10:137: error: expected constructor, destructor, or type conversion before '(' token
10 | for i in r:L[i]-=i>Y and heappop(P);a=A[i];L+=[L[i]+a[1]];heappush(P,a[1]-a[2]);R[i]-=i>X and heappop(Q);a=A[~i];R+=[R[i]+a[0]];heappush(Q,a[0]-a[2])
| ^
|
s191641434 | p03653 | C++ | #include<cctype>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;
const int N=1e5+500,inf=0x7fffffff;
int gti(void)
{
char c=getchar();
int ret=0,st=1;
for (;!isdigit(c);c=getchar()) if (c=='-') st=-1;
for (;isdigit(c);c=getchar()) ret=ret*10+c-'0';
return ret*st;
}
struct P
{
int b,c;
bool operator<(const P &y)const
{
return b>y.b||(b==y.b&&c>y.c);
}
}p[N];
struct Treap
{
struct T{int s[2],val,id,tot,sum;}t[N];
int rt,cnt;
#define ls t[v].s[0]
#define rs t[v].s[1]
void pu(int v)
{
t[v].tot=t[ls].tot+t[rs].tot+1;
t[v].sum=t[v].val+t[ls].sum+t[rs].sum;
}
void split(int v,int k,int &x,int &y)
{
if (!v) return (void)(x=y=0);
if (k<=t[ls].tot)
split(ls,k,x,y),ls=y,y=v;
else split(rs,k-t[ls].tot-1,x,y),rs=x,x=v;
pu(v);
}
int merge(int a,int b)
{
if (!a||!b) return a|b;
int v;
if (t[a].id<t[b].id)
v=a,rs=merge(rs,b);
else v=b,ls=merge(a,ls);
pu(v);
return v;
}
int getrank(int v,int val)
{
if (!v) return 1;
if (t[v].val<val)
return t[ls].tot+1+getrank(rs,val);
return getrank(ls,val);
}
void insert(int val)
{
int k=getrank(rt,val),x,y;
split(rt,k-1,x,y);
t[++cnt]=(T){{0,0},val,rand(),1,val};
rt=merge(x,cnt);
rt=merge(rt,y);
}
void clear(void)
{
rt=cnt=0;
}
int query(int k)
{
int x,y,ret;
split(rt,t[rt].tot-k,x,y);
ret=t[y].sum;
rt=merge(x,y);
return ret;
}
}t;
int ans[N];
#undef int
int main(void)
#define int long long
{
int x=gti(),y=gti(),z=gti(),sum=0,n=x+y+z;
for (int i=1;i<=n;i++)
{
int a=gti();
p[i].b=gti()-a,p[i].c=gti()-a;
sum+=a;
}
sort(p+1,p+1+n);
int sum2=0;
for (int i=1;i<=n;i++)
{
sum2+=p[i].b,t.insert(p[i].c-p[i].b);
if (i>=y)
ans[i]=sum2+t.query(i-y);
}
t.clear();
for (int i=n;i>=1;i--)
{
if (i<=y+z)
ans[i]+=t.query(y+z-i);
t.insert(p[i].c);
}
int mx=-inf;
for (int i=y;i<=y+z;i++)
mx=max(mx,ans[i]);
printf("%lld\n",mx+sum);
return 0;
}
| a.cc: In function 'long long int gti()':
a.cc:10:12: error: 'getchar' was not declared in this scope
10 | char c=getchar();
| ^~~~~~~
a.cc:4:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
3 | #include<algorithm>
+++ |+#include <cstdio>
4 | #define int long long
a.cc: In function 'int main()':
a.cc:114:5: error: 'printf' was not declared in this scope
114 | printf("%lld\n",mx+sum);
| ^~~~~~
a.cc:114:5: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
|
s137671188 | p03653 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
const int N = 1e5 + 5;
multiset <int> l1,l2,r1,r2;
multiset <int> :: iterator it,it2;
int x,y,z,n,a[N],b[N],c[N],id[N];
ll suml,sumr,sumc,ans,nice;
void add_l(int x){
if (l1.size() < ::x) {
suml += a[x];
l1.insert(-a[x]);
}
else {
it = l1.rbegin();
if (-*it < a[x]) {
suml += a[x];
suml -= -*it;
l2.insert(*it);
l1.erase(iit);
l1.insert(-a[x]);
}
else
l2.insert(-a[x]);
}
}
void add_r(int x) {
if (r1.size() < y) {
sumr += b[x];
r1.insert(-b[x]);
}
else {
it = r1.rbegin();
if (-*it < b[x]) {
sumr += b[x];
sumr -= -*it;
r2.insert(*it);
r1.erase(it);
r1.insert(-b[x]);
}
else
r2.insert(-b[x]);
}
}
void remove_r(int x) {
if (r2.empty()) {
if (r1.empty())
return;
it = r1.find(-b[x]);
if (it != r1.end()) {
sumr -= -*it;
r1.erase(it);
}
}
else {
it = r2.find(-b[x]);
if (it != r2.end()) {
r2.erase(it);
return;
}
it = r1.find(-b[x]);
if (it != r1.end()) {
sumr -= -*it;
r1.erase(it);
if (r2.empty() == false) {
it2 = r2.begin();
sumr += -*it2;
r1.insert(*it2);
r2.erase(it2);
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> x >> y >> z;
n = x + y + z;
for (int i = 1 ; i <= n ; i++) {
cin >> a[i] >> b[i] >> c[i];
a[i] -= c[i];
b[i] -= c[i];
nice += c[i];
id[i] = i;
}
sort(id + 1,id + n + 1,[&](int x,int y) {
if (a[x] - b[x] == a[y] - b[y])
return a[x] >= a[y];
return a[x] - b[x] > a[y] - b[y];
});
for (int i = 1 ; i <= x ; i++)
add_l(id[i]);
for (int i = x + 1 ; i <= n ; i++)
add_r(id[i]);
ans = suml + sumr;
for (int i = x + 1 ; i <= n ; i++) {
if (n - i < y)
break;
add_l(id[i]);
remove_r(id[i]);
ans = max(ans,suml + sumr);
}
cout << ans + nice << "\n";
} | a.cc:14:23: error: 'll nice' redeclared as different kind of entity
14 | ll suml,sumr,sumc,ans,nice;
| ^~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
from /usr/include/signal.h:328,
from /usr/include/c++/14/csignal:42,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
from a.cc:1:
/usr/include/unistd.h:619:12: note: previous declaration 'int nice(int)'
619 | extern int nice (int __inc) __THROW __wur;
| ^~~~
a.cc: In function 'void add_l(int)':
a.cc:22:20: error: no match for 'operator=' (operand types are 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'})
22 | it = l1.rbegin();
| ^
In file included from /usr/include/c++/14/map:62,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(const std::_Rb_tree_const_iterator<int>&)'
324 | struct _Rb_tree_const_iterator
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:324:12: note: no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'const std::_Rb_tree_const_iterator<int>&'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(std::_Rb_tree_const_iterator<int>&&)'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'std::_Rb_tree_const_iterator<int>&&'
a.cc:27:16: error: 'iit' was not declared in this scope; did you mean 'it'?
27 | l1.erase(iit);
| ^~~
| it
a.cc: In function 'void add_r(int)':
a.cc:41:20: error: no match for 'operator=' (operand types are 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'})
41 | it = r1.rbegin();
| ^
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(const std::_Rb_tree_const_iterator<int>&)'
324 | struct _Rb_tree_const_iterator
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:324:12: note: no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'const std::_Rb_tree_const_iterator<int>&'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(std::_Rb_tree_const_iterator<int>&&)'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'std::_Rb_tree_const_iterator<int>&&'
a.cc: In function 'int main()':
a.cc:93:10: warning: pointer to a function used in arithmetic [-Wpointer-arith]
93 | nice += c[i];
| ~~~~~^~~~~~~
a.cc:93:10: error: assignment of read-only location 'nice'
a.cc:113:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
113 | cout << ans + nice << "\n";
| ~~~~^~~~~~
|
s949852276 | p03653 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
const int N = 1e5 + 5;
multiset <int> l1,l2,r1,r2;
multiset <int> :: iterator it,it2;
int x,y,z,n,a[N],b[N],c[N],id[N];
ll suml,sumr,sumc,ans,nice;
void add_l(int x){
if (l1.size() < ::x) {
suml += a[x];
l1.insert(-a[x]);
}
else {
it = l1.rbegin();
if (-*it < a[x]) {
suml += a[x];
suml -= -*it;
l2.insert(*it);
l1.erase(iit);
l1.insert(-a[x]);
}
else
l2.insert(-a[x]);
}
}
void add_r(int x) {
if (r1.size() < y) {
sumr += b[x];
r1.insert(-b[x]);
}
else {
it = r1.rbegin();
if (-*it < b[x]) {
sumr += b[x];
sumr -= -*it;
r2.insert(*it);
r1.erase(it);
r1.insert(-b[x]);
}
else
r2.insert(-b[x]);
}
}
void remove_r(int x) {
if (r2.empty()) {
if (r1.empty())
break;
it = r1.find(-b[x]);
if (it != r1.end()) {
sumr -= -*it;
r1.erase(it);
}
}
else {
it = r2.find(-b[x]);
if (it != r2.end()) {
r2.erase(it);
return;
}
it = r1.find(-b[x]);
if (it != r1.end()) {
sumr -= -*it;
r1.erase(it);
if (r2.empty() == false) {
it2 = r2.begin();
sumr += -*it2;
r1.insert(*it2);
r2.erase(it2);
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> x >> y >> z;
n = x + y + z;
for (int i = 1 ; i <= n ; i++) {
cin >> a[i] >> b[i] >> c[i];
a[i] -= c[i];
b[i] -= c[i];
nice += c[i];
id[i] = i;
}
sort(id + 1,id + n + 1,[&](int x,int y) {
if (a[x] - b[x] == a[y] - b[y])
return a[x] >= a[y];
return a[x] - b[x] > a[y] - b[y];
});
for (int i = 1 ; i <= x ; i++)
add_l(id[i]);
for (int i = x + 1 ; i <= n ; i++)
add_r(id[i]);
ans = suml + sumr;
for (int i = x + 1 ; i <= n ; i++) {
if (n - i < y)
break;
add_l(id[i]);
remove_r(id[i]);
ans = max(ans,suml + sumr);
}
cout << ans + nice << "\n";
} | a.cc:14:23: error: 'll nice' redeclared as different kind of entity
14 | ll suml,sumr,sumc,ans,nice;
| ^~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
from /usr/include/signal.h:328,
from /usr/include/c++/14/csignal:42,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
from a.cc:1:
/usr/include/unistd.h:619:12: note: previous declaration 'int nice(int)'
619 | extern int nice (int __inc) __THROW __wur;
| ^~~~
a.cc: In function 'void add_l(int)':
a.cc:22:20: error: no match for 'operator=' (operand types are 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'})
22 | it = l1.rbegin();
| ^
In file included from /usr/include/c++/14/map:62,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(const std::_Rb_tree_const_iterator<int>&)'
324 | struct _Rb_tree_const_iterator
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:324:12: note: no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'const std::_Rb_tree_const_iterator<int>&'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(std::_Rb_tree_const_iterator<int>&&)'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'std::_Rb_tree_const_iterator<int>&&'
a.cc:27:16: error: 'iit' was not declared in this scope; did you mean 'it'?
27 | l1.erase(iit);
| ^~~
| it
a.cc: In function 'void add_r(int)':
a.cc:41:20: error: no match for 'operator=' (operand types are 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'})
41 | it = r1.rbegin();
| ^
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(const std::_Rb_tree_const_iterator<int>&)'
324 | struct _Rb_tree_const_iterator
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:324:12: note: no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'const std::_Rb_tree_const_iterator<int>&'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<int>& std::_Rb_tree_const_iterator<int>::operator=(std::_Rb_tree_const_iterator<int>&&)'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: no known conversion for argument 1 from 'std::multiset<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'std::_Rb_tree_const_iterator<int>&&'
a.cc: In function 'void remove_r(int)':
a.cc:57:7: error: break statement not within loop or switch
57 | break;
| ^~~~~
a.cc: In function 'int main()':
a.cc:93:10: warning: pointer to a function used in arithmetic [-Wpointer-arith]
93 | nice += c[i];
| ~~~~~^~~~~~~
a.cc:93:10: error: assignment of read-only location 'nice'
a.cc:113:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
113 | cout << ans + nice << "\n";
| ~~~~^~~~~~
|
s937194214 | p03653 | C++ | #include<cstdio>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<vector>
using namespace std;
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
// getchar
#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
// print the remaining part
inline void flush () {
fwrite (obuf, 1, oS - obuf, stdout);
oS = obuf;
}
// putchar
inline void putc (char x) {
*oS ++ = x;
if (oS == oT) flush ();
}
// input a signed integer
template <class I>
inline void read (I &x) {
for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
}
// print a signed integer
template <class I>
inline void print (I x) {
if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
while (x) qu[++ qr] = x % 10 + '0', x /= 10;
while (qr) putc (qu[qr --]);
}
//no need to call flush at the end manually!
struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;
typedef long long LL;
const int MaxN = 1e5;
struct node{
LL a, b, c;
bool operator <(const node &A) const{
return (a-b) < A.a - A.b;
}
}a[100005];
int n, x, y, z;
LL tot, ans;
priority_queue<LL, vector<LL>, greater<LL> > q;
LL lef[MaxN + 5];
int main(){
int i,j,k;
read(x),read(y),read(z);
n=x+y+z;
for(i = 1; i <= n; i++){
read(a[i].a),read(a[i].b),read(a[i].c);
tot += a[i].c;
}
sort(a + 1, a + 1 + n);
LL ans = 0, sum = 0;
for(i = 1; i <= y; i++){
sum += a[i].b - a[i].c;
q.push(a[i].b - a[i].c);
}
for(i = y + 1; i <= n - x + 1; i++){
lef[i] = sum;
sum += a[i].b - a[i].c;
q.push(a[i].b - a[i].c);
sum -= q.top();
q.pop();
}
while(!q.empty()) q.pop(); sum = 0;
for(i = n; i > n - x; i--){
sum += a[i].a - a[i].c;
q.push(a[i].a - a[i].c);
}
for(i=n-x;i>=y;i--)
{
ans=max(ans,tot+lef[i+1],sum);
sum+=a[i].a-a[i].c;
q.push(a[i].a-a[i].c);
sum-=q.top();
q.pop();
}
print(ans),putc('\n');
return 0;
}
| 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:2:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
a.cc:87:10: required from here
87 | ans=max(ans,tot+lef[i+1],sum);
| ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function
306 | if (__comp(__a, __b))
| ~~~~~~^~~~~~~~~~
|
s215000384 | p03653 | C++ | 6 2 4
33189 87907 277349742
71616 46764 575306520
8801 53151 327161251
58589 4337 796697686
66854 17565 289910583
50598 35195 478112689
13919 88414 103962455
7953 69657 699253752
44255 98144 468443709
2332 42580 752437097
39752 19060 845062869
60126 74101 382963164 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 6 2 4
| ^
|
s922439516 | p03653 | Java | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.io.IOException;
import java.util.Queue;
import java.util.ArrayDeque;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
TaskC solver = new TaskC();
solver.solve(1, in, out);
out.close();
}
static class TaskC {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int x = in.nextInt();
int y = in.nextInt();
int z = in.nextInt();
int n = x + y + z;
MinCostMaxFlowNetwork g = new MinCostMaxFlowNetwork(n + 3 + 2);
int source = n + 3;
int sink = n + 4;
int[] a = new int[n];
int[] b = new int[n];
int[] c = new int[n];
for (int i = 0; i < n; ++i) {
a[i] = in.nextInt();
b[i] = in.nextInt();
c[i] = in.nextInt();
g.addEdge(i, sink, 1, 0);
g.addEdge(n + 0, i, 1, -a[i]);
g.addEdge(n + 1, i, 1, -b[i]);
g.addEdge(n + 2, i, 1, -c[i]);
}
g.addEdge(source, n + 0, x, 0);
g.addEdge(source, n + 1, y, 0);
g.addEdge(source, n + 2, z, 0);
long ans = g.flow(source, sink)[1];
out.println(-ans);
}
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
if (numChars == -1)
throw new UnknownError();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new UnknownError();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public int nextInt() {
return Integer.parseInt(next());
}
public String next() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuffer res = new StringBuffer();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
private boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
}
static class MinCostMaxFlowNetwork {
private static final int initialEdgeCapacity = 3;
public static long Inf = 1L << 62;
private long[] _capacity;
private long[] _flow;
private long[] _cost;
private int[] _from;
| Main.java:112: error: reached end of file while parsing
private int[] _from;
^
1 error
|
s032898384 | p03653 | Java | import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
public class Main {
static InputStream is;
static PrintWriter out;
static String INPUT = "";
static void solve()
{
int x = ni(), y = ni(), z = ni();
int n = x+y+z;
int[][] ds = new int[n][];
long asum = 0;
for(int i = 0;i < n;i++){
ds[i] = na(3);
ds[i][1] -= ds[i][0];
ds[i][2] -= ds[i][0];
asum += ds[i][0];
}
Arrays.sort(ds, new Comparator<int[]>() {
public int compare(int[] a, int[] b) {
return -(a[1] - b[1]);
}
});
long[] gain = new long[n+1];
{
KMajorPriorityQueue kmjp = new KMajorPriorityQueue();
for(int i = 0;i < n;i++){
kmjp.add(ds[i][2]-ds[i][1]);
gain[i+1] += kmjp.kMajorSum(i+1-y);
}
}
{
KMajorPriorityQueue kmjp = new KMajorPriorityQueue();
for(int i = n-1;i >= 0;i--){
kmjp.add(ds[i][2]);
gain[i] += kmjp.kMajorSum(z-(i-y));
}
}
long sum = 0;
for(int i = 0;i < n;i++){
sum += ds[i][1];
gain[i+1] += sum;
}
long max = 0;
for(int i = y;i <= y+z;i++){
max = Math.max(max, gain[i] + asum);
}
out.println(max);
}
public static class SimpleMinHeapL {
public long[] a;
public int n;
public int pos;
public static final long INF = Long.MAX_VALUE;
public SimpleMinHeapL(int m)
{
n = m+1;
a = new long[n];
Arrays.fill(a, INF);
pos = 1;
}
public SimpleMinHeapL(long[] in)
{
n = in.length+1;
if((n&1)==1)n++;
a = new long[n];
pos = 1+in.length;
// Arrays.fill(a, INF);
a[0] = a[n-1] = a[n-2] = INF;
System.arraycopy(in, 0, a, 1, in.length);
for(int t = pos/2-1;t >= 1;t--){
for(int c = t;2*c < pos;){
int smaller = a[2*c] < a[2*c+1] ? 2*c : 2*c+1;
if(a[smaller] < a[c]){
long d = a[c]; a[c] = a[smaller]; a[smaller] = d;
c = smaller;
}else{
break;
}
}
}
}
public void add(long x)
{
a[pos++] = x;
for(int c = pos-1, p = c>>>1;p >= 1 && a[c] < a[p];c>>>=1, p>>>=1){
long d = a[p]; a[p] = a[c]; a[c] = d;
}
}
public long poll()
{
if(pos == 1)return INF;
pos--;
long ret = a[1];
a[1] = a[pos];
a[pos] = INF;
for(int c = 1;2*c < pos;){
int smaller = a[2*c] < a[2*c+1] ? 2*c : 2*c+1;
if(a[smaller] < a[c]){
long d = a[c]; a[c] = a[smaller]; a[smaller] = d;
c = smaller;
}else{
break;
}
}
return ret;
}
public long min() { return a[1]; }
public int size() { return pos-1; }
}
public static class KMajorPriorityQueue
{
SimpleMinHeapL pq, ipq;
long sum;
public KMajorPriorityQueue() {
pq = new SimpleMinHeapL(100000);
ipq = new SimpleMinHeapL(100000);
sum = 0;
}
public void add(long v) {
pq.add(v);
sum += v;
}
public long kMajorSum(int K) {
if(K < 0)K = 0;
// remove
while(pq.size() > K){
long v = pq.poll();
ipq.add(-v);
sum -= v;
}
// add
while(pq.size() < K){
long v = -ipq.poll();
pq.add(v);
sum += v;
}
// exchange
while(ipq.size() > 0 && pq.size() > 0 && pq.peek() < -ipq.peek()){
long e = pq.poll(), f = -ipq.poll();
sum -= e; sum += f;
pq.add(f);
ipq.add(-e);
}
return sum;
}
}
public static void main(String[] args) throws Exception
{
long S = System.currentTimeMillis();
is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
out = new PrintWriter(System.out);
solve();
out.flush();
long G = System.currentTimeMillis();
tr(G-S+"ms");
}
private static boolean eof()
{
if(lenbuf == -1)return true;
int lptr = ptrbuf;
while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;
try {
is.mark(1000);
while(true){
int b = is.read();
if(b == -1){
is.reset();
return true;
}else if(!isSpaceChar(b)){
is.reset();
return false;
}
}
} catch (IOException e) {
return true;
}
}
private static byte[] inbuf = new byte[1024];
static int lenbuf = 0, ptrbuf = 0;
private static int readByte()
{
if(lenbuf == -1)throw new InputMismatchException();
if(ptrbuf >= lenbuf){
ptrbuf = 0;
try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
if(lenbuf <= 0)return -1;
}
return inbuf[ptrbuf++];
}
private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
// private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }
private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
private static double nd() { return Double.parseDouble(ns()); }
private static char nc() { return (char)skip(); }
private static String ns()
{
int b = skip();
StringBuilder sb = new StringBuilder();
while(!(isSpaceChar(b))){
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
private static char[] ns(int n)
{
char[] buf = new char[n];
int b = skip(), p = 0;
while(p < n && !(isSpaceChar(b))){
buf[p++] = (char)b;
b = readByte();
}
return n == p ? buf : Arrays.copyOf(buf, p);
}
private static char[][] nm(int n, int m)
{
char[][] map = new char[n][];
for(int i = 0;i < n;i++)map[i] = ns(m);
return map;
}
private static int[] na(int n)
{
int[] a = new int[n];
for(int i = 0;i < n;i++)a[i] = ni();
return a;
}
private static int ni()
{
int num = 0, b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-'){
minus = true;
b = readByte();
}
while(true){
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
b = readByte();
}
}
private static long nl()
{
long num = 0;
int b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-'){
minus = true;
b = readByte();
}
while(true){
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
b = readByte();
}
}
private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
| Main.java:158: error: cannot find symbol
while(ipq.size() > 0 && pq.size() > 0 && pq.peek() < -ipq.peek()){
^
symbol: method peek()
location: variable pq of type SimpleMinHeapL
Main.java:158: error: cannot find symbol
while(ipq.size() > 0 && pq.size() > 0 && pq.peek() < -ipq.peek()){
^
symbol: method peek()
location: variable ipq of type SimpleMinHeapL
2 errors
|
s598502827 | p03653 | Java | import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
public class Main {
static InputStream is;
static PrintWriter out;
static String INPUT = "";
static void solve()
{
int x = ni(), y = ni(), z = ni();
int n = x+y+z;
int[][] ds = new int[n][];
long asum = 0;
for(int i = 0;i < n;i++){
ds[i] = na(3);
ds[i][1] -= ds[i][0];
ds[i][2] -= ds[i][0];
asum += ds[i][0];
}
Arrays.sort(ds, new Comparator<int[]>() {
public int compare(int[] a, int[] b) {
return -(a[1] - b[1]);
}
});
long[] gain = new long[n+1];
{
KMajorPriorityQueue kmjp = new KMajorPriorityQueue();
for(int i = 0;i < n;i++){
kmjp.add(ds[i][2]-ds[i][1]);
gain[i+1] += kmjp.kMajorSum(i+1-y);
}
}
{
KMajorPriorityQueue kmjp = new KMajorPriorityQueue();
for(int i = n-1;i >= 0;i--){
kmjp.add(ds[i][2]);
gain[i] += kmjp.kMajorSum(z-(i-y));
}
}
long sum = 0;
for(int i = 0;i < n;i++){
sum += ds[i][1];
gain[i+1] += sum;
}
long max = 0;
for(int i = y;i <= y+z;i++){
max = Math.max(max, gain[i] + asum);
}
out.println(max);
}
public static class SimpleMinHeapL {
public long[] a;
public int n;
public int pos;
public static final long INF = Long.MAX_VALUE;
public SimpleMinHeapL(int m)
{
n = m+1;
a = new long[n];
Arrays.fill(a, INF);
pos = 1;
}
public SimpleMinHeapL(long[] in)
{
n = in.length+1;
if((n&1)==1)n++;
a = new long[n];
pos = 1+in.length;
// Arrays.fill(a, INF);
a[0] = a[n-1] = a[n-2] = INF;
System.arraycopy(in, 0, a, 1, in.length);
for(int t = pos/2-1;t >= 1;t--){
for(int c = t;2*c < pos;){
int smaller = a[2*c] < a[2*c+1] ? 2*c : 2*c+1;
if(a[smaller] < a[c]){
long d = a[c]; a[c] = a[smaller]; a[smaller] = d;
c = smaller;
}else{
break;
}
}
}
}
public void add(long x)
{
a[pos++] = x;
for(int c = pos-1, p = c>>>1;p >= 1 && a[c] < a[p];c>>>=1, p>>>=1){
long d = a[p]; a[p] = a[c]; a[c] = d;
}
}
public long poll()
{
if(pos == 1)return INF;
pos--;
long ret = a[1];
a[1] = a[pos];
a[pos] = INF;
for(int c = 1;2*c < pos;){
int smaller = a[2*c] < a[2*c+1] ? 2*c : 2*c+1;
if(a[smaller] < a[c]){
long d = a[c]; a[c] = a[smaller]; a[smaller] = d;
c = smaller;
}else{
break;
}
}
return ret;
}
public long min() { return a[1]; }
public int size() { return pos-1; }
}
public static class KMajorPriorityQueue
{
SimpleMinHeapL pq, ipq;
long sum;
public KMajorPriorityQueue() {
pq = new SimpleMinHeapL(100000);
ipq = new SimpleMinHeapL(100000);
sum = 0;
}
public void add(long v) {
pq.add(v);
sum += v;
}
public long kMajorSum(int K) {
if(K < 0)K = 0;
// remove
while(pq.size() > K){
long v = pq.poll();
ipq.add(-v);
sum -= v;
}
// add
while(pq.size() < K){
long v = -ipq.poll();
pq.add(v);
sum += v;
}
// exchange
while(ipq.size() > 0 && pq.size() > 0 && pq.peek() < -ipq.peek()){
long e = pq.poll(), f = -ipq.poll();
sum -= e; sum += f;
pq.add(f);
ipq.add(-e);
}
return sum;
}
}
public static void main(String[] args) throws Exception
{
long S = System.currentTimeMillis();
is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
out = new PrintWriter(System.out);
solve();
out.flush();
long G = System.currentTimeMillis();
tr(G-S+"ms");
}
private static boolean eof()
{
if(lenbuf == -1)return true;
int lptr = ptrbuf;
while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;
try {
is.mark(1000);
while(true){
int b = is.read();
if(b == -1){
is.reset();
return true;
}else if(!isSpaceChar(b)){
is.reset();
return false;
}
}
} catch (IOException e) {
return true;
}
}
private static byte[] inbuf = new byte[1024];
static int lenbuf = 0, ptrbuf = 0;
private static int readByte()
{
if(lenbuf == -1)throw new InputMismatchException();
if(ptrbuf >= lenbuf){
ptrbuf = 0;
try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
if(lenbuf <= 0)return -1;
}
return inbuf[ptrbuf++];
}
private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
// private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }
private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
private static double nd() { return Double.parseDouble(ns()); }
private static char nc() { return (char)skip(); }
private static String ns()
{
int b = skip();
StringBuilder sb = new StringBuilder();
while(!(isSpaceChar(b))){
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
private static char[] ns(int n)
{
char[] buf = new char[n];
int b = skip(), p = 0;
while(p < n && !(isSpaceChar(b))){
buf[p++] = (char)b;
b = readByte();
}
return n == p ? buf : Arrays.copyOf(buf, p);
}
private static char[][] nm(int n, int m)
{
char[][] map = new char[n][];
for(int i = 0;i < n;i++)map[i] = ns(m);
return map;
}
private static int[] na(int n)
{
int[] a = new int[n];
for(int i = 0;i < n;i++)a[i] = ni();
return a;
}
private static int ni()
{
int num = 0, b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-'){
minus = true;
b = readByte();
}
while(true){
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
b = readByte();
}
}
private static long nl()
{
long num = 0;
int b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-'){
minus = true;
b = readByte();
}
while(true){
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
b = readByte();
}
}
private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
| Main.java:158: error: cannot find symbol
while(ipq.size() > 0 && pq.size() > 0 && pq.peek() < -ipq.peek()){
^
symbol: method peek()
location: variable pq of type SimpleMinHeapL
Main.java:158: error: cannot find symbol
while(ipq.size() > 0 && pq.size() > 0 && pq.peek() < -ipq.peek()){
^
symbol: method peek()
location: variable ipq of type SimpleMinHeapL
2 errors
|
s052325936 | p03653 | C++ | #include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;
#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<
#define fi first
#define sec second
#define mp make_pair
const int MAXN = 100100;
const ll INF = 1e18;
const lf EPS = 1e-8;
inline bool lt(const lf &a, const lf &b) {return a + EPS < b;}
inline bool eq(const lf &a, const lf &b) {return max(a - b, b - a) < EPS;}
int X, Y, Z;
ll a[MAXN], b[MAXN], c[MAXN];
int n;
ll dp[MAXN];
inline void update(int i, int i1, ll t) {
if (dp[i1] < t) dp[i1] = t;
}
int retA, retB;
pair <ll, int> checkA(lf x, ll y) {
REP(i, n + 1) dp[i] = -INF;
dp[0] = 0;
REP(i, n) {
update(i, i + 1, dp[i] + c[i]);
update(i, i + 1, dp[i] + a[i] + y);
update(i, i + 1, dp[i] + b[i] + x);
}
retA = retB = 0;
for (int i = n; i; i--) {
if (dp[i] == dp[i - 1] + c[i - 1]) continue;
if (dp[i - 1] + a[i - 1] + y == dp[i]) retA++;
else retB++;
}
return mp(dp[n], retA);
}
pair <ll, int> checkB(lf x) {
ll lo = -(1LL << 25), hi = (1LL << 25), mid;
REP(i, 40) {
mid = (lo + hi) / 2;
pair <ll, int> t = checkA(x, mid);
if (t.sec == X) {
lo = mid;
break;
}
if (t.sec < X) lo = mid;
else hi = mid;
}
ll Ret = checkA(x, lo).fi - lo * X;
return mp(Ret, retB);
}
int main() {
scanf("%d %d %d",&X,&Y,&Z);
n = X + Y + Z;
REP(i, n) scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
ll lo = -(1LL << 25), hi = (1LL << 25), mid;
REP(i, 40) {
mid = (lo + hi) / 2;
pair <ll, int> t = checkB(mid);
if (t.sec < Y) lo = mid;
if (t.sec == Y) {
lo = mid;
break;
}
if (t.sec > Y) hi = mid;
}
pair <ll, int> t = checkB(lo);
printf("%lld\n",t.fi - i * Y);
return 0;
}
| a.cc: In function 'int main()':
a.cc:106:32: error: 'i' was not declared in this scope
106 | printf("%lld\n",t.fi - i * Y);
| ^
|
s518025944 | p03653 | C++ | #include<bits/stdc++.h>
using namespace std;
#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<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int X,Y,Z;
LL A[100001];
LL B[100001];
LL C[100001];
bool used[100001];
typedef pair<LL,LL> P;
vector<P>v;
vector<P>v2;
vector<LL>v3;
LL ans=0;
int main(){
cin>>X>>Y>>Z;
REP(i,X+Y+Z){
cin>>A[i]>>B[i]>>C[i];
ans+=C[i];
A[i]-=C[i];
B[i]-=C[i];
v.push_back(P(A[i],i));
v2.push_back(P(B[i],i));
}
sort(v.begin(),v.end(),greater<P>());
sort(v2.begin(),v2.end(),greater<P>());
REP(i,100001){
used[i]=false;
}
REP(i,X){
used[v[i].second]=true;
}
int c=0;
REP(i,Y){
if(used[v2[i].second]==false){
ans+=v2[i].first;
c++;
}else{
int num=v2[i].second;
used[num]=false;
ans+=v2[i].first;
v3.push_back(A[num]-B[num]);
}
}
Y-=c;
c=0;
REP(i,X){
if(used[v[i].second]==true){
ans+=v[i].first;
c++;
}
}
X-=c;
sort(v3.begin(),v3.end()greater<LL>());
REP(i,v3.size()){
if(i<X){
ans+=v3[i];
}else{
}
}
cout<<ans<<endl;
return(0);
} | a.cc: In function 'int main()':
a.cc:58:28: error: expected ')' before 'greater'
58 | sort(v3.begin(),v3.end()greater<LL>());
| ~ ^~~~~~~
| )
|
s199609652 | p03653 | C++ | #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
#define mk make_pair<ll, int>
#define fr first
#define sd second
using namespace std;
typedef long long ll;
typedef double db;
const int N = 100005, mod = 1000000007;
int p[4], a[N][4], n, c[N], mp, mq, mr;
ll ans;
priority_queue< pair<ll, int> > w[4][4];
void add(int i, int j) {
int i0 = i;
Rep(k, 1, 3) if (j != k) {
w[j][k].push( mk((ll)a[i][k] - a[i][j], i0) );
}
}
int main()
{
Rep(i, 1, 3) scanf ("%d", &p[i]), n += p[i];
Rep(i, 1, n) {
int mx = 0;
Rep(j, 1, 3) scanf ("%d", &a[i][j]), mx = max(a[i][j], mx);
Rep(j, 1, 3) if (a[i][j] == mx) {
c[i] = j;
p[j] --;
ans += mx;
add(i, j);
break ;
}
}
while (1) {
// cout << p[1]<<" "<<p[2]<<" "<<p[3]<<" "<<ans<<endl;
Rep(i, 1, 3)
Rep(j, 1, 3) {
while (!w[j][i].empty() && c[ w[j][i].top().sd ] != j) w[j][i].pop();
}
bool fl = 1;
ll mx = -(1ll << 60);
Rep(i, 1, 3) if (p[i] > 0) {
fl = 0;
Rep(j, 1, 3) if (i != j && !w[j][i].empty()) {
if (p[j] < 0) {
if (w[j][i].top().fr > mx) {
mx = w[j][i].top().fr;
mp = i, mq = j; mr = 0;
}
}
Rep(k, 1, 3) if (i != j && j != k && p[k] < 0 && !w[k][j].empty()) {
if (w[j][i].top().fr + w[k][j].top().fr > mx) {
mx = w[j][i].top().fr + w[k][j].top().fr;
mp = i, mq = j, mr = k;
}
}
}
break ;
}
if (fl) break ;
ans += mx;
if (mr) {
int x = w[mr][mq].top().sd;
c[x] = mq; p[mr] ++; p[mq] --;
add(x, mq);
}
int x = w[mq][mp].top().sd;
c[x] = mp; p[mq] ++; p[mp] --;
add(x, mp);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'void add(int, int)':
a.cc:30:57: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
30 | w[j][k].push( mk((ll)a[i][k] - a[i][j], i0) );
| ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
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:1:
/usr/include/c++/14/bits/stl_pair.h:1132:32: note: initializing argument 2 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = long long int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = long long int; typename decay<_Tp>::type = long long int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
|
s809015493 | p03653 | C++ | #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
#define mk make_pair<ll, int>
#define fr first
#define sd second
using namespace std;
typedef long long ll;
typedef double db;
const int N = 100005, mod = 1000000007;
int p[4], a[N][4], n, c[N], mp, mq, mr;
ll ans;
priority_queue< pair<ll, int> > w[4][4];
void add(int i, int j) {
Rep(k, 1, 3) if (j != k) {
w[j][k].push( mk(a[i][k] - a[i][j], i) );
}
}
int main()
{
Rep(i, 1, 3) scanf ("%d", &p[i]), n += p[i];
Rep(i, 1, n) {
int mx = 0;
Rep(j, 1, 3) scanf ("%d", &a[i][j]), mx = max(a[i][j], mx);
Rep(j, 1, 3) if (a[i][j] == mx) {
c[i] = j;
p[j] --;
ans += mx;
add(i, j);
break ;
}
}
while (1) {
// cout << p[1]<<" "<<p[2]<<" "<<p[3]<<" "<<ans<<endl;
Rep(i, 1, 3)
Rep(j, 1, 3) {
while (!w[j][i].empty() && c[ w[j][i].top().sd ] != j) w[j][i].pop();
}
bool fl = 1;
ll mx = -(1ll << 60);
Rep(i, 1, 3) if (p[i] > 0) {
fl = 0;
Rep(j, 1, 3) if (i != j && !w[j][i].empty()) {
if (p[j] < 0) {
if (w[j][i].top().fr > mx) {
mx = w[j][i].top().fr;
mp = i, mq = j; mr = 0;
}
}
Rep(k, 1, 3) if (i != j && j != k && p[k] < 0 && !w[k][j].empty()) {
if (w[j][i].top().fr + w[k][j].top().fr > mx) {
mx = w[j][i].top().fr + w[k][j].top().fr;
mp = i, mq = j, mr = k;
}
}
}
break ;
}
if (fl) break ;
ans += mx;
if (mr) {
int x = w[mr][mq].top().sd;
c[x] = mq; p[mr] ++; p[mq] --;
add(x, mq);
}
int x = w[mq][mp].top().sd;
c[x] = mp; p[mq] ++; p[mp] --;
add(x, mp);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'void add(int, int)':
a.cc:29:53: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
29 | w[j][k].push( mk(a[i][k] - a[i][j], i) );
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
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:1:
/usr/include/c++/14/bits/stl_pair.h:1132:32: note: initializing argument 2 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = long long int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = long long int; typename decay<_Tp>::type = long long int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
|
s520426132 | p03653 | C++ | #include <bits/stdc++.h>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define int ll
#define y1 what
using namespace std;
const int N = (int) 3e5 + 10;
const int M = (int) 1e6 + 7;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;
int n, a, b;
pii pts[N];
ll pref[N];
ll suff[N];
vector<int> all_num;
int get_id(int x) {
return lower_bound(all(all_num), x) - all_num.begin();
}
struct node {
int cnt;
ll sum;
node() {
cnt = sum = 0;
}
};
node t[4 * N];
void upd(int x, int y, int v = 1, int l = 0, int r = sz(all_num) - 1) {
if (l == r) {
++t[v].cnt;
t[v].sum += y;
return;
}
int m = (l + r) / 2;
if (x <= m) {
upd(x, y, v + v, l, m);
} else {
upd(x, y, v + v + 1, m + 1, r);
}
t[v].sum = t[v + v].sum + t[v + v + 1].sum;
t[v].cnt = t[v + v].cnt + t[v + v + 1].cnt;
}
ll get(int k, int v = 1, int l = 0, int r = sz(all_num) - 1) {
if (k == 0)
return 0;
if (l == r) {
if (!(t[v].cnt >= k)) {
cout << "WTF?\n";
exit(0);
}
if (t[v].cnt == 0) return 0;
return k * 1ll * (t[v].sum / t[v].cnt);
}
int m = (l + r) / 2;
if (t[v + v + 1].cnt >= k)
return get(k, v + v + 1, m + 1, r);
return get(k - t[v + v + 1].cnt, v + v, l, m) + t[v + v + 1].sum;
}
void add(int x) {
upd(get_id(x), x);
}
main() {
#define fn "balls"
#ifdef witch
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
// freopen(fn".in", "r", stdin);
// freopen(fn".out", "w", stdout);
#endif
srand(time(0));
cin >> n >> a >> b;
n += a + b;
ll sum = 0, ans = -LINF;
for (int i = 1, x, y, z; i <= n; i++) {
cin >> x >> y >> z;
y -= x;
z -= x;
sum += x;
pts[i] = mp(y, z);
}
sort(pts + 1, pts + n + 1, greater<pii>());
//ai, bi -> X, Y
for (int i = 1; i <= n; i++) {
//cout << pts[i].f << ' ' << pts[i].s << endl;
pref[i] = pref[i - 1] + pts[i].f;
all_num.pb(pts[i].s);
all_num.pb(pts[i].s - pts[i].f);
}
sort(all(all_num));
// cout << endl;
for (int i = n; i >= 1; i--) {
if (i >= a && i <= a + b) {
if (i == a) { continue;
cout<<b - (i - a)<<endl;
for(int j=i+1;j<=n;j++){
cout<<pts[j].s<<" ";
}
cout << endl;
}
suff[i] = get(b - (i - a));
}
add(pts[i].s);
}
for (int i = 0; i < 4 * N; i++) {
t[i].cnt = 0;
t[i].sum = 0;
}
for (int i = 1; i < a; i++) {
add(pts[i].s - pts[i].f);
}
for (int i = 1; i <= a + b; i++) {
add(pts[i].s - pts[i].f);
// we want to delete from back so that we have chosen already a silver
if (i >= a) {
//cout << suff[i] << endl;
ans = max(ans, pref[i] + suff[i] + get(i - a));
}
}
cout << sum + ans;
return 0;
} | a.cc:8:12: error: expected primary-expression before 'long'
8 | #define ll long long
| ^~~~
a.cc:12:13: note: in expansion of macro 'll'
12 | #define int ll
| ^~
a.cc:10:15: note: in expansion of macro 'int'
10 | #define sz(v) int(v.size())
| ^~~
a.cc:46:54: note: in expansion of macro 'sz'
46 | void upd(int x, int y, int v = 1, int l = 0, int r = sz(all_num) - 1) {
| ^~
a.cc:8:12: error: expected ',' or '...' before 'long'
8 | #define ll long long
| ^~~~
a.cc:12:13: note: in expansion of macro 'll'
12 | #define int ll
| ^~
a.cc:10:15: note: in expansion of macro 'int'
10 | #define sz(v) int(v.size())
| ^~~
a.cc:46:54: note: in expansion of macro 'sz'
46 | void upd(int x, int y, int v = 1, int l = 0, int r = sz(all_num) - 1) {
| ^~
a.cc:8:12: error: expected primary-expression before 'long'
8 | #define ll long long
| ^~~~
a.cc:12:13: note: in expansion of macro 'll'
12 | #define int ll
| ^~
a.cc:10:15: note: in expansion of macro 'int'
10 | #define sz(v) int(v.size())
| ^~~
a.cc:62:45: note: in expansion of macro 'sz'
62 | ll get(int k, int v = 1, int l = 0, int r = sz(all_num) - 1) {
| ^~
a.cc:8:12: error: expected ',' or '...' before 'long'
8 | #define ll long long
| ^~~~
a.cc:12:13: note: in expansion of macro 'll'
12 | #define int ll
| ^~
a.cc:10:15: note: in expansion of macro 'int'
10 | #define sz(v) int(v.size())
| ^~~
a.cc:62:45: note: in expansion of macro 'sz'
62 | ll get(int k, int v = 1, int l = 0, int r = sz(all_num) - 1) {
| ^~
a.cc:83:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
83 | main() {
| ^~~~
|
s823600879 | p03653 | C++ | #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
#define MAXN 100020
#define MAXM 1000010
#define INF 2147483647
typedef long long ll;
int S,T,T1,T2,T3;
int en,u[MAXM],v[MAXM],first[MAXN],next[MAXM],cap[MAXM],cost[MAXM];//Next Array
bool inq[MAXN];
ll d[MAXN]/*spfa*/;
int p[MAXN]/*spfa*/,a[MAXN]/*????*/;
queue<int>q;
void Init_MCMF(){memset(first,-1,sizeof(first));en=0;}
void AddEdge(const int &U,const int &V,const int &W,const int &C)
{
u[en]=U; v[en]=V; cap[en]=W; cost[en]=C;
next[en]=first[U]; first[U]=en++;
u[en]=V; v[en]=U; cap[en]=0; cost[en]=-C;
next[en]=first[V]; first[V]=en++;
}
bool Spfa(int &Flow,ll &Cost)
{
memset(d,0x7f,sizeof(d));
memset(inq,0,sizeof(inq));
d[S]=0; inq[S]=1; p[S]=0; a[S]=INF; q.push(S);
while(!q.empty())
{
int U=q.front(); q.pop(); inq[U]=0;
for(int i=first[U];i!=-1;i=next[i])
if(cap[i] && d[v[i]]>d[U]+cost[i])
{
d[v[i]]=d[U]+cost[i];
p[v[i]]=i;
a[v[i]]=min(a[U],cap[i]);
if(!inq[v[i]]) {q.push(v[i]); inq[v[i]]=1;}
}
}
if(d[T]>2000000000ll) return 0;
Flow+=a[T]; Cost+=d[T]*a[T]; int U=T;
while(U!=S)
{
cap[p[U]]-=a[T]; cap[p[U]^1]+=a[T];
U=u[p[U]];
}
return 1;
}
ll Mincost()
{
int Flow=0;
ll Cost=0;
while(Spfa(Flow,Cost));
return Cost;
}
int X,Y,Z;
int main(){
Init_MCMF();
scanf("%d%d%d",&X,&Y,&Z);
int x,y,z;
T1=X+Y+Z+1;
T2=T1+1;
T3=T2+1;
S=T3+1;
T=S+1;
for(int i=1;i<=X+Y+Z;++i){
scanf("%d%d%d",&x,&y,&z);
AddEdge(S,i,1,0);
AddEdge(i,T1,1,-x);
AddEdge(i,T2,1,-y);
AddEdge(i,T3,1,-z);
}
AddEdge(T1,T,X,0);
AddEdge(T2,T,Y,0);
AddEdge(T3,T,Z,0);
cout<<(-Mincost())<<endl;
return 0;
} | a.cc: In function 'void AddEdge(const int&, const int&, const int&, const int&)':
a.cc:21:5: error: reference to 'next' is ambiguous
21 | next[en]=first[U]; first[U]=en++;
| ^~~~
In file included 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:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:12:36: note: 'int next [1000010]'
12 | int en,u[MAXM],v[MAXM],first[MAXN],next[MAXM],cap[MAXM],cost[MAXM];//Next Array
| ^~~~
a.cc:23:5: error: reference to 'next' is ambiguous
23 | next[en]=first[V]; first[V]=en++;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:12:36: note: 'int next [1000010]'
12 | int en,u[MAXM],v[MAXM],first[MAXN],next[MAXM],cap[MAXM],cost[MAXM];//Next Array
| ^~~~
a.cc: In function 'bool Spfa(int&, ll&)':
a.cc:33:38: error: reference to 'next' is ambiguous
33 | for(int i=first[U];i!=-1;i=next[i])
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:12:36: note: 'int next [1000010]'
12 | int en,u[MAXM],v[MAXM],first[MAXN],next[MAXM],cap[MAXM],cost[MAXM];//Next Array
| ^~~~
|
s476083769 | p03653 | C++ | #include <bits/stdc++.h>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define y1 what
using namespace std;
const int N = (int) 2e5 + 10;
const int M = (int) 1e6 + 7;
const ll LINF = (ll) 1e16;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;
int n, a, b;
pii pts[N];
ll pref[N];
ll suff[N];
vector<int> all_num;
int get_id(int x) {
return lower_bound(all(all_num), x) - all_num.begin();
}
struct node {
int cnt;
ll sum;
node() {
cnt = sum = 0;
}
};
node t[4 * N];
void upd(int x, int y, int v = 1, int l = 0, int r = sz(all_num) - 1) {
if (l == r) {
++t[v].cnt;
t[v].sum += y;
return;
}
int m = (l + r) / 2;
if (x <= m) {
upd(x, y, v + v, l, m);
} else {
upd(x, y, v + v + 1, m + 1, r);
}
t[v].sum = t[v + v].sum + t[v + v + 1].sum;
t[v].cnt = t[v + v].cnt + t[v + v + 1].cnt;
}
ll get(int k, int v = 1, int l = 0, int r = sz(all_num) - 1) {
if (k == 0)
return 0;
if (l == r) {
if (!(t[v].cnt >= k)) {
cout << "WTF?\n";
exit(0);
}
if (t[v].cnt == 0) return 0;
return k * 1ll * (t[v].sum / t[v].cnt);
}
int m = (l + r) / 2;
if (t[v + v + 1].cnt >= k)
return get(k, v + v + 1, m + 1, r);
return get(k - t[v + v + 1].cnt, v + v, l, m) + t[v + v + 1].sum;
}
void add(int x) {
upd(get_id(x), x);
}
int main() {
#define fn "balls"
#ifdef witch
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
// freopen(fn".in", "r", stdin);
// freopen(fn".out", "w", stdout);
#endif
srand(time(0));
cin >> n >> a >> b;
n += a + b;
ll sum = 0, ans = -LINF;
for (int i = 1, x, y, z; i <= n; i++) {
cin >> x >> y >> z;
y -= x;
z -= x;
sum += x;
pts[i] = mp(y, z);
}
sort(pts + 1, pts + n + 1, greater<pii>());
//ai, bi -> X, Y
for (int i = 1; i <= n; i++) {
//cout << pts[i].f << ' ' << pts[i].s << endl;
pref[i] = pref[i - 1] + pts[i].f;
all_num.pb(pts[i].s);
all_num.pb(pts[i].s - pts[i].f);
}
sort(all(all_num));
// cout << endl;
multiset<int> A, B;
ll sum_A = 0, sum_B = 0;
for (int i = n; i >= 1; i--) {
if (i >= a && i <= a + b) {
if (i == a) { continue;
cout<<b - (i - a)<<endl;
for(int j=i+1;j<=n;j++){
cout<<pts[j].s<<" ";x
}
cout << endl;
}
suff[i] = get(b - (i - a));
}
add(pts[i].s);
}
for (int i = 0; i < 4 * N; i++) {
t[i].cnt = 0;
t[i].sum = 0;
}
for (int i = 1; i < a; i++) {
add(pts[i].s - pts[i].f);
}
for (int i = 1; i <= a + b; i++) {
add(pts[i].s - pts[i].f);
// we want to delete from back so that we have chosen already a silver
if (i >= a) {
//cout << suff[i] << endl;
ans = max(ans, pref[i] + suff[i] + get(i - a));
}
}
cout << sum + ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:119:41: error: 'x' was not declared in this scope
119 | cout<<pts[j].s<<" ";x
| ^
|
s402487992 | p03653 | C++ | #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define s second
#define f first
#define mk make_pair
using namespace std;
main(){
int a,b,c,a1,b1,c1,x,y,z;
cin>>a>>b>>c>>x>>y>>z;
long int dp[2][a+3][b+3][c+3];
memset(dp,0,sizeof(dp));
vector<pair<int,pair<int,int> > >v[2];
// if(a)dp[0][1][0][0]=x,v[0].push_back(mk(1,mk(0,0)));
//if(b)dp[0][0][1][0]=y,v[0].push_back(mk(0,mk(1,0)));
//if(c)dp[0][0][0][1]=z,v[0].push_back(mk(0,mk(0,1)));
for(int i=1;i<a+b+c;i++){
cin>>x>>y>>z;
//set<pair<int,pair<int,int> > >se;//cout<<v[(i+1)%2].size()<<endl;
for(int j=0;j<v[(i+1)%2].siz//e();j++){
pair<int,pair<int,int> >p=v[(i+1)%2][j];
a1=p.f,b1=p.s.f,c1=p.s.s;//cout<<a1<<b1<<c1<<endl;
if(a1<a)dp[i%2][a1+1][b1][c1]=max(dp[i%2][a1+1][b1][c1],dp[(i+1)%2][a1][b1][c1]+x);
if(b1<b)dp[i%2][a1][b1+1][c1]=max(dp[i%2][a1][b1+1][c1],dp[(i+1)%2][a1][b1][c1]+y);
if(c1<c)dp[i%2][a1][b1][c1+1]=max(dp[i%2][a1][b1][c1+1],dp[(i+1)%2][a1][b1][c1]+z);
p=mk(a1+1,mk(b1,c1));if(a1<a)v[i%2].push_back(p);
//if(!se.count(p)&&a1<a)v[i%2].push_back(p),se.insert(p);
p=mk(a1,mk(b1+1,c1));if(b1<b)v[i%2].push_back(p);
//if(!se.count(p)&&b1<b)v[i%2].push_back(p),se.insert(p);
p=mk(a1,mk(b1,c1+1));if(c1<c)v[i%2].push_back(p);
//if(!se.count(p)&&c1<c)v[i%2].push_back(p),se.insert(p);
}
v[(i+1)%2].clear();
}
long int ans=0;
r(i,a)r(j,b)r(k,c)ans=max(ans,dp[(a+b+c-1)%2][a][b][c]);
cout<<ans<<endl;
return 0;
} | a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:19:30: error: 'class std::vector<std::pair<int, std::pair<int, int> > >' has no member named 'siz'; did you mean 'size'?
19 | for(int j=0;j<v[(i+1)%2].siz//e();j++){
| ^~~
| size
a.cc:19:33: error: expected ';' before 'pair'
19 | for(int j=0;j<v[(i+1)%2].siz//e();j++){
| ^
| ;
20 | pair<int,pair<int,int> >p=v[(i+1)%2][j];
| ~~~~
a.cc:20:31: error: expected primary-expression before 'p'
20 | pair<int,pair<int,int> >p=v[(i+1)%2][j];
| ^
a.cc:20:31: error: expected ')' before 'p'
20 | pair<int,pair<int,int> >p=v[(i+1)%2][j];
| ^
| )
a.cc:19:8: note: to match this '('
19 | for(int j=0;j<v[(i+1)%2].siz//e();j++){
| ^
a.cc:20:31: error: 'p' was not declared in this scope
20 | pair<int,pair<int,int> >p=v[(i+1)%2][j];
| ^
a.cc:21:10: error: 'p' was not declared in this scope
21 | a1=p.f,b1=p.s.f,c1=p.s.s;//cout<<a1<<b1<<c1<<endl;
| ^
a.cc:32:8: error: 'i' was not declared in this scope
32 | v[(i+1)%2].clear();
| ^
a.cc: At global scope:
a.cc:2:16: error: expected unqualified-id before 'for'
2 | #define r(i,n) for(int i=0;i<n;i++)
| ^~~
a.cc:35:3: note: in expansion of macro 'r'
35 | r(i,a)r(j,b)r(k,c)ans=max(ans,dp[(a+b+c-1)%2][a][b][c]);
| ^
a.cc:35:5: error: 'i' does not name a type
35 | r(i,a)r(j,b)r(k,c)ans=max(ans,dp[(a+b+c-1)%2][a][b][c]);
| ^
a.cc:2:28: note: in definition of macro 'r'
2 | #define r(i,n) for(int i=0;i<n;i++)
| ^
a.cc:35:5: error: 'i' does not name a type
35 | r(i,a)r(j,b)r(k,c)ans=max(ans,dp[(a+b+c-1)%2][a][b][c]);
| ^
a.cc:2:32: note: in definition of macro 'r'
2 | #define r(i,n) for(int i=0;i<n;i++)
| ^
a.cc:35:11: error: 'j' does not name a type
35 | r(i,a)r(j,b)r(k,c)ans=max(ans,dp[(a+b+c-1)%2][a][b][c]);
| ^
a.cc:2:28: note: in definition of macro 'r'
2 | #define r(i,n) for(int i=0;i<n;i++)
| ^
a.cc:35:11: error: 'j' does not name a type
35 | r(i,a)r(j,b)r(k,c)ans=max(ans,dp[(a+b+c-1)%2][a][b][c]);
| ^
a.cc:2:32: note: in definition of macro 'r'
2 | #define r(i,n) for(int i=0;i<n;i++)
| ^
a.cc:35:17: error: 'k' does not name a type
35 | r(i,a)r(j,b)r(k,c)ans=max(ans,dp[(a+b+c-1)%2][a][b][c]);
| ^
a.cc:2:28: note: in definition of macro 'r'
2 | #define r(i,n) for(int i=0;i<n;i++)
| ^
a.cc:35:17: error: 'k' does not name a type
35 | r(i,a)r(j,b)r(k,c)ans=max(ans,dp[(a+b+c-1)%2][a][b][c]);
| ^
a.cc:2:32: note: in definition of macro 'r'
2 | #define r(i,n) for(int i=0;i<n;i++)
| ^
a.cc:36:3: error: 'cout' does not name a type
36 | cout<<ans<<endl;
| ^~~~
a.cc:37:3: error: expected unqualified-id before 'return'
37 | return 0;
| ^~~~~~
a.cc:38:1: error: expected declaration before '}' token
38 | }
| ^
|
s177523447 | p03653 | C++ | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <string>
#include <list>
using namespace std;
#define CVector CPoint
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const double PI=acos(-1);
const double EPS=1e-6;
const int INF=0x3f3f3f3f;
inline int readint(){int sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}
inline LL readLL(){LL sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}
//int a[305][305];
struct node{
LL a,b,c;
node(){}
node(LL a,LL b,LL c):a(a),b(b),c(c){}
};
vector<node> s,s1,s2,s3;
bool cmp(const node &a,const node &b){
return a.c-a.a<b.c-b.a;
}
bool cmp1(const node &a,const node &b){
return a.b-a.a<b.b-b.a;
}
bool cmp2(const node &a,const node &b){
return a.b-a.c<b.b-b.c;
}
bool cmp3(const node &a,const node &b){
return a.c-a.a<b.c-b.a;
}
int main(){ios_base::sync_with_stdio(0);cin.tie(0);
/*int n,m;cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}*/
int x,y,z;cin>>x>>y>>z;
LL sum=0;
int a,b,c;
for(int i=1;i<=x+y+z;i++){
cin>>a>>b>>c;
s.push_back(node(a,b,c));
}
sort(s.begin(),s.end(),cmp);
for(int i=1;i<=x;i++){
s1.push_back(s[i-1]);
sum+=s[i-1].a;
}
for(int i=1;i<=y;i++){
s2.push_back(s[i+x-1]);
sum+=s[i+x-1].b;
}
for(int i=1;i<=z;i++){
s3.push_back(s[i+x+y-1]);
sum+=s[i+x+y-1].c;
}
sort(s1.begin(),s1.end(),cmp1);
sort(s2.begin(),s2.end(),cmp1);
int p,q;
p=x-1,q=0;
while(s1[p].b+s2[q].a>s1[p].a+s2[q].b&&p>=0&&q<y){
sum+=(s1[p].b+s2[q].a)-(s1[p].a+s2[q].b);
swap(s1[p],s2[q]);
p--;q++;
}
sort(s2.begin(),s2.end(),cmp2);
sort(s3.begin(),s3.end(),cmp2);
p=z-1,q=0;
while(s3[p].b+s2[q].c>s3[p].c+s2[q].b&&p>=0&&q<y){
sum+=(s3[p].b+s2[q].c)-(s3[p].c+s2[q].b);
swap(s3[p],s2[q]);
p--;q++;
}
sort(s1.begin(),s1.end(),cmp3);
sort(s3.begin(),s3.end(),cmp3);
p=x-1,q=0;
while(s1[p].c+s3[q].a>s1[p].a+s3[q].c&&p>=0&&q<z){
sum+=(s1[p].c+s3[q].a)-(s1[p].a+s3[q].c);
swap(s1[p],s3[q]);
p--;q++;
}
sort(s1.begin(),s1.end(),cmp1);
sort(s2.begin(),s2.end(),cmp1);
int p,q;
p=x-1,q=0;
while(s1[p].b+s2[q].a>s1[p].a+s2[q].b&&p>=0&&q<y){
sum+=(s1[p].b+s2[q].a)-(s1[p].a+s2[q].b);
swap(s1[p],s2[q]);
p--;q++;
}
sort(s2.begin(),s2.end(),cmp2);
sort(s3.begin(),s3.end(),cmp2);
p=z-1,q=0;
while(s3[p].b+s2[q].c>s3[p].c+s2[q].b&&p>=0&&q<y){
sum+=(s3[p].b+s2[q].c)-(s3[p].c+s2[q].b);
swap(s3[p],s2[q]);
p--;q++;
}
sort(s1.begin(),s1.end(),cmp3);
sort(s3.begin(),s3.end(),cmp3);
p=x-1,q=0;
while(s1[p].c+s3[q].a>s1[p].a+s3[q].c&&p>=0&&q<z){
sum+=(s1[p].c+s3[q].a)-(s1[p].a+s3[q].c);
swap(s1[p],s3[q]);
p--;q++;
}
cout<<sum<<endl;
return 0;
}
//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;
| a.cc: In function 'int main()':
a.cc:109:9: error: redeclaration of 'int p'
109 | int p,q;
| ^
a.cc:84:9: note: 'int p' previously declared here
84 | int p,q;
| ^
a.cc:109:11: error: redeclaration of 'int q'
109 | int p,q;
| ^
a.cc:84:11: note: 'int q' previously declared here
84 | int p,q;
| ^
|
s505516451 | p03654 | C++ | #include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
long long ans=0;
struct Edge
{
int to,next,v;
}w[200005];
void add(int x,int y,int z)
{
w[++cnt]=Edge{y,h[x],z};
h[x]=cnt;
}
void dfs(int x,int fa,int v)
{
size[x]=1;
int s=0;
for(int i=h[x];i;i=w[i].next)
{
int to=w[i].to;
if(to==fa) continue;
dfs(to,x,w[i].v);
size[x]+=size[to];s=max(s,size[to]);
}
if(size[x]*2==n) vs=v;
ans+=1ll*min(size[x],n-size[x])*v;
s=max(s,n-size[x]);
if(s<maxx) maxx=s,rt=x;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
add(x,y,z),add(y,x,z);
}
dfs(1,0,0);
if(!vs)
{
vs=0x3f3f3f3f;
for(int i=h[rt];i;i=w[i].next) vs=min(vs,w[i].v);
}
printf("%lld\n",ans*2-vs);
} | a.cc: In function 'void dfs(int, int, int)':
a.cc:22:9: error: reference to 'size' is ambiguous
22 | size[x]=1;
| ^~~~
In file included from /usr/include/c++/14/string:53,
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:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:29:17: error: reference to 'size' is ambiguous
29 | size[x]+=size[to];s=max(s,size[to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:29:26: error: reference to 'size' is ambiguous
29 | size[x]+=size[to];s=max(s,size[to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:29:43: error: reference to 'size' is ambiguous
29 | size[x]+=size[to];s=max(s,size[to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:31:12: error: reference to 'size' is ambiguous
31 | if(size[x]*2==n) vs=v;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:32:22: error: reference to 'size' is ambiguous
32 | ans+=1ll*min(size[x],n-size[x])*v;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:32:32: error: reference to 'size' is ambiguous
32 | ans+=1ll*min(size[x],n-size[x])*v;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:33:19: error: reference to 'size' is ambiguous
33 | s=max(s,n-size[x]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
|
s541852917 | p03654 | C++ | #include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
long long ans=0;
struct Edge
{
int to,next,v;
}w[200005];
void add(int x,int y,int z)
{
w[++cnt]=Edge{y,h[x],z};
h[x]=cnt;
}
void dfs(int x,int fa,int v)
{
size[x]=1;
int s=0;
for(int i=h[x];i;i=w[i].next)
{
int to=w[i].to;
if(to==fa) continue;
dfs(to,x,w[i].v);
size[x]+=size[to];s=max(s,size[to]);
}
if(size[x]*2==n) vs=v;
ans+=1ll*min(size[x],n-size[x])*v;
s=max(s,n-size[x]);
if(s<maxx) maxx=s,rt=x;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
add(x,y,z),add(y,x,z);
}
dfs(1,0,0);
if(!vs)
{
vs=0x3f3f3f3f;
for(int i=h[rt];i;i=w[i].next) vs=min(vs,w[i].v);
}
printf("%lld\n",ans*2-vs);
} | a.cc: In function 'void dfs(int, int, int)':
a.cc:22:9: error: reference to 'size' is ambiguous
22 | size[x]=1;
| ^~~~
In file included from /usr/include/c++/14/string:53,
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:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:29:17: error: reference to 'size' is ambiguous
29 | size[x]+=size[to];s=max(s,size[to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:29:26: error: reference to 'size' is ambiguous
29 | size[x]+=size[to];s=max(s,size[to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:29:43: error: reference to 'size' is ambiguous
29 | size[x]+=size[to];s=max(s,size[to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:31:12: error: reference to 'size' is ambiguous
31 | if(size[x]*2==n) vs=v;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:32:22: error: reference to 'size' is ambiguous
32 | ans+=1ll*min(size[x],n-size[x])*v;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:32:32: error: reference to 'size' is ambiguous
32 | ans+=1ll*min(size[x],n-size[x])*v;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
a.cc:33:19: error: reference to 'size' is ambiguous
33 | s=max(s,n-size[x]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:9:7: note: 'int size [100005]'
9 | int n,size[100005],rt,maxx=0x3f3f3f3f,vs=0,h[100005],cnt;
| ^~~~
|
s224752285 | p03654 | C++ | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int N = 1e5 + 5;
int n;
struct edge { int to, len; };
vector<edge> G[N];
long long ans;
int tmp;
int maxp[N], size[N];
int centr;
void solve(int x, int f) {
size[x] = 1, maxp[x] = 0;
for (auto y : G[x]) {
if (y.to == f) continue;
solve(y.to, x);
ans += y.len * 2ll * min(size[y.to], n - size[y.to]);
size[x] += size[y.to];
maxp[x] = max(maxp[x], size[y.to]);
}
maxp[x] = max(maxp[x], n - size[x]);
if (maxp[x] < maxp[centr]) centr = x;
}
signed main() {
cin >> n;
for (int i = 1; i < n; i++) {
int u, v, w; cin >> u >> v >> w;
G[u].push_back({v, w});
G[v].push_back({u, w});
}
maxp[centr = 0] = 2e9;
solve(1, 0);
tmp = 2e9;
for (auto i : G[centr]) {
int x = i.to, w = i.len;
if (maxp[centr] == maxp[x]) {
printf("%lld\n", ans - w);
return 0;
}
tmp = min(tmp, w);
}
// printf("%d %d %d\n", ans, tmp, centr);
printf("%lld\n", ans - tmp);
return 0;
} | a.cc: In function 'void solve(int, int)':
a.cc:18:5: error: reference to 'size' is ambiguous
18 | size[x] = 1, maxp[x] = 0;
| ^~~~
In file included from /usr/include/c++/14/string:53,
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:2:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:22:34: error: reference to 'size' is ambiguous
22 | ans += y.len * 2ll * min(size[y.to], n - size[y.to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:22:50: error: reference to 'size' is ambiguous
22 | ans += y.len * 2ll * min(size[y.to], n - size[y.to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:23:9: error: reference to 'size' is ambiguous
23 | size[x] += size[y.to];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:23:20: error: reference to 'size' is ambiguous
23 | size[x] += size[y.to];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:24:32: error: reference to 'size' is ambiguous
24 | maxp[x] = max(maxp[x], size[y.to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:26:32: error: reference to 'size' is ambiguous
26 | maxp[x] = max(maxp[x], n - size[x]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
|
s800998229 | p03654 | C++ | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int N = 1e5 + 5;
int n;
struct edge { int to, len; };
vector<edge> G[N];
long long ans;
int tmp;
int maxp[N], size[N];
int centr;
void solve(int x, int f) {
size[x] = 1, maxp[x] = 0;
for (auto y : G[x]) {
if (y.to == f) continue;
solve(y.to, x);
ans += y.len * 2ll * min(size[y.to], n - size[y.to]);
size[x] += size[y.to];
maxp[x] = max(maxp[x], size[y.to]);
}
maxp[x] = max(maxp[x], n - size[x]);
if (maxp[x] < maxp[centr]) centr = x;
}
signed main() {
cin >> n;
for (int i = 1; i < n; i++) {
int u, v, w; cin >> u >> v >> w;
G[u].push_back({v, w});
G[v].push_back({u, w});
}
maxp[centr = 0] = 2e9;
solve(1, 0);
tmp = 2e9;
for (auto i : G[centr]) {
int x = i.to, w = i.len;
if (maxp[centr] == maxp[x]) {
printf("%lld\n", ans - w);
return 0;
}
tmp = min(tmp, w);
}
// printf("%d %d %d\n", ans, tmp, centr);
printf("%lld\n", ans - tmp);
return 0;
} | a.cc: In function 'void solve(int, int)':
a.cc:18:5: error: reference to 'size' is ambiguous
18 | size[x] = 1, maxp[x] = 0;
| ^~~~
In file included from /usr/include/c++/14/string:53,
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:2:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:22:34: error: reference to 'size' is ambiguous
22 | ans += y.len * 2ll * min(size[y.to], n - size[y.to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:22:50: error: reference to 'size' is ambiguous
22 | ans += y.len * 2ll * min(size[y.to], n - size[y.to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:23:9: error: reference to 'size' is ambiguous
23 | size[x] += size[y.to];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:23:20: error: reference to 'size' is ambiguous
23 | size[x] += size[y.to];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:24:32: error: reference to 'size' is ambiguous
24 | maxp[x] = max(maxp[x], size[y.to]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
a.cc:26:32: error: reference to 'size' is ambiguous
26 | maxp[x] = max(maxp[x], n - size[x]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:14:14: note: 'int size [100005]'
14 | int maxp[N], size[N];
| ^~~~
|
s774799550 | p03654 | C++ | #include <cstdio>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> ii;
int n;
vector<ii> al[100005];
long long sz[100005];
long long ans;
int minus=1000000000;
void dfs(int i,int p){
sz[i]=1;
for (auto &it:al[i]){
if (it.first==p) continue;
dfs(it.first,i);
ans+=2LL*min(sz[it.first],n-sz[it.first])*it.second;
sz[i]+=sz[it.first];
if (sz[it.first]*2==n) minus=it.second;
}
}
void dfs2(int i,int p){
for (auto &it:al[i]){
if (it.first==p) continue;
if (sz[it.first]>((n-1)/2)){
dfs(it.first,i);
return;
}
}
for (auto &it:al[i]){
minus=min(minus,it.second);
}
}
int main(){
scanf("%d",&n);
int a,b,c;
for (int x=1;x<n;x++){
scanf("%d%d%d",&a,&b,&c);a
al[a].push_back(ii(b,c));
al[b].push_back(ii(a,c));
minus=min(minus,c);
}
dfs(1,-1);
if (minus==1000000000) dfs2(1,-1);
printf("%lld\n",ans-minus);
} | a.cc: In function 'void dfs(int, int)':
a.cc:23:32: error: reference to 'minus' is ambiguous
23 | if (sz[it.first]*2==n) minus=it.second;
| ^~~~~
In file included from /usr/include/c++/14/bits/refwrap.h:39,
from /usr/include/c++/14/vector:68,
from a.cc:2:
/usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus'
163 | struct minus;
| ^~~~~
a.cc:12:5: note: 'int minus'
12 | int minus=1000000000;
| ^~~~~
a.cc: In function 'void dfs2(int, int)':
a.cc:37:9: error: reference to 'minus' is ambiguous
37 | minus=min(minus,it.second);
| ^~~~~
/usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus'
163 | struct minus;
| ^~~~~
a.cc:12:5: note: 'int minus'
12 | int minus=1000000000;
| ^~~~~
a.cc:37:19: error: reference to 'minus' is ambiguous
37 | minus=min(minus,it.second);
| ^~~~~
/usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus'
163 | struct minus;
| ^~~~~
a.cc:12:5: note: 'int minus'
12 | int minus=1000000000;
| ^~~~~
a.cc: In function 'int main()':
a.cc:45:35: error: expected ';' before 'al'
45 | scanf("%d%d%d",&a,&b,&c);a
| ^
| ;
46 | al[a].push_back(ii(b,c));
| ~~
a.cc:48:9: error: reference to 'minus' is ambiguous
48 | minus=min(minus,c);
| ^~~~~
/usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus'
163 | struct minus;
| ^~~~~
a.cc:12:5: note: 'int minus'
12 | int minus=1000000000;
| ^~~~~
a.cc:48:19: error: reference to 'minus' is ambiguous
48 | minus=min(minus,c);
| ^~~~~
/usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus'
163 | struct minus;
| ^~~~~
a.cc:12:5: note: 'int minus'
12 | int minus=1000000000;
| ^~~~~
a.cc:51:9: error: reference to 'minus' is ambiguous
51 | if (minus==1000000000) dfs2(1,-1);
| ^~~~~
/usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus'
163 | struct minus;
| ^~~~~
a.cc:12:5: note: 'int minus'
12 | int minus=1000000000;
| ^~~~~
a.cc:53:25: error: reference to 'minus' is ambiguous
53 | printf("%lld\n",ans-minus);
| ^~~~~
/usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus'
163 | struct minus;
| ^~~~~
a.cc:12:5: note: 'int minus'
12 | int minus=1000000000;
| ^~~~~
|
s131323945 | p03654 | C++ | #include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
using namespace std;
const long long N = 1e5 + 5;
long long mini = 1e9 + 7;
long long dp[N];
long long dp2[N];
bool mark[N];
bool check = false;
vector<pair<long long, long long>> graph[N];
vector<edge > vec;
long long n, m;
long long ans;
void dfs(long long v)
{
mark[v] = true;
dp[v] = 1;
for (long long i = 0; i < graph[v].size(); i++)
{
long long u = graph[v][i].first;
if (!mark[u])
{
dfs(u);
dp[v] += dp[u];
}
}
}
void dfs2(long long v)
{
mark[v] = true;
for (long long i = 0; i < graph[v].size(); i++)
{
long long u = graph[v][i].first;
long long w = graph[v][i].second;
if (!mark[u])
{
long long cnt1 = dp[u];
long long cnt2 = n - dp[u];
if (cnt1 == cnt2)
{
check = true;
cnt1 = 2 * cnt1 - 1;
}
else
{
cnt1 = 2 * min(cnt1, cnt2);
}
ans += cnt1 * w;
dfs2(u);
}
}
}
int main()
{
cin >> n;
for (long long i = 0; i < n - 1; i++)
{
long long u, v, w;
cin >> u >> v >> w;
graph[u - 1].push_back({v - 1, w});
graph[v - 1].push_back({u - 1, w});
mini = min(mini, w);
}
dfs(0);
memset(mark, 0, sizeof mark);
dfs2(0);
if (!check)
{
ans -= mini;
}
cout << ans << endl;
}
| a.cc:26:8: error: 'edge' was not declared in this scope
26 | vector<edge > vec;
| ^~~~
a.cc:26:13: error: template argument 1 is invalid
26 | vector<edge > vec;
| ^
a.cc:26:13: error: template argument 2 is invalid
|
s504476469 | p03654 | C++ | #include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
using namespace std;
const long long N = 1e5 + 5;
long long mini = 1e9 + 7;
long long dp[N];
long long dp2[N];
bool mark[N];
bool check = false;
vector<pair<long long, long long>> graph[N];
vector<edge > vec;
long long n, m;
long long ans;
void dfs(long long v)
{
mark[v] = true;
dp[v] = 1;
for (long long i = 0; i < graph[v].size(); i++)
{
long long u = graph[v][i].first;
if (!mark[u])
{
dfs(u);
dp[v] += dp[u];
}
}
}
void dfs2(long long v)
{
mark[v] = true;
for (long long i = 0; i < graph[v].size(); i++)
{
long long u = graph[v][i].first;
long long w = graph[v][i].second;
if (!mark[u])
{
long long cnt1 = dp[u];
long long cnt2 = n - dp[u];
if (cnt1 == cnt2)
{
check = true;
cnt1 = 2 * cnt1 - 1;
}
else
{
cnt1 = 2 * min(cnt1, cnt2);
}
ans += cnt1 * w;
dfs2(u);
}
}
}
int main()
{
cin >> n;
for (long long i = 0; i < n - 1; i++)
{
long long u, v, w;
cin >> u >> v >> w;
graph[u - 1].push_back({v - 1, w});
graph[v - 1].push_back({u - 1, w});
mini = min(mini, w);
}
dfs(0);
memset(mark, 0, sizeof mark);
dfs2(0);
if (!check)
{
ans -= mini;
}
cout << ans << endl;
}
| a.cc:26:8: error: 'edge' was not declared in this scope
26 | vector<edge > vec;
| ^~~~
a.cc:26:13: error: template argument 1 is invalid
26 | vector<edge > vec;
| ^
a.cc:26:13: error: template argument 2 is invalid
|
s990117879 | p03654 | C++ | //#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
using namespace std;
const long long N = 1e5 + 5;
long long mini = 1e9 + 7;
long long dp[N];
long long dp2[N];
bool mark[N];
bool check = false;
vector<pair<long long, long long>> graph[N];
vector<edge > vec;
long long n, m;
long long ans;
void dfs(long long v)
{
mark[v] = true;
dp[v] = 1;
for (long long i = 0; i < graph[v].size(); i++)
{
long long u = graph[v][i].first;
if (!mark[u])
{
dfs(u);
dp[v] += dp[u];
}
}
}
void dfs2(long long v)
{
mark[v] = true;
for (long long i = 0; i < graph[v].size(); i++)
{
long long u = graph[v][i].first;
long long w = graph[v][i].second;
if (!mark[u])
{
long long cnt1 = dp[u];
long long cnt2 = n - dp[u];
if (cnt1 == cnt2)
{
check = true;
cnt1 = 2 * cnt1 - 1;
}
else
{
cnt1 = 2 * min(cnt1, cnt2);
}
ans += cnt1 * w;
dfs2(u);
}
}
}
int main()
{
cin >> n;
for (long long i = 0; i < n - 1; i++)
{
long long u, v, w;
cin >> u >> v >> w;
graph[u - 1].push_back({v - 1, w});
graph[v - 1].push_back({u - 1, w});
mini = min(mini, w);
}
dfs(0);
memset(mark, 0, sizeof mark);
dfs2(0);
if (!check)
{
ans -= mini;
}
cout << ans << endl;
}
| a.cc:26:8: error: 'edge' was not declared in this scope
26 | vector<edge > vec;
| ^~~~
a.cc:26:13: error: template argument 1 is invalid
26 | vector<edge > vec;
| ^
a.cc:26:13: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:84:9: error: 'memset' was not declared in this scope
84 | memset(mark, 0, sizeof mark);
| ^~~~~~
a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
14 | #include<numeric>
+++ |+#include <cstring>
15 |
|
s540248344 | p03654 | C++ | #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e7;
const ll MOD=1e9+7;
const int INF=1<<30;
ll gcd(ll a,ll b){
if(a%b==0)
return b;
return gcd(b,a%b);
}
int main(){
int N,K;
cin >> N >> K;
vector<int> A(N);
rep(i,N){
cin >> A[i];
}
int maxA=0;
int GCD=A[0];
rep(i,N){
if(A[i]>maxA) maxA=A[i];
GCD=gcd(GCD,A[i]);
}
if(maxA=>K&&(maxA-K)%GCD==0) cout << "POSSIBLE" << endl;
else cout << "IMPOSSIBLE" << endl;
}
| a.cc: In function 'int main()':
a.cc:31:11: error: expected primary-expression before '>' token
31 | if(maxA=>K&&(maxA-K)%GCD==0) cout << "POSSIBLE" << endl;
| ^
|
s639170445 | p03654 | C++ | #include <bits/stdc++.h>
using namespace std;
#define maxn 100020
int n,head[maxn],tot = 0,sze[maxn],max_sze[maxn],mind,root;
long long ans = 0;
struct edge {
int v,nxt,w;
}e[maxn<<1];
inline void add_(int u,int v,int w) {
e[++tot].v = v;
e[tot].w = w;
e[tot].nxt = head[u];
head[u] = tot;
}
void dfs_(int u,int fa) {
sze[u] = 1;
for(int i = head[u];~i;i = e[i].nxt) {
int v = e[i].v;
if( v == fa ) continue;
dfs_(v,u);
sze[u] += sze[v];
max_sze[u] = max( max_sze[u],sze[v] );
ans += (long long) 2 * e[i].w * min( sze[v],n - sze[v] );
}
max_sze[u] = max( max_sze[u],n - sze[u] );
if( max_sze[u] < mind ) {
mind = max_sze[u];
root = u;
}
}
int main() {
// memset(head,-1,sizeof(head));
n = read_();int x,y,z;
for(int i = 1;i < n;++i) {
x = read_();y = read_();z = read_();
add_(x,y,z);add_(y,x,z);
}
mind = n + 1;
dfs_(1,0);
mind = 200000000;
for(int i = head[root];~i;i = e[i].nxt) {
int v = e[i].v;
if( max_sze[root] == max_sze[v] ) {ans -= e[i].w;printf("%lld",ans);return 0;}
mind = min( mind,e[i].w );
}
printf("%lld",ans-mind);
return 0;
} | a.cc: In function 'int main()':
a.cc:35:13: error: 'read_' was not declared in this scope; did you mean 'read'?
35 | n = read_();int x,y,z;
| ^~~~~
| read
|
s158099249 | p03654 | C++ | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MAXN = 1e5 + 10;
vector<pair<int, int> > Mat[MAXN];
long long ans, val[MAXN];
int a[MAXN], b[MAXN], n;
int dfs(int v, int p, int w) {
int cnt = 1;
for (int i = 0; i < Mat[v].size(); i++) {
int u = Mat[v][i].first, o = Mat[v][i].second;
if (u != p)
cnt += dfs(u, v, o);
}
ans += min(cnt, n - cnt) * 2 * w;
if (cnt == n - cnt)
val[1] += w;
else if (cnt < n - cnt)
val[v] += w;
else
val[1] += w, val[v] -= w;
return cnt;
}
void dfso(int v, int p, long long tmp) {
val[v] += tmp;
for (int i = 0; i < Mat[v].size(); i++) {
int u = Mat[v][i].first, o = Mat[v][i].second;
if (u != p)
dfso(u, v, val[v]);
}
}
int main() {
cin >> n;
for (int i = 0; i < n - 1; i++) {
int a, b, w;
cin >> a >> b >> w;
Mat[a].push_back({ b, w });
Mat[b].push_back({ a, w });
}
dfs(1, 1, 0);
dfso(1, 1, 0);
long long mn[2] = { 1e9, 1e9 };
for (int i = 1; i <= n; i++) {
mn[1] = min(mn[1], val[i]);
if (mn[1] < mn[0])
swap(mn[1], mn[0]);
}
cout << ans - mn[0] - mn[1];
} | a.cc: In function 'int main()':
a.cc:45:29: error: narrowing conversion of '1.0e+9' from 'double' to 'long long int' [-Wnarrowing]
45 | long long mn[2] = { 1e9, 1e9 };
| ^~~
a.cc:45:34: error: narrowing conversion of '1.0e+9' from 'double' to 'long long int' [-Wnarrowing]
45 | long long mn[2] = { 1e9, 1e9 };
| ^~~
|
s067144726 | p03654 | C++ | #include<bits\stdc++.h>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc()
{
static char buf[1000000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd()
{
int x=0,f=1;char ch=gc();
for(;ch<'0'||ch>'9';ch=gc()) if (ch=='-') f=-1;
for(;ch>='0'&&ch<='9';ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
return x*f;
}
inline int read()
{
int x=0,f=1;char ch=getchar();
for(;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
return x*f;
}
inline void print(int x)
{
if(x<0) putchar('-'),x=-x;
if(x>9) print(x/10);
putchar(x%10+'0');
}
const int N=2e5;
int n,tot,rize,root;
int pre[(N<<1)+10],now[N+10],child[(N<<1)+10],val[(N<<1)+10],size[N+10],Msize[N+10];
ll Ans;
void join(int x,int y,int z){pre[++tot]=now[x],now[x]=tot,child[tot]=y,val[tot]=z;}
void insert(int x,int y,int z){join(x,y,z),join(y,x,z);}
void dfs(int x,int fa,int v)
{
int Max=0;size[x]=1;
for(int p=now[x],son=child[p];p;p=pre[p],son=child[p])
{
if(son==fa) continue;
dfs(son,x,val[p]),size[x]+=size[son];
Max=max(Max,size[son]);
}
Ans+=1ll*min(size[x],n-size[x])*v*2;
Max=max(Max,n-size[x]);Msize[x]=Max;
if(Max<rize) {rize=Max;root=x;}
}
int main()
{
n=read(),rize=inf;
for(int i=1;i<n;i++)
{
int x=read(),y=read(),z=read();
insert(x,y,z);
}
dfs(1,0,0);
int tmp=inf;
for(int p=now[root],son=child[p];p;p=pre[p],son=child[p])
{
tmp=min(tmp,val[p]);
if(Msize[root]==Msize[son])
{
Ans-=val[p];
printf("%lld\n",Ans);
return 0;
}
}
printf("%lld\n",Ans-tmp);
return 0;
} | a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
1 | #include<bits\stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s030937225 | p03654 | C++ | #include<bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;
template<typename tp> inline void read(tp &x) {
x = 0; char c = getchar(); int f = 0;
for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
if (f) x = -x;
}
const int N = 3e5 + 2333;
const int M = N * 2;
struct Edge {
int nxt, to, w;
}e[M];
int head[N], e_cnt = 0;
int n, m, ans = 0, mn = 1e18;
int sz[N], dp[N], f[N], isheart[N];
inline void add(int x, int y, int w) {
e[++ e_cnt] = (Edge) {head[x], y, w}; head[x] = e_cnt;
}
inline void upd(int u, int v, int w) {
sz[u] += sz[v];
dp[u] += min(sz[v], n - sz[v]) * w + dp[v];
}
inline void del(int u, int v, int w) {
sz[u] -= sz[v];
dp[u] -= min(sz[v], n - sz[v]) * w + dp[v];
}
inline void dfs(int u, int fat) {
sz[u] = 1; f[u] = 0;
for (int i = head[u]; i; i = e[i].nxt) {
int v = e[i].to;
int w = e[i].w;
if (v != fat) {
dfs(v, u);
upd(u, v, w);
f[u] = max(f[u], sz[v]);
}
}
f[u] = max(f[u], n - sz[u]);
if (f[u] * 2 <= n)
ishear[u] = true;
}
inline void gao(int u, int v, int w) {
int res = dp[u] + dp[v];
res += min(sz[u], sz[v]) * w;
// cout << u << " " << v << " " << dp[u] << " " << dp[v] << " " << res << "\n";
if (abs(sz[u] - sz[v]) <= 1 || isheart[u])
ans = max(ans, res * 2 - (sz[u] == sz[v] ? w : mn));
}
inline void fsd(int u, int fat) {
for (int i = head[u]; i; i = e[i].nxt) {
int v = e[i].to;
int w = e[i].w;
if (v != fat) {
del(u, v, w); gao(u, v, w); upd(v, u, w);
fsd(v, u);
del(v, u, w); upd(u, v, w);
}
}
}
main(void) {
read(n);
for (int i = 2; i <= n; i ++) {
int x, y, w; read(x); read(y); read(w);
add(x, y, w); add(y, x, w); mn = min(mn, w);
}
dfs(2, 0); fsd(2, 0);
cout << ans << "\n";
}
| a.cc: In function 'void dfs(long long int, long long int)':
a.cc:47:5: error: 'ishear' was not declared in this scope; did you mean 'isheart'?
47 | ishear[u] = true;
| ^~~~~~
| isheart
a.cc: At global scope:
a.cc:70:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
70 | main(void) {
| ^~~~
|
s288343199 | p03654 | C++ | #include <bits/stdc++.h>
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define s second
#define vec vector<int>
using namespace std;
const int N = (int) 5e5 + 10;
const int M = (int) 1e6 + 10;
const int K = (int) 500 + 10;
const int mod = (int) 1e9 + 7;
const ll LINF = (ll) 1e18;
int n;
vec v[N];
map<pii, int> e;
int sz[N];
void calc_sizes(int x = 1, int p = -1) {
sz[x] = 1;
for (auto it : v[x]) {
if (it == p)
continue;
calc_sizes(it, x);
sz[x] += sz[it];
}
}
int main() {
#ifdef sony
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
srand(time(0));
cin >> n;
for (int i = 1, x, y, c; i < n; i++) {
cin >> x >> y >> c;
v[x].pb(y);
v[y].pb(x);
e[mp(x, y)] = e[mp(y, x)] = c;
}
calc_sizes();
ll ans = 0;
for (auto it : e) {
//it.f.f, it.f.s, it.s
//cout << sz[it.f.f] << ' ' << (n - sz[it.f.f]) << ' ' << it.s << "\n";
int x = it.f.f, y = it.f.s;
if (sz[x] < sz[y])
swap(x, y);
//cout << x << ' ' << y << ' ' << sz[y] << '\n';
ans += 1ll * min(sz[y], (n - sz[y])) * it.s;
}
vec centroids;
for (int i = 1; i <= n; i++) {
bool centroid = true;
for (auto it : v[i]) {
if (sz[it] < sz[i] && sz[it] > n / 2)
centroid = false;
}
if (centroid && n - sz[i] <= n / 2) {
centroids.pb(i);
}
}
for (auto it : centroids) {
// cout << it << ' ';
//} cout << '\n';
if (sz(centroids) == 1) {
int cmin = mod;
for (auto it : e) {
if (it.f.f == centroids[0]) {
cmin = min(cmin, it.s);
}
}
ans -= cmin;
} else {
assert(sz(centroids) == 2);
ans -= e[mp(centroids[0], centroids[1])];
}
cout << ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:88:2: error: expected '}' at end of input
88 | }
| ^
a.cc:36:12: note: to match this '{'
36 | int main() {
| ^
|
s444989266 | p03654 | C++ | // test | /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
|
s310680776 | p03654 | C++ | #include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=4e5+10;
long long dep[N];
int head[N],next[N],t[N],cc[N],size[N],tot=0,n,root,sta;
void ad(int x,int y,int z)
{
tot++;
next[tot]=head[x];
head[x]=tot;
t[tot]=y;
cc[tot]=z;
}
void fr(int x,int fa)
{
int i=head[x],blan=0;
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
fr(t[i],x);
size[x]=size[x]+size[t[i]];
blan=max(blan,size[t[i]]);
i=next[i];
}
blan=max(blan,n-size[x]);
if (blan<sta)
{
root=x;
sta=blan;
}
}
void dfs(int x,int fa)
{
int i=head[x];
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
dep[t[i]]=dep[x]+cc[i];
dfs(t[i],x);
size[x]=size[x]+size[t[i]];
i=next[i];
}
}
int main()
{
//freopen("test.in","r",stdin);
scanf("%d",&n);
for (int i=1;i<n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
ad(x,y,z);
ad(y,x,z);
}
sta=1e9+7;
fr(1,0);
dfs(root,0);
long long ans=0;
for (int i=1;i<=n;i++) ans=ans+dep[i];
int i=head[root],num=1e9+7;
while (i)
{
if (size[t[i]]==(n+1)/2) num=min(num,cc[i]);
i=next[i];
}
if (num==1e9+7)
{
int i=head[root];
while (i)
{
num=min(num,cc[i]);
i=next[i];
}
}
ans=ans*2-num;
printf("%lld\n",ans);
} | a.cc: In function 'void ad(int, int, int)':
a.cc:11:9: error: reference to 'next' is ambiguous
11 | next[tot]=head[x];
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:13: note: 'int next [400010]'
7 | int head[N],next[N],t[N],cc[N],size[N],tot=0,n,root,sta;
| ^~~~
a.cc: In function 'void fr(int, int)':
a.cc:24:27: error: reference to 'next' is ambiguous
24 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:13: note: 'int next [400010]'
7 | int head[N],next[N],t[N],cc[N],size[N],tot=0,n,root,sta;
| ^~~~
a.cc:30:19: error: reference to 'next' is ambiguous
30 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:13: note: 'int next [400010]'
7 | int head[N],next[N],t[N],cc[N],size[N],tot=0,n,root,sta;
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:47:27: error: reference to 'next' is ambiguous
47 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:13: note: 'int next [400010]'
7 | int head[N],next[N],t[N],cc[N],size[N],tot=0,n,root,sta;
| ^~~~
a.cc:53:19: error: reference to 'next' is ambiguous
53 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:13: note: 'int next [400010]'
7 | int head[N],next[N],t[N],cc[N],size[N],tot=0,n,root,sta;
| ^~~~
a.cc: In function 'int main()':
a.cc:76:19: error: reference to 'next' is ambiguous
76 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:13: note: 'int next [400010]'
7 | int head[N],next[N],t[N],cc[N],size[N],tot=0,n,root,sta;
| ^~~~
a.cc:84:27: error: reference to 'next' is ambiguous
84 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:13: note: 'int next [400010]'
7 | int head[N],next[N],t[N],cc[N],size[N],tot=0,n,root,sta;
| ^~~~
|
s355714479 | p03654 | C++ | #include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=4e5+10;
int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
long long dep[N];
void ad(int x,int y,int z)
{
tot++;
next[tot]=head[x];
head[x]=tot;
t[tot]=y;
cc[tot]=z;
}
void fr(int x,int fa)
{
int i=head[x],blan=0;
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
fr(t[i],x);
size[x]=size[x]+size[t[i]];
blan=max(blan,size[t[i]]);
i=next[i];
}
blan=max(blan,n-size[x]);
if (blan<sta)
{
root=x;
sta=blan;
}
}
void dfs(int x,int fa)
{
int i=head[x];
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
dep[t[i]]=dep[x]+cc[i];
dfs(t[i],x);
size[x]=size[x]+size[t[i]];
i=next[i];
}
}
int main()
{
//freopen("test.in","r",stdin);
scanf("%d",&n);
for (int i=1;i<n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
ad(x,y,z);
ad(y,x,z);
}
sta=1e9+7;
fr(1,0);
dfs(root,0);
long long ans=0;
for (int i=1;i<=n;i++) ans=ans+dep[i];
int i=head[root],num=1e9+7;
while (i)
{
if (size[t[i]]==(n+1)/2) num=min(num,cc[i]);
i=next[i];
}
if (num==1e9+7)
{
int i=head[root];
while (i)
{
num=min(num,cc[i]);
i=next[i];
}
}
ans=ans*2-num;
printf("%lld\n",ans);
} | a.cc: In function 'void ad(int, int, int)':
a.cc:11:9: error: reference to 'next' is ambiguous
11 | next[tot]=head[x];
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [400010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void fr(int, int)':
a.cc:24:27: error: reference to 'next' is ambiguous
24 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [400010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:30:19: error: reference to 'next' is ambiguous
30 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [400010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:47:27: error: reference to 'next' is ambiguous
47 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [400010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:53:19: error: reference to 'next' is ambiguous
53 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [400010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'int main()':
a.cc:76:19: error: reference to 'next' is ambiguous
76 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [400010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:84:27: error: reference to 'next' is ambiguous
84 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [400010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
|
s546392383 | p03654 | C++ | #include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=2e5+10;
int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
long long dep[N];
void ad(int x,int y,int z)
{
tot++;
next[tot]=head[x];
head[x]=tot;
t[tot]=y;
cc[tot]=z;
}
void fr(int x,int fa)
{
int i=head[x],blan=0;
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
fr(t[i],x);
size[x]=size[x]+size[t[i]];
blan=max(blan,size[t[i]]);
i=next[i];
}
blan=max(blan,n-size[x]);
if (blan<sta)
{
root=x;
sta=blan;
}
}
void dfs(int x,int fa)
{
int i=head[x];
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
dep[t[i]]=dep[x]+cc[i];
dfs(t[i],x);
size[x]=size[x]+size[t[i]];
i=next[i];
}
}
int main()
{
//freopen("test.in","r",stdin);
scanf("%d",&n);
for (int i=1;i<n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
ad(x,y,z);
ad(y,x,z);
}
sta=1e9+7;
fr(1,0);
dfs(root,0);
long long ans=0;
for (int i=1;i<=n;i++) ans=ans+dep[i];
int i=head[root],num=1e9+7;
while (i)
{
if (size[t[i]]==(n+1)/2) num=min(num,cc[i]);
i=next[i];
}
if (num==1e9+7)
{
int i=head[root];
while (i)
{
num=min(num,cc[i]);
i=next[i];
}
}
ans=ans*2-num;
printf("%lld\n",ans);
} | a.cc: In function 'void ad(int, int, int)':
a.cc:11:9: error: reference to 'next' is ambiguous
11 | next[tot]=head[x];
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void fr(int, int)':
a.cc:24:27: error: reference to 'next' is ambiguous
24 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:30:19: error: reference to 'next' is ambiguous
30 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:47:27: error: reference to 'next' is ambiguous
47 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:53:19: error: reference to 'next' is ambiguous
53 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'int main()':
a.cc:76:19: error: reference to 'next' is ambiguous
76 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:84:27: error: reference to 'next' is ambiguous
84 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
|
s208776264 | p03654 | C++ | #include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=2e5+10;
int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
long long dep[N];
void ad(int x,int y,int z)
{
tot++;
next[tot]=head[x];
head[x]=tot;
t[tot]=y;
cc[tot]=z;
}
void fr(int x,int fa)
{
int i=head[x],blan=0;
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
fr(t[i],x);
size[x]=size[x]+size[t[i]];
blan=max(blan,size[t[i]]);
i=next[i];
}
blan=max(blan,n-size[x]);
if (blan<sta)
{
root=x;
sta=blan;
}
}
void dfs(int x,int fa)
{
int i=head[x];
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
dep[t[i]]=dep[x]+cc[i];
dfs(t[i],x);
size[x]=size[x]+size[t[i]];
i=next[i];
}
}
int main()
{
//freopen("test.in","r",stdin);
scanf("%d",&n);
for (int i=1;i<n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
ad(x,y,z);
ad(y,x,z);
}
sta=1e9+7;
fr(1,0);
dfs(root,0);
long long ans=0;
for (int i=1;i<=n;i++) ans=ans+dep[i];
int i=head[root],num=1e9+7;
while (i)
{
if (size[t[i]]==(n+1)/2) num=min(num,cc[i]);
i=next[i];
}
if (num==1e9+7)
{
int i=head[root];
while (i)
{
num=min(num,cc[i]);
i=next[i];
}
}
ans=ans*2-num;
printf("%i64d",ans);
} | a.cc: In function 'void ad(int, int, int)':
a.cc:11:9: error: reference to 'next' is ambiguous
11 | next[tot]=head[x];
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void fr(int, int)':
a.cc:24:27: error: reference to 'next' is ambiguous
24 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:30:19: error: reference to 'next' is ambiguous
30 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:47:27: error: reference to 'next' is ambiguous
47 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:53:19: error: reference to 'next' is ambiguous
53 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'int main()':
a.cc:76:19: error: reference to 'next' is ambiguous
76 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:84:27: error: reference to 'next' is ambiguous
84 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
|
s985476294 | p03654 | C++ | #include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=2e5+10;
int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
long long dep[N];
void ad(int x,int y,int z)
{
tot++;
next[tot]=head[x];
head[x]=tot;
t[tot]=y;
cc[tot]=z;
}
void fr(int x,int fa)
{
int i=head[x],blan=0;
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
fr(t[i],x);
size[x]=size[x]+size[t[i]];
blan=max(blan,size[t[i]]);
i=next[i];
}
blan=max(blan,n-size[x]);
if (blan<sta)
{
root=x;
sta=blan;
}
}
void dfs(int x,int fa)
{
int i=head[x];
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
dep[t[i]]=dep[x]+cc[i];
dfs(t[i],x);
size[x]=size[x]+size[t[i]];
i=next[i];
}
}
int main()
{
//freopen("test.in","r",stdin);
scanf("%d",&n);
for (int i=1;i<n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
ad(x,y,z);
ad(y,x,z);
}
sta=1e9+7;
fr(1,0);
dfs(root,0);
long long ans=0;
for (int i=1;i<=n;i++) ans=ans+dep[i];
int i=head[root],num=1e9+7;
while (i)
{
if (size[t[i]]==(n+1)/2) num=min(num,cc[i]);
i=next[i];
}
if (num==1e9+7)
{
int i=head[root];
while (i)
{
num=min(num,cc[i]);
i=next[i];
}
}
ans=ans*2-num;
printf("%lld",ans);
} | a.cc: In function 'void ad(int, int, int)':
a.cc:11:9: error: reference to 'next' is ambiguous
11 | next[tot]=head[x];
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void fr(int, int)':
a.cc:24:27: error: reference to 'next' is ambiguous
24 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:30:19: error: reference to 'next' is ambiguous
30 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:47:27: error: reference to 'next' is ambiguous
47 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:53:19: error: reference to 'next' is ambiguous
53 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'int main()':
a.cc:76:19: error: reference to 'next' is ambiguous
76 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:84:27: error: reference to 'next' is ambiguous
84 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
|
s372224789 | p03654 | C++ | #include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=2e5+10;
int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
long long dep[N];
void ad(int x,int y,int z)
{
tot++;
next[tot]=head[x];
head[x]=tot;
t[tot]=y;
cc[tot]=z;
}
void fr(int x,int fa)
{
int i=head[x],blan=0;
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
fr(t[i],x);
size[x]=size[x]+size[t[i]];
blan=max(blan,size[t[i]]);
i=next[i];
}
blan=max(blan,n-size[x]);
if (blan<sta)
{
root=x;
sta=blan;
}
}
void dfs(int x,int fa)
{
int i=head[x];
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
dep[t[i]]=dep[x]+cc[i];
dfs(t[i],x);
size[x]=size[x]+size[t[i]];
i=next[i];
}
}
int main()
{
scanf("%d",&n);
for (int i=1;i<n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
ad(x,y,z);
ad(y,x,z);
}
sta=1e9+7;
fr(1,0);
dfs(root,0);
long long ans=0;
for (int i=1;i<=n;i++) ans=ans+dep[i];
int i=head[root],num=1e9+7;
while (i)
{
if (size[t[i]]==(n+1)/2) num=min(num,cc[i]);
i=next[i];
}
if (num==1e9+7)
{
int i=head[root];
while (i)
{
num=min(num,cc[i]);
i=next[i];
}
}
ans=ans*2-num;
printf("%lld",ans);
} | a.cc: In function 'void ad(int, int, int)':
a.cc:11:9: error: reference to 'next' is ambiguous
11 | next[tot]=head[x];
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void fr(int, int)':
a.cc:24:27: error: reference to 'next' is ambiguous
24 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:30:19: error: reference to 'next' is ambiguous
30 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:47:27: error: reference to 'next' is ambiguous
47 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:53:19: error: reference to 'next' is ambiguous
53 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'int main()':
a.cc:75:19: error: reference to 'next' is ambiguous
75 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:83:27: error: reference to 'next' is ambiguous
83 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
|
s209752363 | p03654 | C++ | #include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=2e5+10;
int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
long long dep[N];
void ad(int x,int y,int z)
{
tot++;
next[tot]=head[x];
head[x]=tot;
t[tot]=y;
cc[tot]=z;
}
void fr(int x,int fa)
{
int i=head[x],blan=0;
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
fr(t[i],x);
size[x]=size[x]+size[t[i]];
blan=max(blan,size[t[i]]);
i=next[i];
}
blan=max(blan,n-size[x]);
if (blan<sta)
{
root=x;
sta=blan;
}
}
void dfs(int x,int fa)
{
int i=head[x];
size[x]=1;
while (i)
{
if (t[i]==fa)
{
i=next[i];
continue;
}
dep[t[i]]=dep[x]+cc[i];
dfs(t[i],x);
size[x]=size[x]+size[t[i]];
i=next[i];
}
}
int main()
{
scanf("%d",&n);
for (int i=1;i<n;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
ad(x,y,z);
ad(y,x,z);
}
sta=1e9+7;
fr(1,0);
dfs(root,0);
long long ans=0;
for (int i=1;i<=n;i++) ans=ans+dep[i];
int i=head[root],num=1e9+7;
while (i)
{
if (size[t[i]]==(n+1)/2) num=min(num,cc[i]);
i=next[i];
}
if (num==1e9+7)
{
int i=head[root];
while (i)
{
num=min(num,cc[i]);
i=next[i];
}
}
ans=ans*2-num;
printf("%lld",ans);
} | a.cc: In function 'void ad(int, int, int)':
a.cc:11:9: error: reference to 'next' is ambiguous
11 | next[tot]=head[x];
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void fr(int, int)':
a.cc:24:27: error: reference to 'next' is ambiguous
24 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:30:19: error: reference to 'next' is ambiguous
30 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:47:27: error: reference to 'next' is ambiguous
47 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:53:19: error: reference to 'next' is ambiguous
53 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc: In function 'int main()':
a.cc:75:19: error: reference to 'next' is ambiguous
75 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
a.cc:83:27: error: reference to 'next' is ambiguous
83 | i=next[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:6:13: note: 'int next [200010]'
6 | int head[N],next[N],t[N],cc[N],size[N],tot,n,root,sta;
| ^~~~
|
s184459236 | p03654 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
vector<int> Centroid(const vector<vector<int>> &g) {
int n = g.size();
vector<int> centroid;
vector<int> sz(n);
function<void (int, int)> dfs = [&](int u, int prev) {
sz[u] = 1;
bool is_centroid = true;
for (auto v : g[u]) if (v != prev) {
dfs(v, u);
sz[u] += sz[v];
if (sz[v] > n / 2) is_centroid = false;
}
if (n - sz[u] > n / 2) is_centroid = false;
if (is_centroid) centroid.push_back(u);
};
dfs(0, -1);
return centroid;
}
int main() {
int n;
scanf("%d", &n);
vector<vector<int>> g(n);
vector<vector<pair<int ,int>>> gg(n);
for (int i = 0; i < n - 1; i ++) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
a --, b --;
g[a].push_back(b);
g[b].push_back(a);
gg[a].emplace_back(b, c);
gg[b].emplace_back(a, c);
}
long long ans = 0;
vector<int> sz(n);
function<void (int, int)> dfs = [&](int u, int prev) {
sz[u] = 1;
for (auto e : gg[u]) {
int v = e.first, cost = e.second;
if (v == prev) continue;
dfs(v, u);
sz[u] += sz[v];
ans += min(sz[v], n - sz[v]) * 2 * cost;
}
};
dfs(0, -1);
auto centroid = Centroid(g);
if (centroid.size() == 1) {
int mi = 0x3f3f3f3f;
for (auto e : gg[centroid[0]]) {
mi = min(mi, e.second);
}
ans -= mi;
} else {
for (auto e : gg[centroid[0]]) {
if (e.first == centroid[1]) {
ans -= e.second;
break;
}
}
}
printf("%lld\n", ans);
return 0;
}
| a.cc: In function 'std::vector<int> Centroid(const std::vector<std::vector<int> >&)':
a.cc:14:9: error: 'function' was not declared in this scope
14 | function<void (int, int)> dfs = [&](int u, int prev) {
| ^~~~~~~~
a.cc:8:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
7 | #include <set>
+++ |+#include <functional>
8 | using namespace std;
a.cc:14:32: error: expression list treated as compound expression in functional cast [-fpermissive]
14 | function<void (int, int)> dfs = [&](int u, int prev) {
| ^
a.cc:14:18: error: expected primary-expression before 'void'
14 | function<void (int, int)> dfs = [&](int u, int prev) {
| ^~~~
a.cc:25:9: error: 'dfs' was not declared in this scope
25 | dfs(0, -1);
| ^~~
a.cc: In function 'int main()':
a.cc:45:9: error: 'function' was not declared in this scope
45 | function<void (int, int)> dfs = [&](int u, int prev) {
| ^~~~~~~~
a.cc:45:9: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
a.cc:45:32: error: expression list treated as compound expression in functional cast [-fpermissive]
45 | function<void (int, int)> dfs = [&](int u, int prev) {
| ^
a.cc:45:18: error: expected primary-expression before 'void'
45 | function<void (int, int)> dfs = [&](int u, int prev) {
| ^~~~
a.cc:55:9: error: 'dfs' was not declared in this scope
55 | dfs(0, -1);
| ^~~
|
s689351454 | p03654 | C++ | //satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
ll gcd(ll a, ll b){
if(b == 0) return a;
return gcd(b, a%b);
}
const int N = 100002;
int n, subsize[N], parent_[N];
vector<ii> adj[N];
void dfs(int v, int par){
subsize[v] = 1;
parent_[v] = par;
for(auto it : adj[v])
if(it.ff != par){
dfs(it.ff, v);
subsize[v] += subsize[it.ff];
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n;
int e = n-1;
while(e--){
int a, b, c;
cin>>a>>b>>c;
adj[a].pb(ii(b, c));
adj[b].pb(ii(a, c));
}
dfs(1, -1);
// cout<<"subsize: ";for(int i=1;i<=n;i++) cout<<subsize[i]<<" ";cout<<endl;
ll minval = 1e15, yolo = -1;
ll ans = 0;
for(int i=1;i<=n;i++)
for(auto it : adj[i])
if(it.ff > i){
ll s = min(subsize[i], subsize[it.ff]);
s = min(s, n-s);
ans += 2LL * s * it.ss;
// cout<<"now at "<<i<<" "<<it.ff<<":"<<it.ss<<" "<<s<<endl;
minval = min(minval, it.ss);
}
for(int i=1;i<=n;i++)
if(2*subsize[i] == n){
for(auto it : adj[i])
if(it.ff == parent_[i]){
cout<<ans-it.ss;
return 0;
}
}
cout<<ans - minval;
return 0;
}
| a.cc: In function 'int main()':
a.cc:69:29: error: no matching function for call to 'min(ll&, int&)'
69 | minval = min(minval, it.ss);
| ~~~^~~~~~~~~~~~~~~
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:2:
/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:69:29: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
69 | minval = min(minval, it.ss);
| ~~~^~~~~~~~~~~~~~~
/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:
/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:69:29: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
69 | minval = min(minval, it.ss);
| ~~~^~~~~~~~~~~~~~~
|
s673830518 | p03654 | Java | import java.util.*;
import java.lang.*;
public class Main{
static int [] head;
static int [] next;
static int [] to;
static long [] cost;
static int [] size;
static int edgeCount = 0;
static long ans = 0;
static int N;
public static void main(String [] args) {
Scanner sc = new Scanner(new BufferedInputStream(System.in));
N = sc.nextInt();
head = new int [N + 1];
size = new int [N + 1];
next = new int [N + N + 1];
to = new int [N + N + 1];
cost = new long [N + N + 1];
for(int i = 0; i < N - 1; i++) {
int A = sc.nextInt();
int B = sc.nextInt();
int C = sc.nextInt();
addEdge(A,B,C);
addEdge(B,A,C);
}
calcSize(1);
dfs(1);
System.out.println(ans);
}
public static void dfs(int root) {
int maxNodeSize = N - size[root];
long minEdgeCost = Long.MAX_VALUE;
for(int e = head[root]; e != 0; e = next[e]) {
int destination = to[e];
minEdgeCost = Math.min(minEdgeCost,cost[e]);
if(size[destination] < size[root]) {
maxNodeSize = Math.max(maxNodeSize,size[destination]);
long min = Math.min(size[destination], N - size[destination]);
ans = ans + min * cost[e] * 2;
dfs(destination);
if(min + min == N) {
ans = ans - cost[e];
}
}
}
if(maxNodeSize * 2 < N) {
ans = ans - minEdgeCost;
}
}
public static int calcSize(int root) {
size[root] = 1;
for(int e = head[root]; e != 0; e = next[e]) {
if(size[to[e]] == 0) {
size[root] += calcSize(to[e]);
}
}
return size[root];
}
public static void addEdge(int A, int B, int C) {
edgeCount += 1;
to[edgeCount] = B;
cost[edgeCount] = C;
next[edgeCount] = head[A];
head[A] = edgeCount;
}
}
| Main.java:15: error: cannot find symbol
Scanner sc = new Scanner(new BufferedInputStream(System.in));
^
symbol: class BufferedInputStream
location: class Main
1 error
|
s772581933 | p03654 | C++ | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> PP;
/*
freopen("input","r",stdin);
freopen("output","w",stdout);
*/
vector<vector<int> > G;
unordered_map<ll, ll> C;
unordered_map<ll, int> D;
unordered_map<ll, ll> E;
ll mp(int a, int b) {
return a * (1LL << 30) + b;
}
void cal(int a, int b) {
// Calculate following contents:
// (1) Number of child in subtree root as a, without branch b.
// (2) Sum of path sum till subtree a.
if (D.count(mp(a, b))) return;
int child = 1;
ll sum = 0;
for (int n = 0;n < G[a].size();n++) {
int m = G[a][n];
if (m == b) continue;
cal(m, a);
child += D[mp(m, a)];
sum += E[mp(m, a)];
}
sum += C[mp(a, b)] * 2 * child;
E[mp(a, b)] = sum;
D[mp(a, b)] = child;
return;
}
int main() {
ios::sync_with_stdio(false);
int N;
cin >> N;
G.resize(N);
for (int i = 1;i < N;i++) {
int a, b, c;
cin >> a >> b >> c;
a--;
b--;
G[a].push_back(b);
G[b].push_back(a);
C[mp(a, b)] = c;
C[mp(b, a)] = c;
}
for (int i = 0;i < N;i++) {
for (int j = 0;j < G[i].size();j++) {
cal(i, G[i][j]);
}
}
cout << 0 << endl;
return;
ll ans = 0;
for (int i = 0;i < N;i++) {
// Try use i as root.
int ma = 0;
int idx = 0;
ll sol = 0;
bool ok = 1;
for (int j = 0;j < G[i].size() && ok;j++) {
ll k = mp(G[i][j], i);
if (D[k] > ma) {
ma = max(ma, D[k]); // Maximum branch.
if (ma > N - 1 - ma + 1) ok = 0;
idx = G[i][j];
}
sol += E[k];
}
if (ok == 0) continue;
int rem = N - 1 - ma;
if (ma > rem + 1) continue; // Could not pair.
if (ma == rem + 1) {
sol -= C[mp(i, idx)];
}
else {
// Remove one branch.
ll mi = 1E9;
for (int j = 0;j < G[i].size();j++) {
mi = min(mi, C[mp(i, G[i][j])]);
}
sol -= mi;
}
ans = max(ans, sol);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:84:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
84 | return;
| ^~~~~~
|
s831396299 | p03654 | C++ | #include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <cstdio>
typedef long long ll;
#define INF 0x3f3f3f3f
using namespace std;
struct Node {
int parent;
int dis;
int depth;
vector<int> child;
};
int N;
int graph[100000 + 10][100000 + 10];
int parent[100000 + 10];
int depth[100000 + 10];
int dis[100000 + 10];
bool visited[100000 + 10];
int root;
void dfs(int v, int p, int d) {
parent[v] = p;
depth[v] = d;
//printf("visited %d and %d is parent\n", v, p);
for (int i = 1; i <= N; i++) {
if (i != p && graph[v][i] > 0) {
dis[i] = graph[v][i];
dfs(i, v, d + 1);
}
}
}
void build() {
int a, b, c;
scanf("%d", &N);
for(int i = 0; i < N - 1; i++) {
scanf("%d%d%d", &a, &b, &c);
graph[a][b] = graph[b][a] = c;
}
dfs(1, 0, 0);
}
long long lca(int u, int v) {
long long ans = 0;
while(depth[u] > depth[v]) {
ans += dis[u];
u = parent[u];
}
while(depth[v] > depth[u]) {
ans += dis[v];
v = parent[v];
}
while(u != v) {
ans += dis[u] + dis[v];
u = parent[u];
v = parent[v];
}
return ans;
}
long long hamPath(int start, int len) {
if(len == N) {
return 0;
}
long long ans = 0;
visited[start] = true;
for(int i = 1; i <= N; i++) {
if(visited[i] == false) {
ans = max(ans, hamPath(i, len + 1) + graph[start][i]);
}
}
visited[start] = false;
return ans;
}
void solve() {
build();
for(int i = 1; i <= N; i++) {
for(int j = i + 1; j <= N; j++) {
graph[i][j] = graph[j][i] = lca(i, j);
}
}
long long ans = 0;
for(int i = 1; i<= N; i++) {
memset(visited, false, sizeof(visited));
ans = max(ans, hamPath(i, 1));
}
printf("%lld\n", ans);
}
int main(int argc, char *argv[]) {
solve();
/*
build();
cout << lca(1, 5) << endl;
for(int i = 1; i <= N; i++)
cout << parent[i] << " ";
cout << endl;
for(int i = 1; i <= N; i++)
cout << dis[i] << " ";
cout << endl;
for(int i = 1; i <= N; i++)
cout << depth[i] << " ";
cout << endl;
for(int i = 1; i <= N; i++) {
for(int j = 1; j <= N; j++) {
cout << lca(i, j) << " ";
}
cout << endl;
}*/
} | /tmp/ccMjOyKJ.o: in function `dfs(int, int, int)':
a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `parent' defined in .bss section in /tmp/ccMjOyKJ.o
a.cc:(.text+0x3b): relocation truncated to fit: R_X86_64_PC32 against symbol `depth' defined in .bss section in /tmp/ccMjOyKJ.o
a.cc:(.text+0xbc): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccMjOyKJ.o
/tmp/ccMjOyKJ.o: in function `lca(int, int)':
a.cc:(.text+0x209): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccMjOyKJ.o
a.cc:(.text+0x226): relocation truncated to fit: R_X86_64_PC32 against symbol `parent' defined in .bss section in /tmp/ccMjOyKJ.o
a.cc:(.text+0x240): relocation truncated to fit: R_X86_64_PC32 against symbol `depth' defined in .bss section in /tmp/ccMjOyKJ.o
a.cc:(.text+0x257): relocation truncated to fit: R_X86_64_PC32 against symbol `depth' defined in .bss section in /tmp/ccMjOyKJ.o
a.cc:(.text+0x274): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccMjOyKJ.o
a.cc:(.text+0x291): relocation truncated to fit: R_X86_64_PC32 against symbol `parent' defined in .bss section in /tmp/ccMjOyKJ.o
a.cc:(.text+0x2ab): relocation truncated to fit: R_X86_64_PC32 against symbol `depth' defined in .bss section in /tmp/ccMjOyKJ.o
a.cc:(.text+0x2c2): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s790413459 | p03654 | C++ | #include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000009;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
vector<pair<int,long long> >g[110000];
int sz[110000];
long long ret=0;
long long mm;
bool ng=false;
int N;
int V=0;
void dfs(int a,int b){
sz[a]=1;
for(int i=0;i<g[a].size();i++){
if(b==g[a][i].first)continue;
dfs(g[a][i].first,a);
sz[a]+=sz[g[a][i].first];
ret+=g[a][i].second*min(sz[g[a][i].first],N-sz[g[a][i].first]);
V=max(V,min(sz[g[a][i].first],N-sz[g[a][i].first]));
// if(ABS(sz[g[a][i].first]==N-sz[g[a][i].first]){
// mm=g[a][i].second;ng=true;
// }
// if(ABS(sz[g[a][i].first]-(N-sz[g[a][i].first]))<=1){
// mm=min(mm,g[a][i].second);
// }
}
}
void dfs2(int a,int b){
for(int i=0;i<g[a].size();i++){
if(b==g[a][i].first)continue;
dfs2(g[a][i].first,a);
if(V==min(sz[g[a][i].first],N-sz[g[a][i].first])){
mm=min(mm,g[a][i].second);
}
// if(ABS(sz[g[a][i].first]==N-sz[g[a][i].first]){
// mm=g[a][i].second;ng=true;
// }
// if(ABS(sz[g[a][i].first]-(N-sz[g[a][i].first]))<=1){
// mm=min(mm,g[a][i].second);
// }
}
}
int main(){
int a;scanf("%d",&a);
N=a;
mm=mod;
for(int i=0;i<a-1;i++){
int p,q;long long r;scanf("%d%d%lld",&p,&q,&r);
p--;q--;g[p].push_back(make_pair(q,r));g[q].push_back(make_pair(p,r));
}
if(a==2){
printf("%lld\n",g[0][0].second);return 0;
}
int par=0;
for(int i=0;i<a;i++){
if(g[i].size()>1)par=i;
}
dfs(par,-1);
// dfs2(par,-1);
for(int i=0;i<a;i++){
if(min(sz[i],N-sz[i])==V){
for(int j=0;j<g[a][i].size();j++){
mm=min(mm,g[i][j].second);
}
}
}
ret*=2;
ret-=mm;
printf("%lld\n",ret);
} | a.cc: In function 'int main()':
a.cc:78:35: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, long long int> >, std::pair<int, long long int> >::value_type' {aka 'struct std::pair<int, long long int>'} has no member named 'size'
78 | for(int j=0;j<g[a][i].size();j++){
| ^~~~
|
s885634605 | p03654 | C++ | 1 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 1
| ^
|
s681762352 | p03654 | C++ | #include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
using namespace std;
typedef long long LL;
const int N=200010;
const int inf=0x3f3f3f3f;
template<typename T>inline T chkmax(T A,T B){return A>B?A:B;}
template<typename T>inline T chkmin(T A,T B){return A<B?A:B;}
template<typename T>inline void read(T &x)
{
x=0;int _f(0);char ch=getchar();
while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
}
int n;
int bgn[N],nxt[N],to[N],E;
LL w[N],ans,Min;
int sz[N],flag;
inline void add_edge(int u,int v,int ew){nxt[++E]=bgn[u],bgn[u]=E,to[E]=v,w[E]=ew;}
inline void dfs(int u,int f,LL ew)
{
sz[u]=1;
for(int v,i=bgn[u];i;i=nxt[i])
{
if((v=to[i])==f)continue;
dfs(v,u,w[i]);
sz[u]+=sz[v];
}
if(sz[u]==n-sz[u])
{
flag=1;
ans-=ew;
}
ans+=(LL)chkmin(sz[u],n-sz[u])*ew*2ll;
}
int main()
{
int x,y,z;
read(n);
Min=inf;
For(i,2,n)
{
read(x),read(y),read(z);
add_edge(x,y,z),add_edge(y,x,z);
Min=chkmin(Min,z);
}
dfs(1,0,0);
if(!flag)ans-=Min;
printf("%lld\n",ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:61:27: error: no matching function for call to 'chkmin(LL&, int&)'
61 | Min=chkmin(Min,z);
| ~~~~~~^~~~~~~
a.cc:16:30: note: candidate: 'template<class T> T chkmin(T, T)'
16 | template<typename T>inline T chkmin(T A,T B){return A<B?A:B;}
| ^~~~~~
a.cc:16:30: note: template argument deduction/substitution failed:
a.cc:61:27: note: deduced conflicting types for parameter 'T' ('long long int' and 'int')
61 | Min=chkmin(Min,z);
| ~~~~~~^~~~~~~
|
s302407508 | p03655 | C++ | #include <bits/stdc++.h>
const int N = 2000010;
const int mod = 1000000007;
int inv[N], fact[N], ifact[N];
inline void Init() {
inv[1] = 1;
for (int i = 2; i < N; i++)
inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
fact[0] = ifact[0] = 1;
for (int i = 1; i < N; i++) {
fact[i] = 1ll * fact[i - 1] * i % mod;
ifact[i] = 1ll * ifact[i - 1] * inv[i] % mod;
}
}
inline int F(int x1, int y1, int x2, int y2) {
return 1ll * fact[x2 + y2 - x1 - y1] * ifact[x2 - x1] % mod * ifact[y2 - y1] % mod;
}
inline int calc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
int res = 0;
for (int i = x3; i <= x4; i++)
res = (res + 1ll * F(x1, y1, i, y3 - 1) * F(i, y3, x2, y2) % mod * (mod - i - y3) % mod) % mod;
for (int j = y3; j <= y4; j++)
res = (res + 1ll * F(x1, y1, x3 - 1, j) * F(x3, j, x2, y2) % mod * (mod - j - x3) % mod) % mod;
for (int i = x3; i <= x4; i++)
res = (res + 1ll * F(x1, y1, i, y4) * F(i, y4 + 1, x2, y2) % mod * (i + y4 + 1) % mod) % mod;
for (int j = y3; j <= y4; j++)
res = (res + 1ll * F(x1, y1, x4, j) * F(x4 + 1, j, x2, y2) % mod * (j + x4 + 1) % mod) % mod;
return res;
}
struct Node {
int x, y, z;
} ss[4], tt[4];
int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
int main() {
Init();
std::scanf("%d%d%d%d%d%d", &x1, &x2, &x3, &x4, &x5, &x6);
std::scanf("%d%d%d%d%d%d", &y1, &y2, &y3, &y4, &y5, &y6);
ss[0] = (Node){x1 - 1, y1 - 1, 1};
ss[1] = (Node){x1 - 1, y2, mod - 1};
ss[2] = (Node){x2, y1 - 1, mod - 1};
ss[3] = (Node){x2, y2, 1};
tt[0] = (Node){x6 + 1, y6 + 1, 1};
tt[1] = (Node){x6 + 1, y5, mod - 1};
tt[2] = (Node){x5, y6 + 1, mod - 1};
tt[3] = (Node){x5, y5, 1};
int ans = 0;
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
ans = (ans + 1ll * calc(ss[i].x, ss[i].y, tt[j].x, tt[j].y, x3, y3, x4, y4) * ss[i].z % mod * tt[j].z % mod) % mod;
std::printf("%d\n", ans);
return 0;
} | a.cc:33:9: error: 'int y1' redeclared as different kind of entity
33 | int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:38:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
38 | ss[0] = (Node){x1 - 1, y1 - 1, 1};
| ~~~^~~
a.cc:38:35: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
38 | ss[0] = (Node){x1 - 1, y1 - 1, 1};
| ~~~^~~
| |
| double (*)(double) noexcept
a.cc:40:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
40 | ss[2] = (Node){x2, y1 - 1, mod - 1};
| ~~~^~~
a.cc:40:31: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
40 | ss[2] = (Node){x2, y1 - 1, mod - 1};
| ~~~^~~
| |
| double (*)(double) noexcept
|
s624409057 | p03655 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define nn 3000008
#define mod 1000000007
int qpow(int x,int y=mod-2){
int res=1;while(y){
if(y&1) res=res*x%mod;
x=x*x%mod;y=y/2;
}
return res;
}
int f[nn],rf[nn];
int C(int n,int m){
return f[n]*rf[m]%mod*rf[n-m]%mod;
}
int y2[2],x2[2];
int go(int x,int y){
if(x<0 or y<0) return 0;
return C(x+y,x);
}
int solve(int x1,int y1,int x3,int y3){
int ans=0;
for(int i=y2[0];i<=y2[1];i++){
ans-=(i-y1+x2[0]-x1-1)*go(x2[0]-x1-1,i-y1)%mod*go(x3-x2[0],y3-i)%mod;
ans+=(i-y1+x2[1]-x1)*go(x2[1]-x1,i-y1)%mod*go(x3-1-x2[1],y3-i)%mod;
}
for(int i=x2[0];i<=x2[1];i++){
ans-=(i-x1+y2[0]-y1-1)*go(i-x1,y2[0]-y1-1)%mod*go(x3-i,y3-y2[0])%mod;
ans+=(i-x1+y2[1]-y1)*go(i-x1,y2[1]-y1)%mod*go(x3-i,y3-1-y2[1])%mod;
}
return ans%mod;
}
int x1[2],x3[2],y1[2],y3[2];
void in(int a[]){
for(int i=0;i<2;i++) scanf("%lld",&a[i]);
}
signed main(){
f[0]=1;for(int i=1;i<nn;i++) f[i]=f[i-1]*i%mod;
rf[nn-1]=qpow(f[nn-1]);
for(int i=nn-2;i>=0;i--) rf[i]=rf[i+1]*(i+1)%mod;
in(x1);in(x2);in(x3);in(y1);in(y2);in(y3);
// x1[0]--,y1[0]--;
// x3[1]++,y3[1]++;
int ans=0;
for(int i=x1[0];i<=x1[1];i++) for(int j=y1[0];j<=y1[1];j++)
for(int k=x3[0];k<=x3[1];k++) for(int l=y3[0];l<=y3[1];l++)
ans+=solve(i,j,k,l);
// for(int i=0;i<2;i++) for(int j=0;j<2;j++) for(int k=0;k<2;k++) for(int l=0;l<2;l++){
// int ret=solve(x1[i],y1[j],x3[k],y3[l]);
// if(i^j^k^l) ans-=ret;else ans+=ret;ans%=mod;
// }
ans+=mod;ans%=mod;printf("%lld\n",ans);
return 0;
} | a.cc:34:21: error: 'long long int y1 [2]' redeclared as different kind of entity
34 | int x1[2],x3[2],y1[2],y3[2];
| ^
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:43:32: error: cannot convert 'double (*)(double) noexcept' to 'long long int*'
43 | in(x1);in(x2);in(x3);in(y1);in(y2);in(y3);
| ~~^~~~
| |
| double (*)(double) noexcept
a.cc:35:13: note: initializing argument 1 of 'void in(long long int*)'
35 | void in(int a[]){
| ^
a.cc:48:53: warning: pointer to a function used in arithmetic [-Wpointer-arith]
48 | for(int i=x1[0];i<=x1[1];i++) for(int j=y1[0];j<=y1[1];j++)
| ^
a.cc:48:53: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
48 | for(int i=x1[0];i<=x1[1];i++) for(int j=y1[0];j<=y1[1];j++)
| ^
| |
| double (*)(double) noexcept
a.cc:48:62: warning: pointer to a function used in arithmetic [-Wpointer-arith]
48 | for(int i=x1[0];i<=x1[1];i++) for(int j=y1[0];j<=y1[1];j++)
| ^
a.cc:48:56: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
48 | for(int i=x1[0];i<=x1[1];i++) for(int j=y1[0];j<=y1[1];j++)
| ~^~~~~~~
|
s814905757 | p03655 | C++ | #include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
const int mod=1e9+7;
using namespace std;
int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
ll zl[1000005];
ll yl[1000005];
ll sl[1000005];
ll xl[1000005];
ll zr[1000005];
ll yr[1000005];
ll sr[1000005];
ll xr[1000005];
namespace combinatorics
{
int *fac;
int *ifac;
int __Tmod;
inline int add(int a,int b)
{
return (a+b)%__Tmod;
}
inline int sub(int a,int b)
{
return (a-b+__Tmod)%__Tmod;
}
inline int mult(int a,int b)
{
return (1LL*a*b)%__Tmod;
}
inline int fastpow(int basic,int x)
{
int res=1;
while(x)
{
if(x&1) res=mult(res,basic);
basic=mult(basic,basic);
x>>=1;
}
return res;
}
inline int inv(int x)
{
return fastpow(x,__Tmod-2);
}
void init(int n,int tmod)
{
__Tmod=tmod;
fac=new int[n+5];
ifac=new int[n+5];
fac[0]=1;
for(int i=1;i<=n;i++)
{
fac[i]=mult(fac[i-1],i);
}
ifac[n]=inv(fac[n]);
for(int i=n-1;i>=0;i--)
{
ifac[i]=mult(ifac[i+1],i+1);
}
}
inline int C(int n,int m)
{
return mult(mult(fac[n],ifac[m]),ifac[n-m]);
}
inline int Cat(int x)
{
return mult(C(x*2,x),inv(x+1));
}
};
using namespace combinatorics;
inline ll calc(int sx,int sy,int ex,int ey)
{
if(sx>ex) return 0;
if(sy>ey) return 0;
return C(ex-sx+ey-sy,ex-sx);
}
inline ll lenof(int sx,int sy,int ex,int ey)
{
return abs(sx-ex)+abs(sy-ey);
}
inline ll solve(int sx,int sy,int ex,int ey)
{
ll res=0;
for(int i=x3;i<=x4;i++)
{
res=add(res,mult(mult(calc(sx,sy,i,y4),calc(i,y4+1,ex,ey)),i+y4+1));
res=sub(res,mult(mult(calc(sx,sy,i,y3-1),calc(i,y3,ex,ey)),i+y3));
}
for(int j=y3;j<=y4;j++)
{
res=add(res,mult(mult(calc(sx,sy,x4,j),calc(x4+1,j,ex,ey)),x4+j+1));
res=sub(res,mult(mult(calc(sx,sy,x3-1,j),calc(x3,j,ex,ey)),j+x3));
}
return res;
}
int main()
{
// freopen("input.txt","r",stdin);
init(4e6,mod);
cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
ll res=0;
res+=solve(x1-1,y1-1,x5,y5);
res+=solve(x1-1,y1-1,x6+1,y6+1);
res+=solve(x2,y2,x5,y5);
res+=solve(x2,y2,x6+1,y6+1);
res+=solve(x1-1,y2,x6+1,y5);
res+=solve(x1-1,y2,x5,y6+1);
res+=solve(x2,y1-1,x5,y6+1);
res+=solve(x2,y1-1,x6+1,y5);
res-=solve(x1-1,y1-1,x6+1,y5);
res-=solve(x1-1,y1-1,x5,y6+1);
res-=solve(x2,y2,x5,y6+1);
res-=solve(x2,y2,x6+1,y5);
res-=solve(x1-1,y2,x5,y5);
res-=solve(x1-1,y2,x6+1,y6+1);
res-=solve(x2,y1-1,x5,y5);
res-=solve(x2,y1-1,x6+1,y6+1);
res%=mod;
if(res<0) res+=mod;
cout<<res<<endl;
return 0;
} | a.cc:31:5: error: 'int y1' redeclared as different kind of entity
31 | int y1,y2,y3,y4,y5,y6;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/bits/requires_hosted.h:31,
from /usr/include/c++/14/iostream:38,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:132:36: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42:
/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:
a.cc:132:38: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ^~
/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:
a.cc:132:38: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ^~
| |
| double (*)(double) noexcept
a.cc:132:38: error: cannot bind rvalue '(short int)y1' to 'short int&'
/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:
a.cc:132:38: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ^~
| |
| double (*)(double) noexcept
a.cc:132:38: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/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:
a.cc:132:38: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ^~
| |
| double (*)(double) noexcept
a.cc:132:38: error: cannot bind rvalue '(int)y1' to 'int&'
/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:
a.cc:132:38: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ^~
| |
| double (*)(double) noexcept
a.cc:132:38: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/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:
a.cc:132:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ^~
| |
| double (*)(double) noexcept
a.cc:132:38: error: cannot bind rvalue '(long int)y1' to 'long int&'
/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:
a.cc:132:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ^~
| |
| double (*)(double) noexcept
a.cc:132:38: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/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:
a.cc:132:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ^~
| |
| double (*)(double) noexcept
a.cc:132:38: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/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:
a.cc:132:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ^~
| |
| double (*)(double) noexcept
a.cc:132:38: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/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:
a.cc:132:38: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
132 | cin>>x1>>x2>>x3>>x4>>x5>>x6>>y1>>y2>>y3>>y4>>y5>>y6;
| ^~
| |
| double (*)(double) noexcept
a.cc:132:38: error: cannot bind rvalue '(void*)y1' 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:
a.cc:132:38: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
132 | cin>>x1>>x2>>x |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.