submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s216417164 | p00668 | C++ | #include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int s[1<<20];
int size;
// k人目の状態をseg-treeで管理
// ノードは区間内の生存者の合計を保持
void init(int n){
size = 1;
while(size < n){
size *= 2;
}
memset(s, 0, sizeof(int)*size*2);
}
// k番目にaを加算
void add(int k, int a){
k += size-1;
s[k] += a;
while(k > 0){
k = (k-1)/2;
s[k]+=a;
}
}
// 生存者のn番目の位置を探す
int query(int n, int k, int l, int r){
if(s[k] < n || s[k] == 0) return -1;
if(r - l == 1){
return k-(size-1);
}
int chl = k*2+1, chr = k*2+2;
int ret = query(n, chl, l, (l+r)/2);
if(ret != -1) return ret;
return query(n-s[chl], chr, (l+r)/2, r);
}
int main(){
int q, lim;
while(cin >> q >> lim, q|lim){
init(q);
map<int, int> idmap;
vector<int> v;
int idx = 0;
rep(i, q){
int type, x;
cin >> type >> x;
int pos;
switch(type){
case 0:
v.push_back(x);
idmap[x] = idx;
add(idx++, 1);
// 生存者がlim人を超えたら一番左を殺す
if(s[0] > lim){
add(query(1, 0, 0, size), -1);
}
break;
case 1:
add(query(x, 0, 0, size), -1);
break;
case 2:
pos = query(x, 0, 0, size);
cout << v[pos] << endl;
break;
case 3:
add(idmap[x], -1);
break;
}
}
cout << "end" << endl;
}
return 0;
} | a.cc: In function 'void init(int)':
a.cc:23:9: error: reference to 'size' is ambiguous
23 | size = 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:18:5: note: 'int size'
18 | int size;
| ^~~~
a.cc:24:15: error: reference to 'size' is ambiguous
24 | while(size < n){
| ^~~~
/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:18:5: note: 'int size'
18 | int size;
| ^~~~
a.cc:25:17: error: reference to 'size' is ambiguous
25 | size *= 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:18:5: note: 'int size'
18 | int size;
| ^~~~
a.cc:27:34: error: reference to 'size' is ambiguous
27 | memset(s, 0, sizeof(int)*size*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:18:5: note: 'int size'
18 | int size;
| ^~~~
a.cc:27:9: error: 'memset' was not declared in this scope
27 | memset(s, 0, sizeof(int)*size*2);
| ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
7 | #include <queue>
+++ |+#include <cstring>
8 |
a.cc: In function 'void add(int, int)':
a.cc:32:14: error: reference to 'size' is ambiguous
32 | k += size-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:18:5: note: 'int size'
18 | int size;
| ^~~~
a.cc: In function 'int query(int, int, int, int)':
a.cc:44:27: error: reference to 'size' is ambiguous
44 | return k-(size-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:18:5: note: 'int size'
18 | int size;
| ^~~~
a.cc: In function 'int main()':
a.cc:71:60: error: reference to 'size' is ambiguous
71 | add(query(1, 0, 0, size), -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:18:5: note: 'int size'
18 | int size;
| ^~~~
a.cc:75:52: error: reference to 'size' is ambiguous
75 | add(query(x, 0, 0, size), -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:18:5: note: 'int size'
18 | int size;
| ^~~~
a.cc:78:54: error: reference to 'size' is ambiguous
78 | pos = query(x, 0, 0, size);
| ^~~~
/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:18:5: note: 'int size'
18 | int size;
| ^~~~
|
s380901290 | p00669 | C++ | import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
void main() {
int n, k;
int[] x;
bool input() {
scanf("%d %d\n", &n, &k);
if (n == 0 && k == 0) return false;
x = new int[n];
foreach (i; 0 .. n) {
scanf("%d\n", &x[i]);
}
return true;
}
void solve() {
int MaxPoint() {
int CalcK(int i) {
if (i + k > n) return 0;
int Ret = 1;
foreach (j; 0 .. k) {
Ret *= x[i + j];
}
return Ret;
}
int ck = 0;
foreach (i; 0 .. n) {
ck = max(ck, CalcK(i));
}
return ck;
}
int Ans = int.min;
int o = MaxPoint;
foreach (i; 0 .. n) {
foreach (j; i + 1 .. n) {
swap(x[i], x[j]);
Ans = max(Ans, MaxPoint);
swap(x[j], x[i]);
}
}
writeln(Ans - o);
}
while (input) solve;
} | a.cc:1:1: error: 'import' does not name a type
1 | import std.stdio;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import std.c.stdio;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import std.range;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import std.array;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import std.functional;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import std.algorithm;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
7 | import std.conv;
| ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
8 | import std.container;
| ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'import' does not name a type
9 | import std.math;
| ^~~~~~
a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: 'import' does not name a type
10 | import std.numeric;
| ^~~~~~
a.cc:10:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:11:1: error: 'import' does not name a type
11 | import std.string;
| ^~~~~~
a.cc:11:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:12:1: error: 'import' does not name a type
12 | import std.c.string;
| ^~~~~~
a.cc:12:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:13:1: error: 'import' does not name a type
13 | import std.regex;
| ^~~~~~
a.cc:13:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:14:1: error: 'import' does not name a type
14 | import std.typecons;
| ^~~~~~
a.cc:14:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:16:1: error: '::main' must return 'int'
16 | void main() {
| ^~~~
a.cc: In function 'int main()':
a.cc:18:8: error: structured binding declaration cannot have type 'int'
18 | int[] x;
| ^~
a.cc:18:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:18:8: error: empty structured binding declaration
a.cc:18:11: error: expected initializer before 'x'
18 | int[] x;
| ^
a.cc:19:15: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
19 | bool input() {
| ^~
a.cc:19:15: note: remove parentheses to default-initialize a variable
19 | bool input() {
| ^~
| --
a.cc:19:15: note: or replace parentheses with braces to value-initialize a variable
a.cc:19:18: error: a function-definition is not allowed here before '{' token
19 | bool input() {
| ^
a.cc:29:18: error: a function-definition is not allowed here before '{' token
29 | void solve() {
| ^
a.cc:58:12: error: 'input' was not declared in this scope; did you mean 'int'?
58 | while (input) solve;
| ^~~~~
| int
a.cc:58:19: error: 'solve' was not declared in this scope
58 | while (input) solve;
| ^~~~~
|
s808352996 | p00669 | C++ | //O(N^2 * NK)やる。
#include<iostream>
using namespace std;
int n, p;
int c[114];
int getscore() {
int ret = 0;
int i, j;
for( i = 0; i < n; i++ ) {
int score = 1;
for( j = 0; j < p; j++ ) {
if ( i + j >= n )
break;
score *= c[i+j];
}
if ( j == p )
ret = max(score, ret);
}
return ret;
}
void solve() {
int i, j;
for( i = 0; i < n; i++ )
cin >> c[i];
int Score = getscore();
int ans = -1;
for( i = 0; i < n; i++ ) {
for( j = i+1; j < n; j++ ) {
c[i] = c[i] + c[j];
c[j] = c[i] - c[j];
c[i] = c[i] - c[j];
int score = getscore();
ans = max(ans, score - Score);
c[i] = c[i] + c[j];
c[j] = c[i] - c[j];
c[i] = c[i] - c[j];
}
}
if ( ans == -1 )
cout << "NO GAME" << endl;
else
cout << ans << endl;
}
}
int main() {
while( cin >> n >> p ) {
solve();
}
return 0;
} | a.cc:50:1: error: expected declaration before '}' token
50 | }
| ^
|
s527658895 | p00669 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n,k;
while(1) {
cin >> n >> k;
if(n == 0 && k == 0) break;
int a[101] ={};
for(int i=0;i<n;i++) cin >> a[i];
int ck = -1;
int site = 0;
for(int i=0;i<=n-k;i++) {
int t = 1;
for(int j=0;j<k;j++) t*= a[j+i];
if(ck <t) ck = t, site = i;
}
int nmin=100000;
int site2=0;
for(int i=0;i<k;i++)
if(a[site+i] < nmin) nmin = a[site+i],site2 = i+site;
int amax = a[site2];
for(int i=0;i<n;i++) {
if( site <= i && i<=site+k) continue;
if(amax < a[i]) amax = a[i];
}
// cout << a[site2] << endl;
//cout << amax <<endl;
int ck2 = (ck/a[site2])*amax;
//cout << ck <<" "<<ck2<<endl;
//if(ck2-ck <= 0 && n-k<2) cout <<"NO GAME"<<endl;
else cout << ck2-ck <<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:40:5: error: 'else' without a previous 'if'
40 | else cout << ck2-ck <<endl;
| ^~~~
|
s497280097 | p00669 | C++ | #include <stdio.h>
#include <algorithm>
using namespace std;
int n, m, c[100];
inline int solve() {
int ret = 0, u = 1;
for(int i = 0; i < m - 1; i++) u *= c[i];
for(int i = m - 1; i < n; i++) u *= c[i], ret = max(ret, u), c /= c[i - m + 1];
return ret;
}
int main() {
while(scanf("%d%d", &n, &m), n) {
for(int i = 0; i < n; i++) scanf("%d", c + i);
int ret = 0, res = solve();
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
swap(c[i], c[j]);
ret = max(ret, solve());
swap(c[i], c[j]);
}
}
if(ret < res) puts("NO GAME");
else printf("%d\n", ret - res);
}
} | a.cc: In function 'int solve()':
a.cc:8:72: error: invalid operands of types 'int [100]' and 'int' to binary 'operator/'
8 | for(int i = m - 1; i < n; i++) u *= c[i], ret = max(ret, u), c /= c[i - m + 1];
| ~~^~~~~~~~~~~~~~~
a.cc:8:72: note: in evaluation of 'operator/=(int [100], int)'
|
s617882962 | p00669 | C++ | #include <iostream>
using namespace std;
template <class T> void swap(T& x,T& y){
T tmp=x;y=x;x=tmp;
}
int main(){
while(true){
int n,k;
cin>>n>>k;
if(n==0)return 0;
int c[100];
for(int i=0;i<n;i++)
cin>>c[i];
int nowc=calc(c,k,n);
int cmax;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i==j)continue;
swap(c[i],c[j]);
int cprime=calc(c,k,n);
cmax=max(cprime,cmax);
swap(c[i],c[j]);
}
}
if(cmax<nowc)
cout<<"NO GAME";
else
cout<<cmax-nowc;
}
return 0;
}
int calc(int* c,int k,int n){
int m=0;
for(int i=0;i<n-k;i++){
int v=1;
for(int j=0;j<k;j++){
v*=c[i+j];
}
m=max(v,m);
}
return m;
} | a.cc: In function 'int main()':
a.cc:14:14: error: 'calc' was not declared in this scope; did you mean 'calloc'?
14 | int nowc=calc(c,k,n);
| ^~~~
| calloc
a.cc:19:13: error: call of overloaded 'swap(int&, int&)' is ambiguous
19 | swap(c[i],c[j]);
| ~~~~^~~~~~~~~~~
a.cc:3:25: note: candidate: 'void swap(T&, T&) [with T = int]'
3 | template <class T> void swap(T& x,T& y){
| ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = int; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]'
226 | swap(_Tp& __a, _Tp& __b)
| ^~~~
a.cc:22:13: error: call of overloaded 'swap(int&, int&)' is ambiguous
22 | swap(c[i],c[j]);
| ~~~~^~~~~~~~~~~
a.cc:3:25: note: candidate: 'void swap(T&, T&) [with T = int]'
3 | template <class T> void swap(T& x,T& y){
| ^~~~
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = int; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]'
226 | swap(_Tp& __a, _Tp& __b)
| ^~~~
|
s571738851 | p00669 | C++ | #include <iostream>
using namespace std;
template <class T> void swap(T& x,T& y){
T tmp=x;y=x;x=tmp;
}
int calc(int*,int,int);
int main(){
while(true){
int n,k;
cin>>n>>k;
if(n==0)return 0;
int c[100];
for(int i=0;i<n;i++)
cin>>c[i];
int nowc=calc(c,k,n);
int cmax;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i==j)continue;
swap(c[i],c[j]);
int cprime=calc(c,k,n);
cmax=max(cprime,cmax);
swap(c[i],c[j]);
}
}
if(cmax<nowc)
cout<<"NO GAME";
else
cout<<cmax-nowc;
}
return 0;
}
int calc(int* c,int k,int n){
int m=0;
for(int i=0;i<n-k;i++){
int v=1;
for(int j=0;j<k;j++){
v*=c[i+j];
}
m=max(v,m);
}
return m;
} | a.cc: In function 'int main()':
a.cc:20:13: error: call of overloaded 'swap(int&, int&)' is ambiguous
20 | swap(c[i],c[j]);
| ~~~~^~~~~~~~~~~
a.cc:3:25: note: candidate: 'void swap(T&, T&) [with T = int]'
3 | template <class T> void swap(T& x,T& y){
| ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = int; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]'
226 | swap(_Tp& __a, _Tp& __b)
| ^~~~
a.cc:23:13: error: call of overloaded 'swap(int&, int&)' is ambiguous
23 | swap(c[i],c[j]);
| ~~~~^~~~~~~~~~~
a.cc:3:25: note: candidate: 'void swap(T&, T&) [with T = int]'
3 | template <class T> void swap(T& x,T& y){
| ^~~~
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = int; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]'
226 | swap(_Tp& __a, _Tp& __b)
| ^~~~
|
s914504681 | p00669 | C++ |
#include <iostream>
using namespace std;
int calc(int*,int,int);
int main(){
while(true){
int n,k;
cin>>n>>k;
if(n==0)return 0;
int c[100];
for(int i=0;i<n;i++)
cin>>c[i];
int nowc=calc(c,k,n);
cerr<<nowc<<endl;
int cmax=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i==j)continue;
swap(c[i],c[j]);
int cprime=calc(c,k,n);
cmax=max(cprime,cmax);
swap(c[i],c[j]);
}
}
if(cmax<nowc)
cout<<"NO GAME"<<endl;
else
cout<<cmax-nowc<<endl;
}
return 0;
}
int calc(int* c,int k,int n){
int m=0;
for(int i=0;i<n-k+1;i++){
| a.cc: In function 'int calc(int*, int, int)':
a.cc:34:28: error: expected '}' at end of input
34 | for(int i=0;i<n-k+1;i++){
| ~^
a.cc:34:28: error: expected '}' at end of input
a.cc:32:29: note: to match this '{'
32 | int calc(int* c,int k,int n){
| ^
a.cc:34:28: warning: no return statement in function returning non-void [-Wreturn-type]
34 | for(int i=0;i<n-k+1;i++){
| ^
|
s456406277 | p00669 | C++ | // This program was compiled from OCaml by js_of_ocaml 1.3
function caml_raise_with_arg (tag, arg) { throw [0, tag, arg]; }
function caml_raise_with_string (tag, msg) {
caml_raise_with_arg (tag, new MlWrappedString (msg));
}
function caml_invalid_argument (msg) {
caml_raise_with_string(caml_global_data[4], msg);
}
function caml_array_bound_error () {
caml_invalid_argument("index out of bounds");
}
function caml_str_repeat(n, s) {
if (!n) { return ""; }
if (n & 1) { return caml_str_repeat(n - 1, s) + s; }
var r = caml_str_repeat(n >> 1, s);
return r + r;
}
function MlString(param) {
if (param != null) {
this.bytes = this.fullBytes = param;
this.last = this.len = param.length;
}
}
MlString.prototype = {
string:null,
bytes:null,
fullBytes:null,
array:null,
len:null,
last:0,
toJsString:function() {
return this.string = decodeURIComponent (escape(this.getFullBytes()));
},
toBytes:function() {
if (this.string != null)
var b = unescape (encodeURIComponent (this.string));
else {
var b = "", a = this.array, l = a.length;
for (var i = 0; i < l; i ++) b += String.fromCharCode (a[i]);
}
this.bytes = this.fullBytes = b;
this.last = this.len = b.length;
return b;
},
getBytes:function() {
var b = this.bytes;
if (b == null) b = this.toBytes();
return b;
},
getFullBytes:function() {
var b = this.fullBytes;
if (b !== null) return b;
b = this.bytes;
if (b == null) b = this.toBytes ();
if (this.last < this.len) {
this.bytes = (b += caml_str_repeat(this.len - this.last, '\0'));
this.last = this.len;
}
this.fullBytes = b;
return b;
},
toArray:function() {
var b = this.bytes;
if (b == null) b = this.toBytes ();
var a = [], l = this.last;
for (var i = 0; i < l; i++) a[i] = b.charCodeAt(i);
for (l = this.len; i < l; i++) a[i] = 0;
this.string = this.bytes = this.fullBytes = null;
this.last = this.len;
this.array = a;
return a;
},
getArray:function() {
var a = this.array;
if (!a) a = this.toArray();
return a;
},
getLen:function() {
var len = this.len;
if (len !== null) return len;
this.toBytes();
return this.len;
},
toString:function() { var s = this.string; return s?s:this.toJsString(); },
valueOf:function() { var s = this.string; return s?s:this.toJsString(); },
blitToArray:function(i1, a2, i2, l) {
var a1 = this.array;
if (a1) {
if (i2 <= i1) {
for (var i = 0; i < l; i++) a2[i2 + i] = a1[i1 + i];
} else {
for (var i = l - 1; i >= 0; i--) a2[i2 + i] = a1[i1 + i];
}
} else {
var b = this.bytes;
if (b == null) b = this.toBytes();
var l1 = this.last - i1;
if (l <= l1)
for (var i = 0; i < l; i++) a2 [i2 + i] = b.charCodeAt(i1 + i);
else {
for (var i = 0; i < l1; i++) a2 [i2 + i] = b.charCodeAt(i1 + i);
for (; i < l; i++) a2 [i2 + i] = 0;
}
}
},
get:function (i) {
var a = this.array;
if (a) return a[i];
var b = this.bytes;
if (b == null) b = this.toBytes();
return (i<this.last)?b.charCodeAt(i):0;
},
safeGet:function (i) {
if (!this.len) this.toBytes();
if ((i < 0) || (i >= this.len)) caml_array_bound_error ();
return this.get(i);
},
set:function (i, c) {
var a = this.array;
if (!a) {
if (this.last == i) {
this.bytes += String.fromCharCode (c & 0xff);
this.last ++;
return 0;
}
a = this.toArray();
} else if (this.bytes != null) {
this.bytes = this.fullBytes = this.string = null;
}
a[i] = c & 0xff;
return 0;
},
safeSet:function (i, c) {
if (this.len == null) this.toBytes ();
if ((i < 0) || (i >= this.len)) caml_array_bound_error ();
this.set(i, c);
},
fill:function (ofs, len, c) {
if (ofs >= this.last && this.last && c == 0) return;
var a = this.array;
if (!a) a = this.toArray();
else if (this.bytes != null) {
this.bytes = this.fullBytes = this.string = null;
}
var l = ofs + len;
for (var i = ofs; i < l; i++) a[i] = c;
},
compare:function (s2) {
if (this.string != null && s2.string != null) {
if (this.string < s2.string) return -1;
if (this.string > s2.string) return 1;
return 0;
}
var b1 = this.getFullBytes ();
var b2 = s2.getFullBytes ();
if (b1 < b2) return -1;
if (b1 > b2) return 1;
return 0;
},
equal:function (s2) {
if (this.string != null && s2.string != null)
return this.string == s2.string;
return this.getFullBytes () == s2.getFullBytes ();
},
lessThan:function (s2) {
if (this.string != null && s2.string != null)
return this.string < s2.string;
return this.getFullBytes () < s2.getFullBytes ();
},
lessEqual:function (s2) {
if (this.string != null && s2.string != null)
return this.string <= s2.string;
return this.getFullBytes () <= s2.getFullBytes ();
}
}
function MlWrappedString (s) { this.string = s; }
MlWrappedString.prototype = new MlString();
function MlMakeString (l) { this.bytes = ""; this.len = l; }
MlMakeString.prototype = new MlString ();
function caml_array_get (array, index) {
if ((index < 0) || (index >= array.length - 1)) caml_array_bound_error();
return array[index+1];
}
function caml_array_set (array, index, newval) {
if ((index < 0) || (index >= array.length - 1)) caml_array_bound_error();
array[index+1]=newval; return 0;
}
function caml_call_gen(f, args) {
if(f.fun)
return caml_call_gen(f.fun, args);
var n = f.length;
var d = n - args.length;
if (d == 0)
return f.apply(null, args);
else if (d < 0)
return caml_call_gen(f.apply(null, args.slice(0,n)), args.slice(n));
else
return function (x){ return caml_call_gen(f, args.concat([x])); };
}
function caml_parse_format (fmt) {
fmt = fmt.toString ();
var len = fmt.length;
if (len > 31) caml_invalid_argument("format_int: format too long");
var f =
{ justify:'+', signstyle:'-', filler:' ', alternate:false,
base:0, signedconv:false, width:0, uppercase:false,
sign:1, prec:-1, conv:'f' };
for (var i = 0; i < len; i++) {
var c = fmt.charAt(i);
switch (c) {
case '-':
f.justify = '-'; break;
case '+': case ' ':
f.signstyle = c; break;
case '0':
f.filler = '0'; break;
case '#':
f.alternate = true; break;
case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
f.width = 0;
while (c=fmt.charCodeAt(i) - 48, c >= 0 && c <= 9) {
f.width = f.width * 10 + c; i++
}
i--;
break;
case '.':
f.prec = 0;
i++;
while (c=fmt.charCodeAt(i) - 48, c >= 0 && c <= 9) {
f.prec = f.prec * 10 + c; i++
}
i--;
case 'd': case 'i':
f.signedconv = true; /* fallthrough */
case 'u':
f.base = 10; break;
case 'x':
f.base = 16; break;
case 'X':
f.base = 16; f.uppercase = true; break;
case 'o':
f.base = 8; break;
case 'e': case 'f': case 'g':
f.signedconv = true; f.conv = c; break;
case 'E': case 'F': case 'G':
f.signedconv = true; f.uppercase = true;
f.conv = c.toLowerCase (); break;
}
}
return f;
}
function caml_finish_formatting(f, rawbuffer) {
if (f.uppercase) rawbuffer = rawbuffer.toUpperCase();
var len = rawbuffer.length;
if (f.signedconv && (f.sign < 0 || f.signstyle != '-')) len++;
if (f.alternate) {
if (f.base == 8) len += 1;
if (f.base == 16) len += 2;
}
var buffer = "";
if (f.justify == '+' && f.filler == ' ')
for (var i = len; i < f.width; i++) buffer += ' ';
if (f.signedconv) {
if (f.sign < 0) buffer += '-';
else if (f.signstyle != '-') buffer += f.signstyle;
}
if (f.alternate && f.base == 8) buffer += '0';
if (f.alternate && f.base == 16) buffer += "0x";
if (f.justify == '+' && f.filler == '0')
for (var i = len; i < f.width; i++) buffer += '0';
buffer += rawbuffer;
if (f.justify == '-')
for (var i = len; i < f.width; i++) buffer += ' ';
return new MlWrappedString (buffer);
}
function caml_format_int(fmt, i) {
if (fmt.toString() == "%d") return new MlWrappedString(""+i);
var f = caml_parse_format(fmt);
if (i < 0) { if (f.signedconv) { f.sign = -1; i = -i; } else i >>>= 0; }
var s = i.toString(f.base);
if (f.prec >= 0) {
f.filler = ' ';
var n = f.prec - s.length;
if (n > 0) s = caml_str_repeat (n, '0') + s;
}
return caml_finish_formatting(f, s);
}
function caml_int64_compare(x,y) {
var x3 = x[3] << 16;
var y3 = y[3] << 16;
if (x3 > y3) return 1;
if (x3 < y3) return -1;
if (x[2] > y[2]) return 1;
if (x[2] < y[2]) return -1;
if (x[1] > y[1]) return 1;
if (x[1] < y[1]) return -1;
return 0;
}
function caml_int_compare (a, b) {
if (a < b) return (-1); if (a == b) return 0; return 1;
}
function caml_compare_val (a, b, total) {
var stack = [];
for(;;) {
if (!(total && a === b)) {
if (a instanceof MlString) {
if (b instanceof MlString) {
if (a != b) {
var x = a.compare(b);
if (x != 0) return x;
}
} else
return 1;
} else if (a instanceof Array && a[0] === (a[0]|0)) {
var ta = a[0];
if (ta === 250) {
a = a[1];
continue;
} else if (b instanceof Array && b[0] === (b[0]|0)) {
var tb = b[0];
if (tb === 250) {
b = b[1];
continue;
} else if (ta != tb) {
return (ta < tb)?-1:1;
} else {
switch (ta) {
case 248: {
var x = caml_int_compare(a[2], b[2]);
if (x != 0) return x;
break;
}
case 255: {
var x = caml_int64_compare(a, b);
if (x != 0) return x;
break;
}
default:
if (a.length != b.length) return (a.length < b.length)?-1:1;
if (a.length > 1) stack.push(a, b, 1);
}
}
} else
return 1;
} else if (b instanceof MlString ||
(b instanceof Array && b[0] === (b[0]|0))) {
return -1;
} else {
if (a < b) return -1;
if (a > b) return 1;
if (total && a != b) {
if (a == a) return 1;
if (b == b) return -1;
}
}
}
if (stack.length == 0) return 0;
var i = stack.pop();
b = stack.pop();
a = stack.pop();
if (i + 1 < a.length) stack.push(a, b, i + 1);
a = a[i];
b = b[i];
}
}
function caml_compare (a, b) { return caml_compare_val (a, b, true); }
function caml_greaterequal (x, y) { return +(caml_compare(x,y,false) >= 0); }
function caml_parse_sign_and_base (s) {
var i = 0, base = 10, sign = s.get(0) == 45?(i++,-1):1;
if (s.get(i) == 48)
switch (s.get(i + 1)) {
case 120: case 88: base = 16; i += 2; break;
case 111: case 79: base = 8; i += 2; break;
case 98: case 66: base = 2; i += 2; break;
}
return [i, sign, base];
}
function caml_parse_digit(c) {
if (c >= 48 && c <= 57) return c - 48;
if (c >= 65 && c <= 90) return c - 55;
if (c >= 97 && c <= 122) return c - 87;
return -1;
}
var caml_global_data = [0];
function caml_failwith (msg) {
caml_raise_with_string(caml_global_data[3], msg);
}
function caml_int_of_string (s) {
var r = caml_parse_sign_and_base (s);
var i = r[0], sign = r[1], base = r[2];
var threshold = -1 >>> 0;
var c = s.get(i);
var d = caml_parse_digit(c);
if (d < 0 || d >= base) caml_failwith("int_of_string");
var res = d;
for (;;) {
i++;
c = s.get(i);
if (c == 95) continue;
d = caml_parse_digit(c);
if (d < 0 || d >= base) break;
res = base * res + d;
if (res > threshold) caml_failwith("int_of_string");
}
if (i != s.getLen()) caml_failwith("int_of_string");
res = sign * res;
if ((res | 0) != res) caml_failwith("int_of_string");
return res;
}
function caml_js_get_console () {
var c = this.console?this.console:{};
var m = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"trace", "group", "groupCollapsed", "groupEnd", "time", "timeEnd"];
function f () {}
for (var i = 0; i < m.length; i++) if (!c[m[i]]) c[m[i]]=f;
return c;
}
function caml_js_to_array(a) { return [0].concat(a); }
function caml_make_vect (len, init) {
var b = [0]; for (var i = 1; i <= len; i++) b[i] = init; return b;
}
function caml_ml_out_channels_list () { return 0; }
function caml_register_global (n, v) { caml_global_data[n + 1] = v; }
var caml_named_values = {};
function caml_register_named_value(nm,v) {
caml_named_values[nm] = v; return 0;
}
(function(){function F(bg,bh){return bg.length==1?bg(bh):caml_call_gen(bg,[bh]);}var a=[0,new MlString("Failure")],b=[0,new MlString("Invalid_argument")];caml_register_global(6,[0,new MlString("Not_found")]);caml_register_global(5,[0,new MlString("Division_by_zero")]);caml_register_global(3,b);caml_register_global(2,a);var l=new MlString("%d"),k=new MlString("Pervasives.do_at_exit"),j=[0,0,0],i=new MlString("split_n"),h=new MlString("NO GAME"),g=new MlString("get_input"),f=new MlString("\\s");function e(d,c){return caml_greaterequal(d,c)?d:c;}function n(m,o){if(m){var p=m[1];return [0,p,n(m[2],o)];}return o;}function u(t){var q=caml_ml_out_channels_list(0);for(;;){if(q){var r=q[2];try {}catch(s){}var q=r;continue;}return 0;}}caml_register_named_value(k,u);function J(v){var w=v.length-1-1|0,x=0;for(;;){if(0<=w){var z=[0,v[w+1],x],y=w-1|0,w=y,x=z;continue;}return x;}}function B(A){if(A){var C=A[1];return n(C,B(A[2]));}return 0;}function H(E,D){if(D){var G=D[2],I=F(E,D[1]);return [0,I,H(E,G)];}return 0;}var K=[0,0],O=RegExp,N=Array;function P(L){return L;}function Q(M){return M instanceof N?0:[0,new MlWrappedString(M.toString())];}K[1]=[0,Q,K[1]];var W=caml_js_get_console(0);function av(R,S){return F(S,R);}function U(T){return T.toString();}function aw(V){return W.log(U(V));}function _(X,Y){var Z=X<Y?1:0,$=Z?[0,X,_(X+1|0,Y)]:Z;return $;}function ax(ab,aa,ac){var ad=caml_array_get(ab,aa);caml_array_set(ab,aa,caml_array_get(ab,ac));return caml_array_set(ab,ac,ad);}function ag(af,ae){if(ae){if(0<af){var ah=ag(af-1|0,ae[2]);return [0,[0,ae[1],ah[1]],ah[2]];}return [0,0,ae];}if(0===af)return j;throw [0,b,i];}function ay(ai){return caml_int_of_string(ai);}function az(al,aj){function au(ak){if(aj.length-1<=((ak+al|0)-1|0))return -1;var am=0,an=0,ao=al-1|0;if(ao<an)var ap=am;else{var aq=an,ar=am;for(;;){var as=ar+caml_array_get(aj,ak+aq|0)|0,at=aq+1|0;if(ao!==aq){var aq=at,ar=as;continue;}var ap=as;break;}}return e(ap,au(ak+1|0));}return au(0);}var aB=require("fs").readFileSync("/dev/stdin", "utf8"),aD=F(H,function(aA){return new MlWrappedString(aA);});function aE(aC){return caml_js_to_array(aC);}var aF=av(av(av(av(aB.split(new O(U(f))),P),aE),J),aD);a:for(;;){if(aF){var aG=aF[2];if(aG){var aH=ay(aF[1]),aI=ay(aG[1]);if(0===aH&&0===aI){var aJ=0,aK=1;}else var aK=0;if(!aK){var aL=ag(aH,aG[2]),aM=aL[2],aJ=[0,[0,aH,aI,H(ay,aL[1]),aM]];}if(aJ){var aN=aJ[1],aO=aN[2],aP=aN[1],aQ=aN[3];if(aQ){var aR=0,aS=aQ,aY=aQ[2],aV=aQ[1];for(;;){if(aS){var aU=aS[2],aT=aR+1|0,aR=aT,aS=aU;continue;}var aW=caml_make_vect(aR,aV),aX=1,aZ=aY;for(;;){if(aZ){var a0=aZ[2];aW[aX+1]=aZ[1];var a1=aX+1|0,aX=a1,aZ=a0;continue;}var a2=aW;break;}break;}}else var a2=[0];var a3=az(aO,a2),a4=_(0,aP),a7=_(0,aP),ba=B(H(function(a4){return function(a6){return H(function(a5){return [0,a6,a5];},a4);};}(a4),a7)),bb=-1,bc=H(function(aO,a2){return function(a8){var a9=a8[2],a_=a8[1];ax(a2,a_,a9);var a$=az(aO,a2);ax(a2,a_,a9);return a$;};}(aO,a2),ba);for(;;){if(bc){var bd=bc[2],be=e(bb,bc[1]),bb=be,bc=bd;continue;}if(bb<a3)aw(h);else aw(caml_format_int(l,bb-a3|0));var bf=aN[4],aF=bf;continue a;}}u(0);return;}}throw [0,a,g];}}()); | a.cc:2:1: error: 'function' does not name a type; did you mean 'union'?
2 | function caml_raise_with_arg (tag, arg) { throw [0, tag, arg]; }
| ^~~~~~~~
| union
a.cc:3:1: error: 'function' does not name a type; did you mean 'union'?
3 | function caml_raise_with_string (tag, msg) {
| ^~~~~~~~
| union
a.cc:6:1: error: 'function' does not name a type; did you mean 'union'?
6 | function caml_invalid_argument (msg) {
| ^~~~~~~~
| union
a.cc:9:1: error: 'function' does not name a type; did you mean 'union'?
9 | function caml_array_bound_error () {
| ^~~~~~~~
| union
a.cc:12:1: error: 'function' does not name a type; did you mean 'union'?
12 | function caml_str_repeat(n, s) {
| ^~~~~~~~
| union
a.cc:18:1: error: 'function' does not name a type; did you mean 'union'?
18 | function MlString(param) {
| ^~~~~~~~
| union
a.cc:24:1: error: 'MlString' does not name a type
24 | MlString.prototype = {
| ^~~~~~~~
a.cc:176:1: error: 'function' does not name a type; did you mean 'union'?
176 | function MlWrappedString (s) { this.string = s; }
| ^~~~~~~~
| union
a.cc:177:1: error: 'MlWrappedString' does not name a type
177 | MlWrappedString.prototype = new MlString();
| ^~~~~~~~~~~~~~~
a.cc:178:1: error: 'function' does not name a type; did you mean 'union'?
178 | function MlMakeString (l) { this.bytes = ""; this.len = l; }
| ^~~~~~~~
| union
a.cc:179:1: error: 'MlMakeString' does not name a type
179 | MlMakeString.prototype = new MlString ();
| ^~~~~~~~~~~~
a.cc:180:1: error: 'function' does not name a type; did you mean 'union'?
180 | function caml_array_get (array, index) {
| ^~~~~~~~
| union
a.cc:184:1: error: 'function' does not name a type; did you mean 'union'?
184 | function caml_array_set (array, index, newval) {
| ^~~~~~~~
| union
a.cc:188:1: error: 'function' does not name a type; did you mean 'union'?
188 | function caml_call_gen(f, args) {
| ^~~~~~~~
| union
a.cc:200:1: error: 'function' does not name a type; did you mean 'union'?
200 | function caml_parse_format (fmt) {
| ^~~~~~~~
| union
a.cc:253:1: error: 'function' does not name a type; did you mean 'union'?
253 | function caml_finish_formatting(f, rawbuffer) {
| ^~~~~~~~
| union
a.cc:277:1: error: 'function' does not name a type; did you mean 'union'?
277 | function caml_format_int(fmt, i) {
| ^~~~~~~~
| union
a.cc:289:1: error: 'function' does not name a type; did you mean 'union'?
289 | function caml_int64_compare(x,y) {
| ^~~~~~~~
| union
a.cc:300:1: error: 'function' does not name a type; did you mean 'union'?
300 | function caml_int_compare (a, b) {
| ^~~~~~~~
| union
a.cc:303:1: error: 'function' does not name a type; did you mean 'union'?
303 | function caml_compare_val (a, b, total) {
| ^~~~~~~~
| union
a.cc:367:1: error: 'function' does not name a type; did you mean 'union'?
367 | function caml_compare (a, b) { return caml_compare_val (a, b, true); }
| ^~~~~~~~
| union
a.cc:368:1: error: 'function' does not name a type; did you mean 'union'?
368 | function caml_greaterequal (x, y) { return +(caml_compare(x,y,false) >= 0); }
| ^~~~~~~~
| union
a.cc:369:1: error: 'function' does not name a type; did you mean 'union'?
369 | function caml_parse_sign_and_base (s) {
| ^~~~~~~~
| union
a.cc:379:1: error: 'function' does not name a type; did you mean 'union'?
379 | function caml_parse_digit(c) {
| ^~~~~~~~
| union
a.cc:385:1: error: 'var' does not name a type
385 | var caml_global_data = [0];
| ^~~
a.cc:386:1: error: 'function' does not name a type; did you mean 'union'?
386 | function caml_failwith (msg) {
| ^~~~~~~~
| union
a.cc:389:1: error: 'function' does not name a type; did you mean 'union'?
389 | function caml_int_of_string (s) {
| ^~~~~~~~
| union
a.cc:411:1: error: 'function' does not name a type; did you mean 'union'?
411 | function caml_js_get_console () {
| ^~~~~~~~
| union
a.cc:419:1: error: 'function' does not name a type; did you mean 'union'?
419 | function caml_js_to_array(a) { return [0].concat(a); }
| ^~~~~~~~
| union
a.cc:420:1: error: 'function' does not name a type; did you mean 'union'?
420 | function caml_make_vect (len, init) {
| ^~~~~~~~
| union
a.cc:423:1: error: 'function' does not name a type; did you mean 'union'?
423 | function caml_ml_out_channels_list () { return 0; }
| ^~~~~~~~
| union
a.cc:424:1: error: 'function' does not name a type; did you mean 'union'?
424 | function caml_register_global (n, v) { caml_global_data[n + 1] = v; }
| ^~~~~~~~
| union
a.cc:425:1: error: 'var' does not name a type
425 | var caml_named_values = {};
| ^~~
a.cc:426:1: error: 'function' does not name a type; did you mean 'union'?
426 | function caml_register_named_value(nm,v) {
| ^~~~~~~~
| union
a.cc:429:12: error: expected ')' before '{' token
429 | (function(){function F(bg,bh){return bg.length==1?bg(bh):caml_call_gen(bg,[bh]);}var a=[0,new MlString("Failure")],b=[0,new MlString("Invalid_argument")];caml_register_global(6,[0,new MlString("Not_found")]);caml_register_global(5,[0,new MlString("Division_by_zero")]);caml_register_global(3,b);caml_register_global(2,a);var l=new MlString("%d"),k=new MlString("Pervasives.do_at_exit"),j=[0,0,0],i=new MlString("split_n"),h=new MlString("NO GAME"),g=new MlString("get_input"),f=new MlString("\\s");function e(d,c){return caml_greaterequal(d,c)?d:c;}function n(m,o){if(m){var p=m[1];return [0,p,n(m[2],o)];}return o;}function u(t){var q=caml_ml_out_channels_list(0);for(;;){if(q){var r=q[2];try {}catch(s){}var q=r;continue;}return 0;}}caml_register_named_value(k,u);function J(v){var w=v.length-1-1|0,x=0;for(;;){if(0<=w){var z=[0,v[w+1],x],y=w-1|0,w=y,x=z;continue;}return x;}}function B(A){if(A){var C=A[1];return n(C,B(A[2]));}return 0;}function H(E,D){if(D){var G=D[2],I=F(E,D[1]);return [0,I,H(E,G)];}return 0;}var K=[0,0],O=RegExp,N=Array;function P(L){return L;}function Q(M){return M instanceof N?0:[0,new MlWrappedString(M.toString())];}K[1]=[0,Q,K[1]];var W=caml_js_get_console(0);function av(R,S){return F(S,R);}function U(T){return T.toString();}function aw(V){return W.log(U(V));}function _(X,Y){var Z=X<Y?1:0,$=Z?[0,X,_(X+1|0,Y)]:Z;return $;}function ax(ab,aa,ac){var ad=caml_array_get(ab,aa);caml_array_set(ab,aa,caml_array_get(ab,ac));return caml_array_set(ab,ac,ad);}function ag(af,ae){if(ae){if(0<af){var ah=ag(af-1|0,ae[2]);return [0,[0,ae[1],ah[1]],ah[2]];}return [0,0,ae];}if(0===af)return j;throw [0,b,i];}function ay(ai){return caml_int_of_string(ai);}function az(al,aj){function au(ak){if(aj.length-1<=((ak+al|0)-1|0))return -1;var am=0,an=0,ao=al-1|0;if(ao<an)var ap=am;else{var aq=an,ar=am;for(;;){var as=ar+caml_array_get(aj,ak+aq|0)|0,at=aq+1|0;if(ao!==aq){var aq=at,ar=as;continue;}var ap=as;break;}}return e(ap,au(ak+1|0));}return au(0);}var aB=require("fs").readFileSync("/dev/stdin", "utf8"),aD=F(H,function(aA){return new MlWrappedString(aA);});function aE(aC){return caml_js_to_array(aC);}var aF=av(av(av(av(aB.split(new O(U(f))),P),aE),J),aD);a:for(;;){if(aF){var aG=aF[2];if(aG){var aH=ay(aF[1]),aI=ay(aG[1]);if(0===aH&&0===aI){var aJ=0,aK=1;}else var aK=0;if(!aK){var aL=ag(aH,aG[2]),aM=aL[2],aJ=[0,[0,aH,aI,H(ay,aL[1]),aM]];}if(aJ){var aN=aJ[1],aO=aN[2],aP=aN[1],aQ=aN[3];if(aQ){var aR=0,aS=aQ,aY=aQ[2],aV=aQ[1];for(;;){if(aS){var aU=aS[2],aT=aR+1|0,aR=aT,aS=aU;continue;}var aW=caml_make_vect(aR,aV),aX=1,aZ=aY;for(;;){if(aZ){var a0=aZ[2];aW[aX+1]=aZ[1];var a1=aX+1|0,aX=a1,aZ=a0;continue;}var a2=aW;break;}break;}}else var a2=[0];var a3=az(aO,a2),a4=_(0,aP),a7=_(0,aP),ba=B(H(function(a4){return function(a6){return H(function(a5){return [0,a6,a5];},a4);};}(a4),a7)),bb=-1,bc=H(function(aO,a2){return function(a8){var a9=a8[2],a_=a8[1];ax(a2,a_,a9);var a$=az(aO,a2);ax(a2,a_,a9);return a$;};}(aO,a2),ba);for(;;){if(bc){var bd=bc[2],be=e(bb,bc[1]),bb=be,bc=bd;continue;}if(bb<a3)aw(h);else aw(caml_format_int(l,bb-a3|0));var bf=aN[4],aF=bf;continue a;}}u(0);return;}}throw [0,a,g];}}());
| ~ ^
| )
a.cc:429:3124: error: expected unqualified-id before ')' token
429 | (function(){function F(bg,bh){return bg.length==1?bg(bh):caml_call_gen(bg,[bh]);}var a=[0,new MlString("Failure")],b=[0,new MlString("Invalid_argument")];caml_register_global(6,[0,new MlString("Not_found")]);caml_register_global(5,[0,new MlString("Division_by_zero")]);caml_register_global(3,b);caml_register_global(2,a);var l=new MlString("%d"),k=new MlString("Pervasives.do_at_exit"),j=[0,0,0],i=new MlString("split_n"),h=new MlString("NO GAME"),g=new MlString("get_input"),f=new MlString("\\s");function e(d,c){return caml_greaterequal(d,c)?d:c;}function n(m,o){if(m){var p=m[1];return [0,p,n(m[2],o)];}return o;}function u(t){var q=caml_ml_out_channels_list(0);for(;;){if(q){var r=q[2];try {}catch(s){}var q=r;continue;}return 0;}}caml_register_named_value(k,u);function J(v){var w=v.length-1-1|0,x=0;for(;;){if(0<=w){var z=[0,v[w+1],x],y=w-1|0,w=y,x=z;continue;}return x;}}function B(A){if(A){var C=A[1];return n(C,B(A[2]));}return 0;}function H(E,D){if(D){var G=D[2],I=F(E,D[1]);return [0,I,H(E,G)];}return 0;}var K=[0,0],O=RegExp,N=Array;function P(L){return L;}function Q(M){return M instanceof N?0:[0,new MlWrappedString(M.toString())];}K[1]=[0,Q,K[1]];var W=caml_js_get_console(0);function av(R,S){return F(S,R);}function U(T){return T.toString();}function aw(V){return W.log(U(V));}function _(X,Y){var Z=X<Y?1:0,$=Z?[0,X,_(X+1|0,Y)]:Z;return $;}function ax(ab,aa,ac){var ad=caml_array_get(ab,aa);caml_array_set(ab,aa,caml_array_get(ab,ac));return caml_array_set(ab,ac,ad);}function ag(af,ae){if(ae){if(0<af){var ah=ag(af-1|0,ae[2]);return [0,[0,ae[1],ah[1]],ah[2]];}return [0,0,ae];}if(0===af)return j;throw [0,b,i];}function ay(ai){return caml_int_of_string(ai);}function az(al,aj){function au(ak){if(aj.length-1<=((ak+al|0)-1|0))return -1;var am=0,an=0,ao=al-1|0;if(ao<an)var ap=am;else{var aq=an,ar=am;for(;;){var as=ar+caml_arr |
s226295993 | p00670 | Java | #include <stdio.h>
#define uint unsigned int
inline int in() {
int x = 0, c;
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
return x;
}
int main(){
int n,S;
while(n=in(),S=in(),(n||S)){
int w[102]={},a[102]={};
int ans = 0;
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
for(int i = 99 ; i >= 0 ; i--) w[i] += w[i+1];
for(int i = 0 ; i <= 100 ; i++) if(2*i>S) ans+=a[i]*(a[i]-1)/2;
for(int i = 1 ; i <= 100 ; i++) ans+=a[i]*w[i>S-i?i+1:S-i+1];
printf("%d%c",ans,10);
}
} | Main.java:1: error: illegal character: '#'
#include <stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <stdio.h>
^
Main.java:2: error: illegal character: '#'
#define uint unsigned int
^
Main.java:5: error: class, interface, enum, or record expected
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
^
Main.java:5: error: class, interface, enum, or record expected
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
^
Main.java:5: error: class, interface, enum, or record expected
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
^
Main.java:5: error: class, interface, enum, or record expected
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
^
Main.java:5: error: class, interface, enum, or record expected
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
^
Main.java:6: error: class, interface, enum, or record expected
do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
^
Main.java:7: error: class, interface, enum, or record expected
return x;
^
Main.java:8: error: class, interface, enum, or record expected
}
^
Main.java:12: error: class, interface, enum, or record expected
while(n=in(),S=in(),(n||S)){
^
Main.java:14: error: unnamed classes are a preview feature and are disabled by default.
int ans = 0;
^
(use --enable-preview to enable unnamed classes)
Main.java:15: error: class, interface, enum, or record expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: class, interface, enum, or record expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: class, interface, enum, or record expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: ']' expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: ';' expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: class, interface, enum, or record expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: class, interface, enum, or record expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:16: error: class, interface, enum, or record expected
for(int i = 99 ; i >= 0 ; i--) w[i] += w[i+1];
^
Main.java:16: error: class, interface, enum, or record expected
for(int i = 99 ; i >= 0 ; i--) w[i] += w[i+1];
^
Main.java:17: error: class, interface, enum, or record expected
for(int i = 0 ; i <= 100 ; i++) if(2*i>S) ans+=a[i]*(a[i]-1)/2;
^
Main.java:17: error: class, interface, enum, or record expected
for(int i = 0 ; i <= 100 ; i++) if(2*i>S) ans+=a[i]*(a[i]-1)/2;
^
Main.java:17: error: class, interface, enum, or record expected
for(int i = 0 ; i <= 100 ; i++) if(2*i>S) ans+=a[i]*(a[i]-1)/2;
^
Main.java:18: error: class, interface, enum, or record expected
for(int i = 1 ; i <= 100 ; i++) ans+=a[i]*w[i>S-i?i+1:S-i+1];
^
Main.java:18: error: class, interface, enum, or record expected
for(int i = 1 ; i <= 100 ; i++) ans+=a[i]*w[i>S-i?i+1:S-i+1];
^
Main.java:18: error: class, interface, enum, or record expected
for(int i = 1 ; i <= 100 ; i++) ans+=a[i]*w[i>S-i?i+1:S-i+1];
^
Main.java:19: error: class, interface, enum, or record expected
printf("%d%c",ans,10);
^
Main.java:20: error: class, interface, enum, or record expected
}
^
30 errors
|
s038205607 | p00670 | Java | #include <stdio.h>
#define uint unsigned int
int in() {
int x = 0, c;
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
return x;
}
int main(){
int n,S;
while(n=in(),S=in(),(n||S)){
int w[102]={},a[102]={};
int ans = 0;
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
for(int i = 99 ; i >= 0 ; i--) w[i] += w[i+1];
for(int i = 0 ; i <= 100 ; i++) if(2*i>S) ans+=a[i]*(a[i]-1)/2;
for(int i = 1 ; i <= 100 ; i++) ans+=a[i]*w[i>S-i?i+1:S-i+1];
printf("%d%c",ans,10);
}
} | Main.java:1: error: illegal character: '#'
#include <stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <stdio.h>
^
Main.java:2: error: illegal character: '#'
#define uint unsigned int
^
Main.java:5: error: class, interface, enum, or record expected
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
^
Main.java:5: error: class, interface, enum, or record expected
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
^
Main.java:5: error: class, interface, enum, or record expected
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
^
Main.java:5: error: class, interface, enum, or record expected
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
^
Main.java:5: error: class, interface, enum, or record expected
for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
^
Main.java:6: error: class, interface, enum, or record expected
do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
^
Main.java:7: error: class, interface, enum, or record expected
return x;
^
Main.java:8: error: class, interface, enum, or record expected
}
^
Main.java:12: error: class, interface, enum, or record expected
while(n=in(),S=in(),(n||S)){
^
Main.java:14: error: unnamed classes are a preview feature and are disabled by default.
int ans = 0;
^
(use --enable-preview to enable unnamed classes)
Main.java:15: error: class, interface, enum, or record expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: class, interface, enum, or record expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: class, interface, enum, or record expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: ']' expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: ';' expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: class, interface, enum, or record expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:15: error: class, interface, enum, or record expected
for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
^
Main.java:16: error: class, interface, enum, or record expected
for(int i = 99 ; i >= 0 ; i--) w[i] += w[i+1];
^
Main.java:16: error: class, interface, enum, or record expected
for(int i = 99 ; i >= 0 ; i--) w[i] += w[i+1];
^
Main.java:17: error: class, interface, enum, or record expected
for(int i = 0 ; i <= 100 ; i++) if(2*i>S) ans+=a[i]*(a[i]-1)/2;
^
Main.java:17: error: class, interface, enum, or record expected
for(int i = 0 ; i <= 100 ; i++) if(2*i>S) ans+=a[i]*(a[i]-1)/2;
^
Main.java:17: error: class, interface, enum, or record expected
for(int i = 0 ; i <= 100 ; i++) if(2*i>S) ans+=a[i]*(a[i]-1)/2;
^
Main.java:18: error: class, interface, enum, or record expected
for(int i = 1 ; i <= 100 ; i++) ans+=a[i]*w[i>S-i?i+1:S-i+1];
^
Main.java:18: error: class, interface, enum, or record expected
for(int i = 1 ; i <= 100 ; i++) ans+=a[i]*w[i>S-i?i+1:S-i+1];
^
Main.java:18: error: class, interface, enum, or record expected
for(int i = 1 ; i <= 100 ; i++) ans+=a[i]*w[i>S-i?i+1:S-i+1];
^
Main.java:19: error: class, interface, enum, or record expected
printf("%d%c",ans,10);
^
Main.java:20: error: class, interface, enum, or record expected
}
^
30 errors
|
s891073742 | p00670 | C++ | while True:
n,S = map(int, raw_input().split())
if n == 0 and S == 0:
break
r = []
for i in range(n):
r.append(input())
ans = 0
for i in range(n):
for j in range(i + 1, n):
if r[i] + r[j] > S:
ans += 1
print ans | a.cc:1:1: error: expected unqualified-id before 'while'
1 | while True:
| ^~~~~
|
s193727666 | p00670 | C++ | #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
int main() {
int n,s;
while(cin>>n>>s){
if(n==0 && s==0)break;
vi in;
rep(i,n){
int a;
cin>>a;
in.pb(a);
}
sort(all(in));
int sum=0;
rep(i,n-1){
for(int j=i+1;j<n;j++){
if(in[i]+in[j]>s){
sum+=n-j;
}
}
cout<<sum<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:62:2: error: expected '}' at end of input
62 | }
| ^
a.cc:33:12: note: to match this '{'
33 | int main() {
| ^
|
s951422215 | p00670 | C++ | #define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define VS vector<string>
#define all(a) (a).begin(),(a).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003
int dp[353][353]={0};
int bow[353][353]={0};
set<string> a;
int main(){
int n,S;
while(cin>>n>>S,n!=0||S!=0){
int r[120]={0};
int a;
rep(i,n){
cin>>a;
r[a]++;
}
long long ans=0;
REP(i,1,101){
REP(j,i,101){
if(i+j>S&&r[i]>0&&r[j]>0){
if(i==j)
ans+=r[i]*(r[i]-1)/2
else
ans+=r[i]*r[j];
}
}
}
cout<<ans<<endl;
}
} | a.cc: In function 'int main()':
a.cc:69:61: error: expected ';' before 'else'
69 | ans+=r[i]*(r[i]-1)/2
| ^
| ;
70 | else
| ~~~~
|
s597376405 | p00670 | C++ | #include <stdio.h>
#include <algorithm>
using namespace std;
int n, s;
int main() {
while(scanf("%d%d", &n, &s), n) {
int a[102] = {0};
for(int i = 0; i < n; i++) scanf("%d", &r), a[r]++;
int ret = 0;
for(int i = 1; i <= 100; i++) {
for(int j = max(i, s - i + 1); j <= 100; j++) {
ret += a[i] * a[j];
}
}
for(int i = s / 2 + 1; i <= 100; i++) ret -= (a[i] * a[i] + a[i]) / 2;
printf("%d\n", ret);
}
} | a.cc: In function 'int main()':
a.cc:8:57: error: 'r' was not declared in this scope
8 | for(int i = 0; i < n; i++) scanf("%d", &r), a[r]++;
| ^
|
s527226176 | p00670 | C++ | #include<bits/stdc++.h>
using namespace std;
signed main(){
int a,b;
int c[20000];
while(cin>>a>>b,a|b){
for(int d=0;d<a;d++)cin>>c[d];
sort(c,c+a);
int s=0;
for(int e=0;e<a-1;e++){
s+=c+a-lower_bound(c+e;1,c+a,b-c[e]);
}
printf("%d\n",s);
}
} | a.cc: In function 'int main()':
a.cc:12:31: error: expected ')' before ';' token
12 | s+=c+a-lower_bound(c+e;1,c+a,b-c[e]);
| ~ ^
| )
a.cc:12:44: error: expected ';' before ')' token
12 | s+=c+a-lower_bound(c+e;1,c+a,b-c[e]);
| ^
| ;
|
s112572083 | p00670 | C++ | #include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
int in(){ int a; scanf("%d",&a); return a; }
int main(){
int n,S;
while(n=in(),S=in(),(n||S)){
int w[101]={};
int ans = 0;
for(int i = 0 ; i < n ; i++) w[in()]++;
for(int i = 0 ; i <= 100 ; i++){
if(w[i]==0)continue;
for(int j = i ; j <= 100 ; j++){
if(i+j>S){
if(i==j) ans+=w[i]*(w[i]-1)/2;
else ans += w[i]*w[j];
}
}
}
printf("%d%c",ans,10);
}
}#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
int in(){ int a; scanf("%d",&a); return a; }
int main(){
int n,S;
while(n=in(),S=in(),(n||S)){
int w[101]={};
int ans = 0;
for(int i = 0 ; i < n ; i++) w[in()]++;
for(int i = 0 ; i <= 100 ; i++){
if(w[i]==0)continue;
for(int j = i ; j <= 100 ; j++){
if(i+j>S){
if(i==j) ans+=w[i]*(w[i]-1)/2;
else ans += w[i]*w[j];
}
}
}
printf("%d%c",ans,10);
}
} | a.cc:24:2: error: stray '#' in program
24 | }#include <cstdio>
| ^
a.cc:24:3: error: 'include' does not name a type
24 | }#include <cstdio>
| ^~~~~~~
a.cc:28:5: error: redefinition of 'int in()'
28 | int in(){ int a; scanf("%d",&a); return a; }
| ^~
a.cc:5:5: note: 'int in()' previously defined here
5 | int in(){ int a; scanf("%d",&a); return a; }
| ^~
a.cc:29:5: error: redefinition of 'int main()'
29 | int main(){
| ^~~~
a.cc:6:5: note: 'int main()' previously defined here
6 | int main(){
| ^~~~
|
s517536323 | p00670 | C++ | include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n, S, r[20001];
while(cin >> n >> S && (n|S)) {
for(int i = 0; i < n; ++i) cin >> r[i];
sort(r,r+n);
int res = 0;
for(int i = 0; i < n; ++i) {
int* begin = lower_bound(r,r+n,S-r[i]);
res += distance(begin,r+n) - (begin <= &r[i]);
}
cout << res/2 << endl;
}
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include <iostream>
| ^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
|
s691935253 | p00670 | C++ | #include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
while(true){
int n,S;
cin >> n >> S;
vector<int> R(n);
for(int i=0;i<n;i++) cin >> R[i];
if(n==0)return 0;
sort(R.begin(),R.end());
vector<int> Rcount(101);
for(int i=1;i<101;i++){
Rcount[i] = upper_bound(R.begin(),R.end(),i)
- lower_bound(R.begin(),R.end(),i);
}
vector<int> Rsum(101);
for(int i=1;i<=100;i++){
Rsum[i] = Rsum[i-1] + Rcount[i];
}
int retval=0;
for(int i=0;i<S-1;i++){
retval+=Rcount(i)*(Rsum(100)-Rsum(S-i-1));
}
for(int i=S;i<101;i++){
retval+=Rcount(i)*Rsum(100);
}
cout<<retval;
}
} | a.cc: In function 'int main()':
a.cc:26:21: error: no match for call to '(std::vector<int>) (int&)'
26 | retval+=Rcount(i)*(Rsum(100)-Rsum(S-i-1));
| ~~~~~~^~~
a.cc:26:30: error: no match for call to '(std::vector<int>) (int)'
26 | retval+=Rcount(i)*(Rsum(100)-Rsum(S-i-1));
| ~~~~^~~~~
a.cc:26:40: error: no match for call to '(std::vector<int>) (int)'
26 | retval+=Rcount(i)*(Rsum(100)-Rsum(S-i-1));
| ~~~~^~~~~~~
a.cc:29:21: error: no match for call to '(std::vector<int>) (int&)'
29 | retval+=Rcount(i)*Rsum(100);
| ~~~~~~^~~
a.cc:29:29: error: no match for call to '(std::vector<int>) (int)'
29 | retval+=Rcount(i)*Rsum(100);
| ~~~~^~~~~
|
s255096096 | p00670 | C++ | import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
for(;;)
{
int n=in.nextInt();
int S=in.nextInt();
if((n|S)==0)
return;
int a[]=new int[n];
int cnt=0;
ArrayList<Integer>AL=new ArrayList<Integer>();
for(int i=0;i<n;i++)
a[i]=in.nextInt();
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
{
if(i==j)
continue;
AL.add(a[i]+a[j]);
}
for(int p:AL)
if(p>S)
cnt++;
System.out.println(cnt);
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: expected unqualified-id before 'public'
2 | public class Main
| ^~~~~~
|
s033830930 | p00671 | C++ | XF#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
int C, D, W, X, E[20][40], F[20][40], dp[32][52][8];
void main2() {
memset(dp, 0, sizeof dp);
for (int i = 0; i < D; ++i) { // ツ禿コツ付
for (int j = 0; j <= W; ++j) { // ツ氾ヲツ労ツ度
for (int k = 0; k <= X; ++k) { // 2ツ嘉アツ暗按湘」ツづ個δ可イツブツづーツ行ツつ、ツ禿コ
for (int l = 0; l < C; ++l) { // ツ地ツ暗ヲ
int dW = F[l][i], dE = E[l][i];
if (dE > 0 && dW + j <= W) {
dp[i+1][j+dW][k] = max(dp[i+1][j+dW][k],
max(dp[i][j+dW][k], dp[i][j][k] + dE));
if (k < X) {
// ツ湘」ツつェツづゥ
for (int ll = l-1; ll >= 0; --ll) {
dW += F[ll][i]; dE += E[ll][i];
if (dW + j > W || E[ll][i] == 0) break;
dp[i+1][j+dW][k+1] =
max(dp[i+1][j+dW][k+1],
max(dp[i][j+dW][k+1], dp[i][j][k] + dE));
}
// ツ可コツつェツづゥ
dW = F[l][i], dE = E[l][i]; // ツ渉可甘コツ可サ
for (int ll = l+1; ll < C; ++ll) {
dW += F[ll][i]; dE += E[ll][i];
if (dW + j > W || E[ll][i] == 0) break;
dp[i+1][j+dW][k+1] =
max(dp[i+1][j+dW][k+1],
max(dp[i][j+dW][k+1], dp[i][j][k] + dE));
}
}
} else {
dp[i+1][j+dW][k] = max(dp[i+1][j+dW][k], dp[i][j+dW][k]);
}
}
}
}
}
int ans = -1;
for (int j = 0; j <= W; ++j) {
for (int k = 0; k <= X; ++k) {
// printf("%d,%d => %d\n", j,k,dp[D][j][k]);
ans = max(ans, dp[D][j][k]);
}
}
printf("%d\n", ans);
}
int main() {
while (-1 != scanf("%d%d%d%d", &C, &D, &W, &X)) {
if (!(C)) break;
rep(i,C) rep(j,D) scanf("%d", E[i]+j);
rep(i,C) rep(j,D) scanf("%d", F[i]+j);
main2();
}
return 0;
} | a.cc:1:3: error: stray '#' in program
1 | XF#include <cstdio>
| ^
a.cc:1:1: error: 'XF' does not name a type
1 | XF#include <cstdio>
| ^~
In file included from /usr/include/c++/14/cmath:45,
from a.cc:4:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/stdlib.h:32,
from /usr/include/c++/14/cstdlib:79,
from a.cc:2:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
214 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
225 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
112 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
65 | #include <debug/assertions.h>
+++ |+#include <cstddef>
66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
118 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_iterator.h:67,
from /usr/include/c++/14/bits/st |
s509767492 | p00671 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int main(){
int c,d,w,x;
while(cin>>c>>d>>w>>x,c||d||w||x){
int e[20][35],f[20][35];
for(int i=0;i<c;i++)
for(int j=0;j<d;j++)
cin>>e[i][j];
for(int i=0;i<c;i++)
for(int j=0;j<d;j++)
cin>>f[i][j];
int dp[35][55][10];
memset(dp,-1,sizeof(dp));
dp[0][0][0]=0;
for(int i=0;i<d;i++){
for(int j=0;j<=w;j++)
for(int k=0;k<=x;k++){
if(dp[i][j][k]==-1)
continue;
for(int l=0;l<c;l++){
int now=l,nx=k,nw=j,nowe=dp[i][j][k];
while(now<c){
nowe+=e[now][i],nw+=f[now][i];
if(!e[now][i]||x<nx||w<nw)
break;
dp[i+1][nw][nx]=max(dp[i+1][nw][nx],nowe);
now++;
nx=k+1;
}
}
dp[i+1][j][k]=max(dp[i][j][k],dp[i+1][j][k]);
}
}
int ans=0;
for(int i=0;i<=w;i++)
for(int j=0;j<=x;j++)
ans=max(ans,dp[d][i][j]);
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:17: error: 'memset' was not declared in this scope
15 | memset(dp,-1,sizeof(dp));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 | using namespace std;
|
s647512474 | p00671 | C++ | #include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
int main() {
cin.tie(false);
ios::sync_with_stdio(false);
for(int c, d, w, x; cin >> c >> d >> w >> x, c;) {
vector<vector<int> > e(c, vector<int>(d));
for(int i = 0; i < c; ++i)
for(int j = 0; j < d; ++j)
cin >> e[i][j];
vector<vector<int> > f(c, vector<int>(d));
for(int i = 0; i < c; ++i)
for(int j = 0; j < d; ++j)
cin >> f[i][j];
vector<vector<int> > dp(w + 1, vector<int>(x + 1, -INT_MAX));
dp[0][0] = 0;
for(int i = 0; i < d; ++i) {
vector<vector<int> > next(w + 1, vector<int>(x + 1, -INT_MAX));
for(int j = 0; j < w + 1; ++j) {
for(int k = 0; k < x + 1; ++k) {
chmax(next[j][k], dp[j][k]);
for(int l = 0; l < c; ++l) {
int tmp_w = j;
int tmp_e = dp[j][k];
for(int m = l; m < c; ++m) {
if(!e[m][i])
break;
tmp_w += f[m][i];
tmp_e += e[m][i];
if(tmp_w > w)
break;
int tmp_x = k + (l != m);
if(tmp_x > x)
break;
chmax(next[tmp_w][tmp_x], tmp_e);
}
}
}
}
dp.swap(next);
}
int ans = 0;
for(int i = 0; i < w + 1; ++i)
for(int j = 0; j < x + 1; ++j)
chmax(ans, dp[i][j]);
cout << ans << endl;
}
return EXIT_SUCCESS;
} | a.cc: In function 'int main()':
a.cc:9:16: error: no matching function for call to 'std::basic_istream<char>::tie(bool)'
9 | cin.tie(false);
| ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/basic_ios.h:299:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie() const [with _CharT = char; _Traits = std::char_traits<char>]'
299 | tie() const
| ^~~
/usr/include/c++/14/bits/basic_ios.h:299:7: note: candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_ios.h:311:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie(std::basic_ostream<_CharT, _Traits>*) [with _CharT = char; _Traits = std::char_traits<char>]'
311 | tie(basic_ostream<_CharT, _Traits>* __tiestr)
| ^~~
/usr/include/c++/14/bits/basic_ios.h:311:43: note: no known conversion for argument 1 from 'bool' to 'std::basic_ostream<char>*'
311 | tie(basic_ostream<_CharT, _Traits>* __tiestr)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
a.cc:23:68: error: 'INT_MAX' was not declared in this scope
23 | vector<vector<int> > dp(w + 1, vector<int>(x + 1, -INT_MAX));
| ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <vector>
+++ |+#include <climits>
4 | using namespace std;
|
s897009094 | p00673 | C++ | #include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<queue>
#include<functional>
#include<map>
using namespace std;
typedef pair<int,int> P;
struct edge{
int to,cap,cost,rev;
};
const int N=602;
const int INF=1<<29;
int V;
vector<vector<edge> > G;
int h[N];
int dist[N];
int prevv[N],preve[N];
void set_id(map<int,int> &m){
int x=0;
for(auto &e:m){
e.second=x++;
}
}
void add_edge(int from,int to,int cost=0,int cap=INF){
if(from<0||G.size()<=fromK)for(;;);
G[from].push_back({to,cap,cost,(int)G[to].size()});
G[to].push_back({from,0,-cost,(int)G[from].size()-1});
}
// pair<int,int> min_cost_flow(int s,int t,int g){
// int res=0;
// fill(h,h+V,0);
// int f=0;
// while(f<g){
// priority_queue<P,vector<P>,greater<P> > que;
// fill(dist,dist+V,INF);
// dist[s]=0;
// que.push({0,s});
// while(!que.empty()){
// P p=que.top();
// que.pop();
// int v=p.second;
// if(dist[v]<p.first)continue;
// for(int i=0;i<G[v].size();i++){
// edge &e=G[v][i];
// if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
// dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
// prevv[e.to]=v;
// preve[e.to]=i;
// que.push({dist[e.to],e.to});
// }
// }
// }
// if(dist[t]>=INF){
// return {f,res};
// }
// for(int v=0;v<V;v++){
// h[v]+=dist[v];
// }
// f++;
// res+=h[t];
// for(int v=t;v!=s;v=prevv[v]){
// edge &e=G[prevv[v]][preve[v]];
// e.cap--;
// G[v][e.rev].cap++;
// }
// }
// return {f,res};
// }
pair<int,int> min_cost_flow(int s,int t,int f){
int res=0;
const int INF=1<<29;
fill(h,h+V,INF);
h[s]=0;
for(;;){
bool u=false;
for(int i=0;i<V;i++){
for(auto f:G[i]){
if(f.cap){
int nd=h[i]+f.cost;
if(nd<h[f.to]){
h[f.to]=nd;
u=true;
}
}
}
}
if(!u)break;
}
int g=0;
while(g<f){
priority_queue<P,vector<P>,greater<P> > que;
fill(dist,dist+V,INF);
dist[s]=0;
que.push({0,s});
while(!que.empty()){
P p=que.top();
que.pop();
int v=p.second;
if(dist[v]<p.first)continue;
for(int i=0;i<G[v].size();i++){
edge &e=G[v][i];
if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
prevv[e.to]=v;
preve[e.to]=i;
que.push({dist[e.to],e.to});
}
}
}
if(dist[t]==INF)return {g,res};
for(int v=0;v<V;v++){
h[v]+=dist[v];
}
int d=INF;
for(int v=t;v!=s;v=prevv[v]){
d=min(d,G[prevv[v]][preve[v]].cap);
}
g+=d;
res+=d*h[t];
for(int v=t;v!=s;v=prevv[v]){
edge &e=G[prevv[v]][preve[v]];
e.cap-=d;
G[v][e.rev].cap+=d;
}
}
return {g,res};
}
int main(){
for(int n;cin>>n,n;){
map<int,int> in[100],out[100];
int o[101]={2};
int m[100];
int x[100][20],y[100][20],c[100][20];
G=vector<vector<edge> >(N);
for(int i=0;i<n-1;i++){
cin>>m[i];
for(int j=0;j<m[i];j++){
cin>>x[i][j]>>y[i][j]>>c[i][j];
in[i][x[i][j]];
out[i][y[i][j]];
}
set_id(in[i]);
set_id(out[i]);
for(int j=0;j<m[i];j++){
add_edge(o[i]+in[i][x[i][j]],o[i]+in[i].size()+out[i][y[i][j]],c[i][j]);
}
if(i){
for(auto e:out[i-1]){
for(auto f:in[i]){
if(e.first<=f.first){
add_edge(o[i-1]+in[i-1].size()+out[i-1].size()+e.second,o[i]+f.second);
}
}
}
}
for(auto e:out[i]){
add_edge(o[i]+in[i].size()+e.second,o[i]+in[i].size()+out[i].size()+e.second,0,1);
}
o[i+1]=o[i]+in[i].size()+2*out[i].size();
}
for(auto e:in[0]){
add_edge(0,2+e.second);
}
for(auto f:out[n-2]){
add_edge(o[n-2]+in[n-2].size()+out[n-2].size()+f.second,1);
}
V=o[n-1];
int g;
cin>>g;
auto r=min_cost_flow(0,1,g);
cout<<r.first<<' '<<r.second<<endl;
}
}
| a.cc: In function 'void add_edge(int, int, int, int)':
a.cc:33:24: error: 'fromK' was not declared in this scope; did you mean 'from'?
33 | if(from<0||G.size()<=fromK)for(;;);
| ^~~~~
| from
|
s090264742 | p00673 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
#define V 10000
#define INF 100000000
typedef pair<int,int> P;
struct edge {int to,cap,cost,rev;};
int n,m[110],g,a,b;
int x[110][30],y[110][30],c[110][30];
vector<int> time[30];
int v;
vector<edge> G[V];
int h[V];
int dist[V];
int prevv[V], preve[V];
void add_edge(int from,int to,int cap,int cost){
G[from].push_back((edge){to,cap,cost,G[to].size()});
G[to].push_back((edge){from,0,-cost,G[from].size() - 1});
}
int min_cost_flow(int s,int t,int f){
int res = 0;
fill(h,h+V,0);
while(f>0){
priority_queue<P ,vector<P>, greater<P> > q;
fill(dist,dist+V,INF);
dist[s] = 0;
q.push(P(0,s));
while(!q.empty()){
P p = q.top(); q.pop();
int v = p.second;
if(dist[v] < p.first)continue;
for(int i=0;i<G[v].size();i++){
edge &e = G[v][i];
if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
prevv[e.to] = v;
preve[e.to] = i;
q.push(P(dist[e.to],e.to));
}
}
}
if(dist[t] == INF)return -1;
for(int v=0;v<V;v++)h[v] += dist[v];
int d = f;
for(int v=t;v!=s;v = prevv[v]){
d = min(d,G[prevv[v]][preve[v]].cap);
}
f -= d;
res += d*h[t];
for(int v=t;v!=s;v=prevv[v]){
edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
}
int main(){
while(scanf("%d",&n) != EOF, n){
m[0] = 1; time[0].clear(); time[0].push_back(0);
x[0][0] = 0; y[0][0] = 0; c[0][0] = 0;
for(int i=1;i<n;i++){
scanf("%d",&m[i]);
for(int j=0;j<m[i];j++){
scanf("%d %d %d",&x[i][j],&y[i][j],&c[i][j]);
time[i].push_back(y[i][j]);
}
sort(time[i].begin(),time[i].end());
time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
}
m[n] = 1; time[n].clear(); time[n].push_back(1000000);
x[n][0] = 1000000; y[n][0] = 1000000; c[n][0] = 0;
scanf("%d",&g);
for(int ans = g;ans>=0;ans--){
for(int i=0;i<=V;i++)G[i].clear();
for(int i=0;i<n;i++){
for(int j=0;j<time[i].size();j++){
for(int k=0;k<m[i+1];k++){
if(time[i][j]<=x[i+1][k]){
for(int l=0;l<time[i+1].size();l++){
if(y[i+1][k] == time[i+1][l]){
a = l;
break;
}
}
add_edge(i*50 + j*2 + 1, (i+1)*50 + a*2, g, c[i+1][k]);
}
}
}
for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
}
/*
if(ans == g){
for(int i=0;i<V;i++){
for(int j=0;j<G[i].size();j++){
edge e = G[i][j];
cout << i << " " << e.to << " " << e.cap << " " << e.cost << endl;
}
}
}
*/
int res = min_cost_flow(1,n*50,ans);
if(0<=res){
cout << ans << " " << res << endl;
break;
}
}
}
} | a.cc:17:20: error: 'std::vector<int> time [30]' redeclared as different kind of entity
17 | vector<int> time[30];
| ^
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
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/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'void add_edge(int, int, int, int)':
a.cc:26:50: warning: narrowing conversion of 'G[to].std::vector<edge>::size()' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
26 | G[from].push_back((edge){to,cap,cost,G[to].size()});
| ~~~~~~~~~~^~
a.cc:27:54: warning: narrowing conversion of '(G[from].std::vector<edge>::size() - 1)' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
27 | G[to].push_back((edge){from,0,-cost,G[from].size() - 1});
| ~~~~~~~~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:74:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
74 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^
a.cc:74:23: error: request for member 'clear' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
74 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^~~~~
a.cc:74:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
74 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^
a.cc:74:40: error: request for member 'push_back' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
74 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^~~~~~~~~
a.cc:80:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
80 | time[i].push_back(y[i][j]);
| ^
a.cc:80:17: error: request for member 'push_back' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
80 | time[i].push_back(y[i][j]);
| ^~~~~~~~~
a.cc:82:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
82 | sort(time[i].begin(),time[i].end());
| ^
a.cc:82:20: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
82 | sort(time[i].begin(),time[i].end());
| ^~~~~
a.cc:82:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
82 | sort(time[i].begin(),time[i].end());
| ^
a.cc:82:36: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
82 | sort(time[i].begin(),time[i].end());
| ^~~
a.cc:83:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:83:15: error: request for member 'erase' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~~~
a.cc:83:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:83:36: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~~~
a.cc:83:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:83:52: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~
a.cc:83:65: warning: pointer to a function used in arithmetic [-Wpointer-arith]
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:83:67: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~
a.cc:85:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
85 | m[n] = 1; time[n].clear(); time[n].push_back(1000000);
| ^
a.cc:85:23: error: request for member 'clear' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
85 | m[n] = 1; time[n].clear(); time[n].push_back(1000000);
| ^~~~~
a.cc:85:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
85 | m[n] = 1; time[n].clear(); time[n].push_back(1000000);
| ^
a.cc:85:40: error: request for member 'push_back' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
85 | m[n] = 1; time[n].clear(); time[n].push_back(1000000);
| ^~~~~~~~~
a.cc:92:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
92 | for(int j=0;j<time[i].size();j++){
| ^
a.cc:92:31: error: request for member 'size' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
92 | for(int j=0;j<time[i].size();j++){
| ^~~~
a.cc:94:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
94 | if(time[i][j]<=x[i+1][k]){
| ^
a.cc:94:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
94 | if(time[i][j]<=x[i+1][k]){
| ^
a.cc:94:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
94 | if(time[i][j]<=x[i+1][k]){
| ~~~~~~~~~~^~~~~~~~~~~
a.cc:95:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
95 | for(int l=0;l<time[i+1].size();l++){
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:95:39: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
95 | for(int l=0;l<time[i+1].size();l++){
| ^~~~
a.cc:96:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
96 | if(y[i+1][k] == time[i+1][l]){
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:96:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
96 | if(y[i+1][k] == time[i+1][l]){
| ^
a.cc:96:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
96 | if(y[i+1][k] == time[i+1][l]){
| ~~~~~~~~~~^~~~~~~~~~~~~~~
a.cc:105:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
105 | for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:105:33: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
105 | for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
| ^~~~
|
s479097086 | p00673 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
#define V 10000
#define INF 100000000
typedef pair<int,int> P;
struct edge {int to,cap,cost,rev;};
int n,m[110],g,a,b;
int x[110][30],y[110][30],c[110][30];
vector<int> time[30];
int v;
vector<edge> G[V];
int h[V];
int dist[V];
int prevv[V], preve[V];
void add_edge(int from,int to,int cap,int cost){
G[from].push_back((edge){to,cap,cost,G[to].size()});
G[to].push_back((edge){from,0,-cost,G[from].size() - 1});
}
int min_cost_flow(int s,int t,int f){
int res = 0;
fill(h,h+V,0);
while(f>0){
priority_queue<P ,vector<P>, greater<P> > q;
fill(dist,dist+V,INF);
dist[s] = 0;
q.push(P(0,s));
while(!q.empty()){
P p = q.top(); q.pop();
int v = p.second;
if(dist[v] < p.first)continue;
for(int i=0;i<G[v].size();i++){
edge &e = G[v][i];
if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
prevv[e.to] = v;
preve[e.to] = i;
q.push(P(dist[e.to],e.to));
}
}
}
if(dist[t] == INF)return -1;
for(int v=0;v<V;v++)h[v] += dist[v];
int d = f;
for(int v=t;v!=s;v = prevv[v]){
d = min(d,G[prevv[v]][preve[v]].cap);
}
f -= d;
res += d*h[t];
for(int v=t;v!=s;v=prevv[v]){
edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
}
int main(){
while(scanf("%d",&n) != EOF, n){
m[0] = 1; time[0].clear(); time[0].push_back(0);
x[0][0] = 0; y[0][0] = 0; c[0][0] = 0;
for(int i=1;i<n;i++){
scanf("%d",&m[i]);
for(int j=0;j<m[i];j++){
scanf("%d %d %d",&x[i][j],&y[i][j],&c[i][j]);
time[i].push_back(y[i][j]);
}
sort(time[i].begin(),time[i].end());
time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
}
m[n] = 1; time[n].clear(); time[n].push_back(1000000);
x[n][0] = 1000000; y[n][0] = 1000000; c[n][0] = 0;
scanf("%d",&g);
for(int ans = g;ans>=0;ans--){
for(int i=0;i<=V;i++)G[i].clear();
for(int i=0;i<n;i++){
for(int j=0;j<time[i].size();j++){
for(int k=0;k<m[i+1];k++){
if(time[i][j]<=x[i+1][k]){
for(int l=0;l<time[i+1].size();l++){
if(y[i+1][k] == time[i+1][l]){
a = l;
break;
}
}
add_edge(i*50 + j*2 + 1, (i+1)*50 + a*2, g, c[i+1][k]);
}
}
}
for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
}
/*
if(ans == g){
for(int i=0;i<V;i++){
for(int j=0;j<G[i].size();j++){
edge e = G[i][j];
cout << i << " " << e.to << " " << e.cap << " " << e.cost << endl;
}
}
}
*/
int res = min_cost_flow(1,n*50,ans);
if(0<=res){
cout << ans << " " << res << endl;
break;
}
}
}
} | a.cc:17:20: error: 'std::vector<int> time [30]' redeclared as different kind of entity
17 | vector<int> time[30];
| ^
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
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/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'void add_edge(int, int, int, int)':
a.cc:26:50: warning: narrowing conversion of 'G[to].std::vector<edge>::size()' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
26 | G[from].push_back((edge){to,cap,cost,G[to].size()});
| ~~~~~~~~~~^~
a.cc:27:54: warning: narrowing conversion of '(G[from].std::vector<edge>::size() - 1)' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
27 | G[to].push_back((edge){from,0,-cost,G[from].size() - 1});
| ~~~~~~~~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:74:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
74 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^
a.cc:74:23: error: request for member 'clear' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
74 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^~~~~
a.cc:74:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
74 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^
a.cc:74:40: error: request for member 'push_back' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
74 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^~~~~~~~~
a.cc:80:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
80 | time[i].push_back(y[i][j]);
| ^
a.cc:80:17: error: request for member 'push_back' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
80 | time[i].push_back(y[i][j]);
| ^~~~~~~~~
a.cc:82:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
82 | sort(time[i].begin(),time[i].end());
| ^
a.cc:82:20: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
82 | sort(time[i].begin(),time[i].end());
| ^~~~~
a.cc:82:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
82 | sort(time[i].begin(),time[i].end());
| ^
a.cc:82:36: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
82 | sort(time[i].begin(),time[i].end());
| ^~~
a.cc:83:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:83:15: error: request for member 'erase' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~~~
a.cc:83:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:83:36: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~~~
a.cc:83:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:83:52: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~
a.cc:83:65: warning: pointer to a function used in arithmetic [-Wpointer-arith]
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:83:67: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
83 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~
a.cc:85:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
85 | m[n] = 1; time[n].clear(); time[n].push_back(1000000);
| ^
a.cc:85:23: error: request for member 'clear' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
85 | m[n] = 1; time[n].clear(); time[n].push_back(1000000);
| ^~~~~
a.cc:85:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
85 | m[n] = 1; time[n].clear(); time[n].push_back(1000000);
| ^
a.cc:85:40: error: request for member 'push_back' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
85 | m[n] = 1; time[n].clear(); time[n].push_back(1000000);
| ^~~~~~~~~
a.cc:92:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
92 | for(int j=0;j<time[i].size();j++){
| ^
a.cc:92:31: error: request for member 'size' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
92 | for(int j=0;j<time[i].size();j++){
| ^~~~
a.cc:94:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
94 | if(time[i][j]<=x[i+1][k]){
| ^
a.cc:94:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
94 | if(time[i][j]<=x[i+1][k]){
| ^
a.cc:94:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
94 | if(time[i][j]<=x[i+1][k]){
| ~~~~~~~~~~^~~~~~~~~~~
a.cc:95:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
95 | for(int l=0;l<time[i+1].size();l++){
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:95:39: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
95 | for(int l=0;l<time[i+1].size();l++){
| ^~~~
a.cc:96:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
96 | if(y[i+1][k] == time[i+1][l]){
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:96:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
96 | if(y[i+1][k] == time[i+1][l]){
| ^
a.cc:96:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
96 | if(y[i+1][k] == time[i+1][l]){
| ~~~~~~~~~~^~~~~~~~~~~~~~~
a.cc:105:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
105 | for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:105:33: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
105 | for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
| ^~~~
|
s723756346 | p00673 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
#define V 6000
#define INF 100000000
typedef pair<int,int> P;
struct edge {
int to,cap,cost,rev;
edge(int a,int b,int c,int d){to = a;cap = b,cost = c;rev = d;}
};
int n,m[110],g,a,b;
int x[110][30],y[110][30],c[110][30];
vector<int> time[30];
int v;
vector<edge> G[V];
//int h[V];
int dist[V];
int prevv[V], preve[V];
void add_edge(int from,int to,int cap,int cost){
G[from].push_back(edge(to,cap,cost,G[to].size()));
G[to].push_back(edge(from,0,-cost,G[from].size() - 1));
}
/*
int min_cost_flow(int s,int t,int f){
int res = 0;
fill(h,h+V,0);
while(f>0){
priority_queue<P ,vector<P>, greater<P> > q;
fill(dist,dist+V,INF);
dist[s] = 0;
q.push(P(0,s));
while(!q.empty()){
P p = q.top(); q.pop();
int v = p.second;
if(dist[v] < p.first)continue;
for(int i=0;i<G[v].size();i++){
edge &e = G[v][i];
if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
prevv[e.to] = v;
preve[e.to] = i;
q.push(P(dist[e.to],e.to));
}
}
}
if(dist[t] == INF)return -1;
for(int v=0;v<V;v++)h[v] += dist[v];
int d = f;
for(int v=t;v!=s;v = prevv[v]){
d = min(d,G[prevv[v]][preve[v]].cap);
}
f -= d;
res += d*h[t];
for(int v=t;v!=s;v=prevv[v]){
edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
}
*/
int min_cost_flow(int s,int t,int f){
int res = 0;
while(f>0){
fill(dist,dist+V,INF);
dist[s] = 0;
bool up = true;
while(up){
up = false;
for(int v=0;v<V;v++){
if(dist[v] == INF)continue;
for(int i=0;i<G[v].size();i++){
edge &e = G[v][i];
if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
dist[e.to] = dist[v] + e.cost;
prevv[e.to] = v;
preve[e.to] = i;
up = true;
}
}
}
}
if(dist[t] == INF)return -1;
int d = f;
for(int v=t;v!=s;v = prevv[v]){
d = min(d,G[prevv[v]][preve[v]].cap);
}
f -= d;
res += d*dist[t];
for(int v=t;v!=s;v=prevv[v]){
edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
}
int main(){
while(scanf("%d",&n) != EOF, n){
m[0] = 1; time[0].clear(); time[0].push_back(0);
x[0][0] = 0; y[0][0] = 0; c[0][0] = 0;
for(int i=1;i<n;i++){
scanf("%d",&m[i]);
for(int j=0;j<m[i];j++){
scanf("%d %d %d",&x[i][j],&y[i][j],&c[i][j]);
time[i].push_back(y[i][j]);
}
sort(time[i].begin(),time[i].end());
time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
}
m[n] = 1; time[n].clear(); time[n].push_back(INF);
x[n][0] = INF; y[n][0] = INF; c[n][0] = 0;
scanf("%d",&g);
for(int ans = g;ans>=0;ans--){
for(int i=0;i<=V;i++)G[i].clear();
for(int i=0;i<n;i++){
for(int j=0;j<time[i].size();j++){
for(int k=0;k<m[i+1];k++){
if(time[i][j]<=x[i+1][k]){
for(int l=0;l<time[i+1].size();l++){
if(y[i+1][k] == time[i+1][l]){
a = l;
break;
}
}
add_edge(i*50 + j*2 + 1, (i+1)*50 + a*2, g, c[i+1][k]);
}
}
}
for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
}
/*
if(ans == g){
for(int i=0;i<V;i++){
for(int j=0;j<G[i].size();j++){
edge e = G[i][j];
cout << i << " " << e.to << " " << e.cap << " " << e.cost << endl;
}
}
}
*/
int res = min_cost_flow(1,n*50,ans);
if(0<=res){
cout << ans << " " << res << endl;
break;
}
}
}
} | a.cc:20:20: error: 'std::vector<int> time [30]' redeclared as different kind of entity
20 | vector<int> time[30];
| ^
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
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/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'int main()':
a.cc:118:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
118 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^
a.cc:118:23: error: request for member 'clear' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
118 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^~~~~
a.cc:118:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
118 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^
a.cc:118:40: error: request for member 'push_back' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
118 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^~~~~~~~~
a.cc:124:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
124 | time[i].push_back(y[i][j]);
| ^
a.cc:124:17: error: request for member 'push_back' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
124 | time[i].push_back(y[i][j]);
| ^~~~~~~~~
a.cc:126:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
126 | sort(time[i].begin(),time[i].end());
| ^
a.cc:126:20: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
126 | sort(time[i].begin(),time[i].end());
| ^~~~~
a.cc:126:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
126 | sort(time[i].begin(),time[i].end());
| ^
a.cc:126:36: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
126 | sort(time[i].begin(),time[i].end());
| ^~~
a.cc:127:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:127:15: error: request for member 'erase' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~~~
a.cc:127:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:127:36: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~~~
a.cc:127:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:127:52: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~
a.cc:127:65: warning: pointer to a function used in arithmetic [-Wpointer-arith]
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:127:67: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~
a.cc:129:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
129 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^
a.cc:129:23: error: request for member 'clear' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
129 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^~~~~
a.cc:129:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
129 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^
a.cc:129:40: error: request for member 'push_back' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
129 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^~~~~~~~~
a.cc:136:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
136 | for(int j=0;j<time[i].size();j++){
| ^
a.cc:136:31: error: request for member 'size' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
136 | for(int j=0;j<time[i].size();j++){
| ^~~~
a.cc:138:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
138 | if(time[i][j]<=x[i+1][k]){
| ^
a.cc:138:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
138 | if(time[i][j]<=x[i+1][k]){
| ^
a.cc:138:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
138 | if(time[i][j]<=x[i+1][k]){
| ~~~~~~~~~~^~~~~~~~~~~
a.cc:139:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
139 | for(int l=0;l<time[i+1].size();l++){
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:139:39: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
139 | for(int l=0;l<time[i+1].size();l++){
| ^~~~
a.cc:140:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
140 | if(y[i+1][k] == time[i+1][l]){
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:140:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
140 | if(y[i+1][k] == time[i+1][l]){
| ^
a.cc:140:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
140 | if(y[i+1][k] == time[i+1][l]){
| ~~~~~~~~~~^~~~~~~~~~~~~~~
a.cc:149:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
149 | for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:149:33: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
149 | for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
| ^~~~
|
s223055854 | p00673 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
#define V 6000
#define INF 100000000
typedef pair<int,int> P;
struct edge {
int to,cap,cost,rev;
edge(int a,int b,int c,int d){to = a;cap = b,cost = c;rev = d;}
};
int n,m[110],g,a,b;
int x[110][30],y[110][30],c[110][30];
vector<int> time[30];
int v;
vector<edge> G[V];
//int h[V];
int dist[V];
int prevv[V], preve[V];
void add_edge(int from,int to,int cap,int cost){
G[from].push_back(edge(to,cap,cost,G[to].size()));
G[to].push_back(edge(from,0,-cost,G[from].size() - 1));
}
/*
int min_cost_flow(int s,int t,int f){
int res = 0;
fill(h,h+V,0);
while(f>0){
priority_queue<P ,vector<P>, greater<P> > q;
fill(dist,dist+V,INF);
dist[s] = 0;
q.push(P(0,s));
while(!q.empty()){
P p = q.top(); q.pop();
int v = p.second;
if(dist[v] < p.first)continue;
for(int i=0;i<G[v].size();i++){
edge &e = G[v][i];
if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
prevv[e.to] = v;
preve[e.to] = i;
q.push(P(dist[e.to],e.to));
}
}
}
if(dist[t] == INF)return -1;
for(int v=0;v<V;v++)h[v] += dist[v];
int d = f;
for(int v=t;v!=s;v = prevv[v]){
d = min(d,G[prevv[v]][preve[v]].cap);
}
f -= d;
res += d*h[t];
for(int v=t;v!=s;v=prevv[v]){
edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
}
*/
int min_cost_flow(int s,int t,int f){
int res = 0;
while(f>0){
fill(dist,dist+V,INF);
dist[s] = 0;
bool up = true;
while(up){
up = false;
for(int v=0;v<V;v++){
if(dist[v] == INF)continue;
for(int i=0;i<G[v].size();i++){
edge &e = G[v][i];
if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
dist[e.to] = dist[v] + e.cost;
prevv[e.to] = v;
preve[e.to] = i;
up = true;
}
}
}
}
if(dist[t] == INF)return -1;
int d = f;
for(int v=t;v!=s;v = prevv[v]){
d = min(d,G[prevv[v]][preve[v]].cap);
}
f -= d;
res += d*dist[t];
for(int v=t;v!=s;v=prevv[v]){
edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
}
int main(){
while(scanf("%d",&n) != EOF, n){
m[0] = 1; time[0].clear(); time[0].push_back(0);
x[0][0] = 0; y[0][0] = 0; c[0][0] = 0;
for(int i=1;i<n;i++){
scanf("%d",&m[i]);
for(int j=0;j<m[i];j++){
scanf("%d %d %d",&x[i][j],&y[i][j],&c[i][j]);
time[i].push_back(y[i][j]);
}
sort(time[i].begin(),time[i].end());
time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
}
m[n] = 1; time[n].clear(); time[n].push_back(INF);
x[n][0] = INF; y[n][0] = INF; c[n][0] = 0;
scanf("%d",&g);
for(int ans = g;ans>=0;ans--){
for(int i=0;i<=V;i++)G[i].clear();
for(int i=0;i<n;i++){
for(int j=0;j<time[i].size();j++){
for(int k=0;k<m[i+1];k++){
if(time[i][j]<=x[i+1][k]){
for(int l=0;l<time[i+1].size();l++){
if(y[i+1][k] == time[i+1][l]){
a = l;
break;
}
}
add_edge(i*50 + j*2 + 1, (i+1)*50 + a*2, g, c[i+1][k]);
}
}
}
for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
}
/*
if(ans == g){
for(int i=0;i<V;i++){
for(int j=0;j<G[i].size();j++){
edge e = G[i][j];
cout << i << " " << e.to << " " << e.cap << " " << e.cost << endl;
}
}
}
*/
int res = min_cost_flow(1,n*50,ans);
if(0<=res){
cout << ans << " " << res << endl;
break;
}
}
}
} | a.cc:20:20: error: 'std::vector<int> time [30]' redeclared as different kind of entity
20 | vector<int> time[30];
| ^
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
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/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'int main()':
a.cc:118:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
118 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^
a.cc:118:23: error: request for member 'clear' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
118 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^~~~~
a.cc:118:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
118 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^
a.cc:118:40: error: request for member 'push_back' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
118 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^~~~~~~~~
a.cc:124:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
124 | time[i].push_back(y[i][j]);
| ^
a.cc:124:17: error: request for member 'push_back' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
124 | time[i].push_back(y[i][j]);
| ^~~~~~~~~
a.cc:126:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
126 | sort(time[i].begin(),time[i].end());
| ^
a.cc:126:20: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
126 | sort(time[i].begin(),time[i].end());
| ^~~~~
a.cc:126:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
126 | sort(time[i].begin(),time[i].end());
| ^
a.cc:126:36: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
126 | sort(time[i].begin(),time[i].end());
| ^~~
a.cc:127:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:127:15: error: request for member 'erase' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~~~
a.cc:127:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:127:36: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~~~
a.cc:127:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:127:52: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~
a.cc:127:65: warning: pointer to a function used in arithmetic [-Wpointer-arith]
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:127:67: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
127 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~
a.cc:129:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
129 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^
a.cc:129:23: error: request for member 'clear' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
129 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^~~~~
a.cc:129:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
129 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^
a.cc:129:40: error: request for member 'push_back' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
129 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^~~~~~~~~
a.cc:136:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
136 | for(int j=0;j<time[i].size();j++){
| ^
a.cc:136:31: error: request for member 'size' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
136 | for(int j=0;j<time[i].size();j++){
| ^~~~
a.cc:138:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
138 | if(time[i][j]<=x[i+1][k]){
| ^
a.cc:138:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
138 | if(time[i][j]<=x[i+1][k]){
| ^
a.cc:138:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
138 | if(time[i][j]<=x[i+1][k]){
| ~~~~~~~~~~^~~~~~~~~~~
a.cc:139:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
139 | for(int l=0;l<time[i+1].size();l++){
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:139:39: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
139 | for(int l=0;l<time[i+1].size();l++){
| ^~~~
a.cc:140:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
140 | if(y[i+1][k] == time[i+1][l]){
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:140:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
140 | if(y[i+1][k] == time[i+1][l]){
| ^
a.cc:140:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
140 | if(y[i+1][k] == time[i+1][l]){
| ~~~~~~~~~~^~~~~~~~~~~~~~~
a.cc:149:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
149 | for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:149:33: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
149 | for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
| ^~~~
|
s559029653 | p00673 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
#define V 6000
#define INF 100000000
typedef pair<int,int> P;
struct edge {
int to,cap,cost,rev;
edge(int a,int b,int c,int d){to = a;cap = b,cost = c;rev = d;}
};
int n,m[110],g,a,b;
int x[110][30],y[110][30],c[110][30];
vector<int> time[30];
vector<edge> G[V];
//int h[V];
int dist[V];
int prevv[V], preve[V];
void add_edge(int from,int to,int cap,int cost){
G[from].push_back(edge(to,cap,cost,G[to].size()));
G[to].push_back(edge(from,0,-cost,G[from].size() - 1));
}
/*
int min_cost_flow(int s,int t,int f){
int res = 0;
fill(h,h+V,0);
while(f>0){
priority_queue<P ,vector<P>, greater<P> > q;
fill(dist,dist+V,INF);
dist[s] = 0;
q.push(P(0,s));
while(!q.empty()){
P p = q.top(); q.pop();
int v = p.second;
if(dist[v] < p.first)continue;
for(int i=0;i<G[v].size();i++){
edge &e = G[v][i];
if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
prevv[e.to] = v;
preve[e.to] = i;
q.push(P(dist[e.to],e.to));
}
}
}
if(dist[t] == INF)return -1;
for(int v=0;v<V;v++)h[v] += dist[v];
int d = f;
for(int v=t;v!=s;v = prevv[v]){
d = min(d,G[prevv[v]][preve[v]].cap);
}
f -= d;
res += d*h[t];
for(int v=t;v!=s;v=prevv[v]){
edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
}
*/
int min_cost_flow(int s,int t,int f){
int res = 0;
while(f>0){
fill(dist,dist+V,INF);
dist[s] = 0;
bool up = true;
while(up){
up = false;
for(int v=0;v<V;v++){
if(dist[v] == INF)continue;
for(int i=0;i<G[v].size();i++){
edge &e = G[v][i];
if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
dist[e.to] = dist[v] + e.cost;
prevv[e.to] = v;
preve[e.to] = i;
up = true;
}
}
}
}
if(dist[t] == INF)return -1;
int d = f;
for(int v=t;v!=s;v = prevv[v]){
d = min(d,G[prevv[v]][preve[v]].cap);
}
f -= d;
res += d*dist[t];
for(int v=t;v!=s;v=prevv[v]){
edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
}
int main(){
while(scanf("%d",&n) != EOF, n){
m[0] = 1; time[0].clear(); time[0].push_back(0);
x[0][0] = 0; y[0][0] = 0; c[0][0] = 0;
for(int i=1;i<n;i++){
scanf("%d",&m[i]);
for(int j=0;j<m[i];j++){
scanf("%d %d %d",&x[i][j],&y[i][j],&c[i][j]);
time[i].push_back(y[i][j]);
}
sort(time[i].begin(),time[i].end());
time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
}
m[n] = 1; time[n].clear(); time[n].push_back(INF);
x[n][0] = INF; y[n][0] = INF; c[n][0] = 0;
scanf("%d",&g);
for(int ans = g;ans>=0;ans--){
for(int i=0;i<=V;i++)G[i].clear();
for(int i=0;i<n;i++){
for(int j=0;j<time[i].size();j++){
for(int k=0;k<m[i+1];k++){
if(time[i][j]<=x[i+1][k]){
for(int l=0;l<time[i+1].size();l++){
if(y[i+1][k] == time[i+1][l]){
a = l;
break;
}
}
add_edge(i*50 + j*2 + 1, (i+1)*50 + a*2, g, c[i+1][k]);
}
}
}
for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
}
/*
if(ans == g){
for(int i=0;i<V;i++){
for(int j=0;j<G[i].size();j++){
edge e = G[i][j];
cout << i << " " << e.to << " " << e.cap << " " << e.cost << endl;
}
}
}
*/
int res = min_cost_flow(1,n*50,ans);
if(0<=res){
cout << ans << " " << res << endl;
break;
}
}
}
} | a.cc:20:20: error: 'std::vector<int> time [30]' redeclared as different kind of entity
20 | vector<int> time[30];
| ^
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
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/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'int main()':
a.cc:117:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
117 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^
a.cc:117:23: error: request for member 'clear' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
117 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^~~~~
a.cc:117:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
117 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^
a.cc:117:40: error: request for member 'push_back' in '* time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
117 | m[0] = 1; time[0].clear(); time[0].push_back(0);
| ^~~~~~~~~
a.cc:123:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
123 | time[i].push_back(y[i][j]);
| ^
a.cc:123:17: error: request for member 'push_back' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
123 | time[i].push_back(y[i][j]);
| ^~~~~~~~~
a.cc:125:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
125 | sort(time[i].begin(),time[i].end());
| ^
a.cc:125:20: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
125 | sort(time[i].begin(),time[i].end());
| ^~~~~
a.cc:125:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
125 | sort(time[i].begin(),time[i].end());
| ^
a.cc:125:36: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
125 | sort(time[i].begin(),time[i].end());
| ^~~
a.cc:126:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
126 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:126:15: error: request for member 'erase' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
126 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~~~
a.cc:126:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
126 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:126:36: error: request for member 'begin' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
126 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~~~
a.cc:126:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
126 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:126:52: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
126 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~
a.cc:126:65: warning: pointer to a function used in arithmetic [-Wpointer-arith]
126 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^
a.cc:126:67: error: request for member 'end' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
126 | time[i].erase(unique(time[i].begin(),time[i].end()),time[i].end());
| ^~~
a.cc:128:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
128 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^
a.cc:128:23: error: request for member 'clear' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
128 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^~~~~
a.cc:128:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
128 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^
a.cc:128:40: error: request for member 'push_back' in '*(time + ((sizetype)n))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
128 | m[n] = 1; time[n].clear(); time[n].push_back(INF);
| ^~~~~~~~~
a.cc:135:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
135 | for(int j=0;j<time[i].size();j++){
| ^
a.cc:135:31: error: request for member 'size' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
135 | for(int j=0;j<time[i].size();j++){
| ^~~~
a.cc:137:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
137 | if(time[i][j]<=x[i+1][k]){
| ^
a.cc:137:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
137 | if(time[i][j]<=x[i+1][k]){
| ^
a.cc:137:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
137 | if(time[i][j]<=x[i+1][k]){
| ~~~~~~~~~~^~~~~~~~~~~
a.cc:138:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
138 | for(int l=0;l<time[i+1].size();l++){
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:138:39: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
138 | for(int l=0;l<time[i+1].size();l++){
| ^~~~
a.cc:139:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
139 | if(y[i+1][k] == time[i+1][l]){
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:139:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
139 | if(y[i+1][k] == time[i+1][l]){
| ^
a.cc:139:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
139 | if(y[i+1][k] == time[i+1][l]){
| ~~~~~~~~~~^~~~~~~~~~~~~~~
a.cc:148:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
148 | for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:148:33: error: request for member 'size' in '*(time + (((sizetype)i) + 1))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
148 | for(int j=0;j<time[i+1].size();j++)add_edge((i+1)*50 + j*2,(i+1)*50 + j*2 + 1, 1, 0);
| ^~~~
|
s690455020 | p00674 | C++ | #include<iostream>
#include<complex>
#include<vector>
using namespace std;
typedef complex<long double> P;
typedef vector<P> Polygon;
double cross(P a,P b){
return (conj(a)*b).imag();
}
double area(const Polygon &p){
double a=0;
for(int i=0;i<p.size();i++){
a+=cross(p[(i+1)%p.size()],p[i]);
}
return fabs(a)/2;
}
int main(){
for(int N;cin>>N,N;){
P p[20];
for(int i=0;i<N;i++){
double x,y;
cin>>x>>y;
p[i]=P(x,y);
}
P c[18];
long double w[18];
for(int i=0;i+2<N;i++){
w[i]=area({p[0],p[i+1],p[i+2]});
c[i]=(p[0]+p[i+1]+p[i+2])/2.;
}
P a;
for(int i=0;i+2<N;i++){
a+=c[i]*w[i];
}
a/=area(vector<P>(p,p+N));
if(abs(a)==0){
a=P(1,1);
}else{
a=a/abs(a)*2.;
}
cout.precision(15);
cout<<fixed<<a.real()<<' '<<a.imag()<<endl;
}
}
| a.cc: In function 'int main()':
a.cc:34:32: error: no match for 'operator/' (operand types are 'std::complex<long double>' and 'double')
34 | c[i]=(p[0]+p[i+1]+p[i+2])/2.;
| ~~~~~~~~~~~~~~~~~~~~^~~
| | |
| | double
| std::complex<long double>
In file included from a.cc:2:
/usr/include/c++/14/complex:430:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator/(const complex<_Tp>&, const complex<_Tp>&)'
430 | operator/(const complex<_Tp>& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:430:5: note: template argument deduction/substitution failed:
a.cc:34:33: note: mismatched types 'const std::complex<_Tp>' and 'double'
34 | c[i]=(p[0]+p[i+1]+p[i+2])/2.;
| ^~
/usr/include/c++/14/complex:439:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator/(const complex<_Tp>&, const _Tp&)'
439 | operator/(const complex<_Tp>& __x, const _Tp& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:439:5: note: template argument deduction/substitution failed:
a.cc:34:33: note: deduced conflicting types for parameter 'const _Tp' ('long double' and 'double')
34 | c[i]=(p[0]+p[i+1]+p[i+2])/2.;
| ^~
/usr/include/c++/14/complex:448:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator/(const _Tp&, const complex<_Tp>&)'
448 | operator/(const _Tp& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:448:5: note: template argument deduction/substitution failed:
a.cc:34:33: note: mismatched types 'const std::complex<_Tp>' and 'double'
34 | c[i]=(p[0]+p[i+1]+p[i+2])/2.;
| ^~
a.cc:44:17: error: no match for 'operator*' (operand types are 'std::complex<long double>' and 'double')
44 | a=a/abs(a)*2.;
| ~~~~~~~~^~~
| | |
| | double
| std::complex<long double>
/usr/include/c++/14/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)'
400 | operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:400:5: note: template argument deduction/substitution failed:
a.cc:44:18: note: mismatched types 'const std::complex<_Tp>' and 'double'
44 | a=a/abs(a)*2.;
| ^~
/usr/include/c++/14/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)'
409 | operator*(const complex<_Tp>& __x, const _Tp& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:409:5: note: template argument deduction/substitution failed:
a.cc:44:18: note: deduced conflicting types for parameter 'const _Tp' ('long double' and 'double')
44 | a=a/abs(a)*2.;
| ^~
/usr/include/c++/14/complex:418:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)'
418 | operator*(const _Tp& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:418:5: note: template argument deduction/substitution failed:
a.cc:44:18: note: mismatched types 'const std::complex<_Tp>' and 'double'
44 | a=a/abs(a)*2.;
| ^~
|
s149684600 | p00674 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
template<typename F> ld bsearch(ld lower, ld upper, ld k, ll max_loop, F f) {
if (upper < lower) swap(upper, lower);
ld nu = upper - lower, nl = 0;
if (k < f(0)) swap(nl, nu); // ??????????°??????´???
REP(_, max_loop) {
ld mid = (nl + nu) / 2;
(f(mid + lower) > k ? nu : nl) = mid;
}
return (nl + nu) / 2 + lower;
}
// ?????°
#define EPS (1e-10)
// ?????????
#define X real()
#define Y imag()
#define SZ size()
#define PB push_back()
#define PREV(x, i) (x[(i+x.SZ-1) % x.SZ])
#define NEXT(x, i) (x[(i + 1) % x.SZ])
// ??????????????£??????
using ld = long double;
template<class T> using CR = const T &;
// ?¬??????¢??°
int sgn(ld a, ld b = 0) {
if (a > b + EPS) return 1;
if (a < b - EPS) return -1;
return 0;
}
///////////////////////
// ???
using P = complex<ld>;
using G = vector<P>; // ???????¨???????
struct L : public vector<P> {
L(P a, P b) { PB(a); PB(b); }
};
// ????????¢??°
namespace std {
bool operator < (P a, P b) { return sgn(a.X, b.X) ? a.X < b.X : a.Y < b.Y; }
}
ld dot (P a, P b) { return (conj(a)*b).X; }
ld cross(P a, P b) { return (conj(a)*b).Y; }
int ccw(P a, P b, P c) { // Verified : AOJCGL1C
b -= a;
c -= a;
if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise(-1) or counter clockwise(1)
if (sgn(dot(b, c)) == -1) return 2; // c--a--b
if (sgn(norm(b), norm(c)) == -1) return -2; // a--b--c
return 0; // a--c--b
}
bool iLS(CR<L> l, CR<L> s, bool strict = false) {
int a = sgn(cross(l[1] - l[0], s[0] - l[0]))
* sgn(cross(l[1] - l[0], s[1] - l[0]));
return strict ? a == -1 // strict
: a <= 0; // not strict
}
P pLL(CR<L> l, CR<L> m) {
ld a = cross(l[1] - l[0], m[1] - m[0]);
ld b = cross(l[1] - l[0], l[1] - m[0]);
assert(sgn(a)); // parallel or same line
return m[0] + b / a * (m[1] - m[0]);
}
G convex_cut(CR<G> g, CR<L> l) {
G q;
REP(i, g.size()) {
if (ccw(l[0], l[1], g[i]) != -1) q.PB(g[i]);
L s = { g[i], NEXT(g,i) };
if (iLS(l, s, true)) q.PB(pLL(l, s));
}
return q;
}
ld area2(CR<G> g) {
ld s = 0;
REP(i, g.size()) s += cross(g[i], NEXT(g, i));
return s;
}
L half_convex(CR<G> g, P p, ld lower, ld upper, ll max_loop) {
ld ans = bsearch(lower, upper, area2(g) / 2, max_loop, [&](ld x){
return area2(convex_cut(g, {p, p + polar<ld>(1, x)}));
});
return {p, p + polar<ld>(max_loop, ans)};
}
int main() {
while (true) {
int n;
cin >> n;
if (n == 0) break;
G g(n);
REP (i, n) cin >> g[i].X >> g[i].Y;
vector<ld> angles;
angles.push_back(0);
angles.push_back(acos(-1));
REP (i, n) {
ld angle = arg(g[i]);
if (angle < 0) angle += acos(-1);
angles.push_back(angle);
}
sort(ALL(angles));
REP (i, va.size() - 1) {
L l = half_convex(g, 0, angles[i], angles[i + 1], 1000);
G cc = convex_cut(g, l);
if (!sig(area2(g)/2, area2(cc))) {
printf("%.15Lf %.15Lf\n", l[1].X, l[0].Y);
break;
}
}
}
return 0;
} | a.cc:9:22: error: 'ld' does not name a type; did you mean 'll'?
9 | template<typename F> ld bsearch(ld lower, ld upper, ld k, ll max_loop, F f) {
| ^~
| ll
a.cc: In constructor 'L::L(P, P)':
a.cc:27:21: error: no matching function for call to 'L::push_back()'
27 | #define PB push_back()
| ~~~~~~~~~^~
a.cc:48:23: note: in expansion of macro 'PB'
48 | L(P a, P b) { PB(a); PB(b); }
| ^~
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 0 provided
a.cc:27:21: error: no matching function for call to 'L::push_back()'
27 | #define PB push_back()
| ~~~~~~~~~^~
a.cc:48:30: note: in expansion of macro 'PB'
48 | L(P a, P b) { PB(a); PB(b); }
| ^~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 0 provided
a.cc: In function 'G convex_cut(CR<std::vector<std::complex<long double> > >, CR<L>)':
a.cc:27:21: error: no matching function for call to 'std::vector<std::complex<long double> >::push_back()'
27 | #define PB push_back()
| ^
a.cc:83:52: note: in expansion of macro 'PB'
83 | if (ccw(l[0], l[1], g[i]) != -1) q.PB(g[i]);
| ^~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 0 provided
a.cc:27:21: error: no matching function for call to 'std::vector<std::complex<long double> >::push_back()'
27 | #define PB push_back()
| ^
a.cc:85:40: note: in expansion of macro 'PB'
85 | if (iLS(l, s, true)) q.PB(pLL(l, s));
| ^~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 0 provided
a.cc: In function 'L half_convex(CR<std::vector<std::complex<long double> > >, P, ld, ld, ll)':
a.cc:95:26: error: cannot convert 'ld' {aka 'long double'} to 'const void*'
95 | ld ans = bsearch(lower, upper, area2(g) / 2, max_loop, [&](ld x){
| ^~~~~
| |
| ld {aka long double}
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42:
/usr/include/stdlib.h:960:35: note: initializing argument 1 of 'void* bsearch(const void*, const void*, size_t, size_t, __compar_fn_t)'
960 | extern void *bsearch (const void *__key, const void *__base,
| ~~~~~~~~~~~~^~~~~
a.cc: In function 'int main()':
a.cc:108:32: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'long double')
108 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ~~~ ^~
| |
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/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:24:15: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'long double'
24 | #define X real()
| ^
a.cc:108:40: note: in expansion of macro 'X'
108 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:24:15: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'long double'
24 | #define X real()
| ^
a.cc:108:40: note: in expansion of macro 'X'
108 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:24:15: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'long double'
24 | #define X real()
| ^
a.cc:108:40: note: in expansion of macro 'X'
108 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:24:15: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long double'
24 | #define X real()
| ^
a.cc:108:40: note: in expansion of macro 'X'
108 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:24:15: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'long double'
24 | #define X real()
| ^
a.cc:108:40: note: in expansion of macro 'X'
108 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long |
s189244382 | p00674 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
template<typename F> ld bsearch(ld lower, ld upper, ld k, ll max_loop, F f) {
if (upper < lower) swap(upper, lower);
ld nu = upper - lower, nl = 0;
if (k < f(0)) swap(nl, nu); // ??????????°??????´???
REP(_, max_loop) {
ld mid = (nl + nu) / 2;
(f(mid + lower) > k ? nu : nl) = mid;
}
return (nl + nu) / 2 + lower;
}
// ?????°
#define EPS (1e-10)
// ?????????
#define X real()
#define Y imag()
#define SZ size()
#define PB push_back()
#define PREV(x, i) (x[(i+x.SZ-1) % x.SZ])
#define NEXT(x, i) (x[(i + 1) % x.SZ])
// ??????????????£??????
using ld = long double;
template<class T> using CR = const T &;
// ?¬??????¢??°
int sgn(ld a, ld b = 0) {
if (a > b + EPS) return 1;
if (a < b - EPS) return -1;
return 0;
}
///////////////////////
// ???
using P = complex<ld>;
using G = vector<P>; // ???????¨???????
struct L : public vector<P> {
L(P a, P b) { PB(a); PB(b); }
};
// ????????¢??°
namespace std {
bool operator < (P a, P b) { return sgn(a.X, b.X) ? a.X < b.X : a.Y < b.Y; }
}
ld dot (P a, P b) { return (conj(a)*b).X; }
ld cross(P a, P b) { return (conj(a)*b).Y; }
int ccw(P a, P b, P c) { // Verified : AOJCGL1C
b -= a;
c -= a;
if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise(-1) or counter clockwise(1)
if (sgn(dot(b, c)) == -1) return 2; // c--a--b
if (sgn(norm(b), norm(c)) == -1) return -2; // a--b--c
return 0; // a--c--b
}
bool iLS(CR<L> l, CR<L> s, bool strict = false) {
int a = sgn(cross(l[1] - l[0], s[0] - l[0]))
* sgn(cross(l[1] - l[0], s[1] - l[0]));
return strict ? a == -1 // strict
: a <= 0; // not strict
}
P pLL(CR<L> l, CR<L> m) {
ld a = cross(l[1] - l[0], m[1] - m[0]);
ld b = cross(l[1] - l[0], l[1] - m[0]);
assert(sgn(a)); // parallel or same line
return m[0] + b / a * (m[1] - m[0]);
}
G convex_cut(CR<G> g, CR<L> l) {
G q;
REP(i, g.size()) {
if (ccw(l[0], l[1], g[i]) != -1) q.PB(g[i]);
L s = { g[i], NEXT(g,i) };
if (iLS(l, s, true)) q.PB(pLL(l, s));
}
return q;
}
ld area2(CR<G> g) {
ld s = 0;
REP(i, g.size()) s += cross(g[i], NEXT(g, i));
return s;
}
L half_convex(CR<G> g, P p, ld lower, ld upper, ll max_loop) {
ld ans = bsearch(lower, upper, area2(g) / 2, max_loop, [&](ld x){
return area2(convex_cut(g, {p, p + polar<ld>(1, x)}));
});
return {p, p + polar<ld>(max_loop, ans)};
}
int main() {
while (true) {
int n;
cin >> n;
if (n == 0) break;
G g(n);
REP (i, n) cin >> g[i].X >> g[i].Y;
vector<ld> angles;
angles.push_back(0);
angles.push_back(acos(-1));
REP (i, n) {
ld angle = arg(g[i]);
if (angle < 0) angle += acos(-1);
angles.push_back(angle);
}
sort(ALL(angles));
REP (i, va.size() - 1) {
L l = half_convex(g, 0, angles[i], angles[i + 1], 1000);
G cc = convex_cut(g, l);
if (!sig(area2(g)/2, area2(cc))) {
printf("%.15Lf %.15Lf\n", l[1].X, l[0].Y);
break;
}
}
}
return 0;
} | a.cc: In constructor 'L::L(P, P)':
a.cc:28:21: error: no matching function for call to 'L::push_back()'
28 | #define PB push_back()
| ~~~~~~~~~^~
a.cc:49:23: note: in expansion of macro 'PB'
49 | L(P a, P b) { PB(a); PB(b); }
| ^~
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 0 provided
a.cc:28:21: error: no matching function for call to 'L::push_back()'
28 | #define PB push_back()
| ~~~~~~~~~^~
a.cc:49:30: note: in expansion of macro 'PB'
49 | L(P a, P b) { PB(a); PB(b); }
| ^~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 0 provided
a.cc: In function 'G convex_cut(CR<std::vector<std::complex<long double> > >, CR<L>)':
a.cc:28:21: error: no matching function for call to 'std::vector<std::complex<long double> >::push_back()'
28 | #define PB push_back()
| ^
a.cc:84:52: note: in expansion of macro 'PB'
84 | if (ccw(l[0], l[1], g[i]) != -1) q.PB(g[i]);
| ^~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 0 provided
a.cc:28:21: error: no matching function for call to 'std::vector<std::complex<long double> >::push_back()'
28 | #define PB push_back()
| ^
a.cc:86:40: note: in expansion of macro 'PB'
86 | if (iLS(l, s, true)) q.PB(pLL(l, s));
| ^~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::complex<long double>; _Alloc = std::allocator<std::complex<long double> >; value_type = std::complex<long double>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 0 provided
a.cc: In function 'int main()':
a.cc:109:32: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'long double')
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ~~~ ^~
| |
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/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:25:15: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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: conv |
s766094742 | p00674 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
template<typename F> ld bsearch(ld lower, ld upper, ld k, ll max_loop, F f) {
if (upper < lower) swap(upper, lower);
ld nu = upper - lower, nl = 0;
if (k < f(0)) swap(nl, nu); // ??????????°??????´???
REP(_, max_loop) {
ld mid = (nl + nu) / 2;
(f(mid + lower) > k ? nu : nl) = mid;
}
return (nl + nu) / 2 + lower;
}
// ?????°
#define EPS (1e-10)
// ?????????
#define X real()
#define Y imag()
#define SZ size()
#define PB(x) push_back(x)
#define PREV(x, i) (x[(i+x.SZ-1) % x.SZ])
#define NEXT(x, i) (x[(i + 1) % x.SZ])
// ??????????????£??????
using ld = long double;
template<class T> using CR = const T &;
// ?¬??????¢??°
int sgn(ld a, ld b = 0) {
if (a > b + EPS) return 1;
if (a < b - EPS) return -1;
return 0;
}
///////////////////////
// ???
using P = complex<ld>;
using G = vector<P>; // ???????¨???????
struct L : public vector<P> {
L(P a, P b) { PB(a); PB(b); }
};
// ????????¢??°
namespace std {
bool operator < (P a, P b) { return sgn(a.X, b.X) ? a.X < b.X : a.Y < b.Y; }
}
ld dot (P a, P b) { return (conj(a)*b).X; }
ld cross(P a, P b) { return (conj(a)*b).Y; }
int ccw(P a, P b, P c) { // Verified : AOJCGL1C
b -= a;
c -= a;
if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise(-1) or counter clockwise(1)
if (sgn(dot(b, c)) == -1) return 2; // c--a--b
if (sgn(norm(b), norm(c)) == -1) return -2; // a--b--c
return 0; // a--c--b
}
bool iLS(CR<L> l, CR<L> s, bool strict = false) {
int a = sgn(cross(l[1] - l[0], s[0] - l[0]))
* sgn(cross(l[1] - l[0], s[1] - l[0]));
return strict ? a == -1 // strict
: a <= 0; // not strict
}
P pLL(CR<L> l, CR<L> m) {
ld a = cross(l[1] - l[0], m[1] - m[0]);
ld b = cross(l[1] - l[0], l[1] - m[0]);
assert(sgn(a)); // parallel or same line
return m[0] + b / a * (m[1] - m[0]);
}
G convex_cut(CR<G> g, CR<L> l) {
G q;
REP(i, g.size()) {
if (ccw(l[0], l[1], g[i]) != -1) q.PB(g[i]);
L s = { g[i], NEXT(g,i) };
if (iLS(l, s, true)) q.PB(pLL(l, s));
}
return q;
}
ld area2(CR<G> g) {
ld s = 0;
REP(i, g.size()) s += cross(g[i], NEXT(g, i));
return s;
}
L half_convex(CR<G> g, P p, ld lower, ld upper, ll max_loop) {
ld ans = bsearch(lower, upper, area2(g) / 2, max_loop, [&](ld x){
return area2(convex_cut(g, {p, p + polar<ld>(1, x)}));
});
return {p, p + polar<ld>(max_loop, ans)};
}
int main() {
while (true) {
int n;
cin >> n;
if (n == 0) break;
G g(n);
REP (i, n) cin >> g[i].X >> g[i].Y;
vector<ld> angles;
angles.push_back(0);
angles.push_back(acos(-1));
REP (i, n) {
ld angle = arg(g[i]);
if (angle < 0) angle += acos(-1);
angles.push_back(angle);
}
sort(ALL(angles));
REP (i, va.size() - 1) {
L l = half_convex(g, 0, angles[i], angles[i + 1], 1000);
G cc = convex_cut(g, l);
if (!sig(area2(g)/2, area2(cc))) {
printf("%.15Lf %.15Lf\n", l[1].X, l[0].Y);
break;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:109:32: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'long double')
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ~~~ ^~
| |
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/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:25:15: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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:25:15: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:25:15: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:25:15: error: cannot bind non-const lvalue reference of type 'double&' to a value of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:25:15: error: cannot bind non-const lvalue reference of type 'long double&' to an rvalue of type 'long double'
25 | #define X real()
| ^
a.cc:109:40: note: in expansion of macro 'X'
109 | REP (i, n) cin >> g[i].X >> g[i].Y;
| ^
/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>]'
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'long double' to 'void*&'
328 | operator>>(void*& __p)
| ~~~~~~~^~~
/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 = cha |
s017099145 | p00674 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
template<typename F> ld bsearch(ld lower, ld upper, ld k, ll max_loop, F f) {
if (upper < lower) swap(upper, lower);
ld nu = upper - lower, nl = 0;
if (k < f(0)) swap(nl, nu); // ??????????°??????´???
REP(_, max_loop) {
ld mid = (nl + nu) / 2;
(f(mid + lower) > k ? nu : nl) = mid;
}
return (nl + nu) / 2 + lower;
}
// ?????°
#define EPS (1e-10)
// ?????????
#define X real()
#define Y imag()
#define SZ size()
#define PB(x) push_back(x)
#define PREV(x, i) (x[(i+x.SZ-1) % x.SZ])
#define NEXT(x, i) (x[(i + 1) % x.SZ])
// ??????????????£??????
using ld = long double;
template<class T> using CR = const T &;
// ?¬??????¢??°
int sgn(ld a, ld b = 0) {
if (a > b + EPS) return 1;
if (a < b - EPS) return -1;
return 0;
}
///////////////////////
// ???
using P = complex<ld>;
using G = vector<P>; // ???????¨???????
struct L : public vector<P> {
L(P a, P b) { PB(a); PB(b); }
};
// ????????¢??°
namespace std {
bool operator < (P a, P b) { return sgn(a.X, b.X) ? a.X < b.X : a.Y < b.Y; }
}
ld dot (P a, P b) { return (conj(a)*b).X; }
ld cross(P a, P b) { return (conj(a)*b).Y; }
int ccw(P a, P b, P c) { // Verified : AOJCGL1C
b -= a;
c -= a;
if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise(-1) or counter clockwise(1)
if (sgn(dot(b, c)) == -1) return 2; // c--a--b
if (sgn(norm(b), norm(c)) == -1) return -2; // a--b--c
return 0; // a--c--b
}
bool iLS(CR<L> l, CR<L> s, bool strict = false) {
int a = sgn(cross(l[1] - l[0], s[0] - l[0]))
* sgn(cross(l[1] - l[0], s[1] - l[0]));
return strict ? a == -1 // strict
: a <= 0; // not strict
}
P pLL(CR<L> l, CR<L> m) {
ld a = cross(l[1] - l[0], m[1] - m[0]);
ld b = cross(l[1] - l[0], l[1] - m[0]);
assert(sgn(a)); // parallel or same line
return m[0] + b / a * (m[1] - m[0]);
}
G convex_cut(CR<G> g, CR<L> l) {
G q;
REP(i, g.size()) {
if (ccw(l[0], l[1], g[i]) != -1) q.PB(g[i]);
L s = { g[i], NEXT(g,i) };
if (iLS(l, s, true)) q.PB(pLL(l, s));
}
return q;
}
ld area2(CR<G> g) {
ld s = 0;
REP(i, g.size()) s += cross(g[i], NEXT(g, i));
return s;
}
L half_convex(CR<G> g, P p, ld lower, ld upper, ll max_loop) {
ld ans = bsearch(lower, upper, area2(g) / 2, max_loop, [&](ld x){
return area2(convex_cut(g, {p, p + polar<ld>(1, x)}));
});
return {p, p + polar<ld>(max_loop, ans)};
}
int main() {
while (true) {
int n;
cin >> n;
if (n == 0) break;
G g(n);
REP (i, n) {
ld x,y; cin >> x >> y;
g[i].real(x);
g[i].imag(y);
}
vector<ld> angles;
angles.push_back(0);
angles.push_back(acos(-1));
REP (i, n) {
ld angle = arg(g[i]);
if (angle < 0) angle += acos(-1);
angles.push_back(angle);
}
sort(ALL(angles));
REP (i, va.size() - 1) {
L l = half_convex(g, 0, angles[i], angles[i + 1], 1000);
G cc = convex_cut(g, l);
if (!sig(area2(g)/2, area2(cc))) {
printf("%.15Lf %.15Lf\n", l[1].X, l[0].Y);
break;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:123:25: error: 'va' was not declared in this scope
123 | REP (i, va.size() - 1) {
| ^~
a.cc:7:37: note: in definition of macro 'REP'
7 | #define REP(i,n) for(ll i = 0; i < (n); ++i)
| ^
a.cc:126:30: error: 'sig' was not declared in this scope; did you mean 'sin'?
126 | if (!sig(area2(g)/2, area2(cc))) {
| ^~~
| sin
|
s594043839 | p00674 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
typedef vector<int> vi; typedef vector<ll> vl; typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)
template<typename F> ld bsearch(ld lower, ld upper, ld k, ll max_loop, F f) {
if (upper < lower) swap(upper, lower);
ld nu = upper - lower, nl = 0;
if (k < f(0)) swap(nl, nu); // ??????????°??????´???
REP(_, max_loop) {
ld mid = (nl + nu) / 2;
(f(mid + lower) > k ? nu : nl) = mid;
}
return (nl + nu) / 2 + lower;
}
// ?????°
#define EPS (1e-10)
// ?????????
#define X real()
#define Y imag()
#define PB(x) push_back(x)
#define PREV(x, i) (x[(i+x.SZ-1) % x.SZ])
#define NEXT(x, i) (x[(i + 1) % x.SZ])
// ??????????????£??????
using ld = long double;
template<class T> using CR = const T &;
// ?¬??????¢??°
int sgn(ld a, ld b = 0) {
if (a > b + EPS) return 1;
if (a < b - EPS) return -1;
return 0;
}
///////////////////////
// ???
using P = complex<ld>;
using G = vector<P>; // ???????¨???????
struct L : public vector<P> {
L(P a, P b) { PB(a); PB(b); }
};
// ????????¢??°
namespace std {
bool operator < (P a, P b) { return sgn(a.X, b.X) ? a.X < b.X : a.Y < b.Y; }
}
ld dot (P a, P b) { return (conj(a)*b).X; }
ld cross(P a, P b) { return (conj(a)*b).Y; }
int ccw(P a, P b, P c) { // Verified : AOJCGL1C
b -= a;
c -= a;
if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise(-1) or counter clockwise(1)
if (sgn(dot(b, c)) == -1) return 2; // c--a--b
if (sgn(norm(b), norm(c)) == -1) return -2; // a--b--c
return 0; // a--c--b
}
bool iLS(CR<L> l, CR<L> s, bool strict = false) {
int a = sgn(cross(l[1] - l[0], s[0] - l[0]))
* sgn(cross(l[1] - l[0], s[1] - l[0]));
return strict ? a == -1 // strict
: a <= 0; // not strict
}
P pLL(CR<L> l, CR<L> m) {
ld a = cross(l[1] - l[0], m[1] - m[0]);
ld b = cross(l[1] - l[0], l[1] - m[0]);
assert(sgn(a)); // parallel or same line
return m[0] + b / a * (m[1] - m[0]);
}
G convex_cut(CR<G> g, CR<L> l) {
G q;
REP(i, g.size()) {
if (ccw(l[0], l[1], g[i]) != -1) q.PB(g[i]);
L s = { g[i], NEXT(g,i) };
if (iLS(l, s, true)) q.PB(pLL(l, s));
}
return q;
}
ld area2(CR<G> g) {
ld s = 0;
REP(i, g.size()) s += cross(g[i], NEXT(g, i));
return s;
}
L half_convex(CR<G> g, P p, ld lower, ld upper, ll max_loop) {
ld ans = bsearch(lower, upper, area2(g) / 2, max_loop, [&](ld x){
return area2(convex_cut(g, {p, p + polar<ld>(1, x)}));
});
return {p, p + polar<ld>(max_loop, ans)};
}
int main() {
#ifdef _WIN32
ifstream cin("sample.in");
ofstream cout("sample.out");
#endif
cin.tie(0); // cin??¨cout?????£????????????
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(50);
while (true) {
int n;
cin >> n;
if (n == 0) break;
G g(n);
REP (i, n) {
ld x,y; cin >> x >> y;
g[i].real(x);
g[i].imag(y);
}
vector<ld> angles;
angles.push_back(0);
angles.push_back(acos(-1));
REP (i, n) {
ld angle = arg(g[i]);
if (angle < 0) angle += acos(-1);
angles.push_back(angle);
}
sort(ALL(angles));
REP (i, angles.size() - 1) {
L l = half_convex(g, 0, angles[i], angles[i + 1], 1000);
G cc = convex_cut(g, l);
if (!sgn(area2(g)/2, area2(cc))) {
cout << l[1].X << " " << l[1].Y << endl;
break;
}
}
}
return 0;
} | a.cc: In function 'G convex_cut(CR<std::vector<std::complex<long double> > >, CR<L>)':
a.cc:33:35: error: 'const class std::vector<std::complex<long double> >' has no member named 'SZ'
33 | #define NEXT(x, i) (x[(i + 1) % x.SZ])
| ^~
a.cc:88:31: note: in expansion of macro 'NEXT'
88 | L s = { g[i], NEXT(g,i) };
| ^~~~
a.cc:88:41: error: could not convert '{(& g)->std::vector<std::complex<long double> >::operator[](((std::vector<std::complex<long double> >::size_type)i)), <expression error>}' from '<brace-enclosed initializer list>' to 'L'
88 | L s = { g[i], NEXT(g,i) };
| ^
| |
| <brace-enclosed initializer list>
a.cc: In function 'ld area2(CR<std::vector<std::complex<long double> > >)':
a.cc:33:35: error: 'const class std::vector<std::complex<long double> >' has no member named 'SZ'
33 | #define NEXT(x, i) (x[(i + 1) % x.SZ])
| ^~
a.cc:95:43: note: in expansion of macro 'NEXT'
95 | REP(i, g.size()) s += cross(g[i], NEXT(g, i));
| ^~~~
|
s130339752 | p00674 | C++ | ツ!
4
-100 -100
100 -100
100 100
-100 100
4
-99 -100
100 -100
100 100
-99 100
4
-100 -99
100 -99
100 100
-100 100
14
-99 -70
-92 -79
10 -98
37 -100
62 -95
77 -69
88 -47
92 -10
96 28
100 91
42 92
-62 92
-88 91
-98 64
0 | a.cc:1:1: error: '\U000030c4\U0000ff01' does not name a type
1 | ツ!
| ^~~~
|
s805122428 | p00674 | C++ | main(n,i){for(;scanf("%d",&n),n;){for(;n--;)scanf("%*d%*d");puts("0.000000000000000 0.000000000000000");}exit(0);} | a.cc:1:5: error: expected constructor, destructor, or type conversion before '(' token
1 | main(n,i){for(;scanf("%d",&n),n;){for(;n--;)scanf("%*d%*d");puts("0.000000000000000 0.000000000000000");}exit(0);}
| ^
|
s683350196 | p00674 | C++ | main() | a.cc:1:7: error: expected constructor, destructor, or type conversion at end of input
1 | main()
| ^
|
s474319118 | p00674 | C++ | main(); | a.cc:1:7: error: expected constructor, destructor, or type conversion before ';' token
1 | main();
| ^
|
s451890420 | p00674 | C++ | #include <cstdio>
main(){
cout<<"hello world"<<endl;
} | a.cc:2:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
2 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:3:1: error: 'cout' was not declared in this scope
3 | cout<<"hello world"<<endl;
| ^~~~
a.cc:3:22: error: 'endl' was not declared in this scope
3 | cout<<"hello world"<<endl;
| ^~~~
|
s207220565 | p00674 | C++ | main; | a.cc:1:1: error: 'main' does not name a type
1 | main;
| ^~~~
|
s300135272 | p00674 | C++ | main; | a.cc:1:1: error: 'main' does not name a type
1 | main;
| ^~~~
|
s914234712 | p00674 | C++ | 4
-100 -100
100 -100
100 100
-100 100
4
-99 -100
100 -100
100 100
-99 100
4
-100 -99
100 -99
100 100
-100 100
14
-99 -70
-92 -79
10 -98
37 -100
62 -95
77 -69
88 -47
92 -10
96 28
100 91
42 92
-62 92
-88 91
-98 64
0 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 4
| ^
|
s840405201 | p00674 | C++ | #include <iostream>
#include <complex>
#include <vector>
#include <cstdio>
using namespace std;
#define FOREACH(it,c) for(__typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define TIMES(i,n) for(int i = 0; i < (n); ++i)
typedef complex<double> P;
static const double PI = acos(-1.0);
static const double EPS = 1e-10;
inline bool EQV(double a, double b) {
return abs(a-b) < EPS;
}
inline double dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }
inline double cross(const P& a, const P& b) { return a.real()*b.imag() - b.real()*a.imag(); }
int ccw(const P& a, P b, P c)
{
b -= a;
c -= a;
if (cross(b, c) > EPS) {
return +1;
} else if (cross(b, c) < -EPS) {
return -1;
} else if (dot(b, c) < -EPS) {
return +2;
} else if (dot(b, b) + EPS < dot(c, c)) {
return -2;
} else {
return 0;
}
}
struct line/*{{{*/
{
P a, b;
line() {}
line(const P& p, const P& q) : a(p), b(q) {}
inline bool parallel(const line& ln) const
{
return abs(cross(ln.b - ln.a, b - a)) < EPS;
}
inline bool intersects(const line& ln) const
{
return !parallel(ln);
}
inline P intersection(const line& ln) const
{
// assert(intersects(ln))
const P x = b - a;
const P y = ln.b - ln.a;
return a + x*(cross(y, ln.a - a))/cross(y, x);
}
inline double distance(const P& p) const
{
return abs(cross(p - a, b - a)) / abs(b - a);
}
// AOJ 1171 Laser Beam Reflections
inline P perpendicular(const P& p) const
{
// 点 p から直線上に下ろした垂線の足
const double t = dot(p-a, a-b) / dot(b-a, b-a);
return a + t*(a-b);
}
};/*}}}*/
struct segment/*{{{*/
{
P a, b;
segment() {}
segment(const P& x, const P& y) : a(x), b(y) {}
inline bool intersects(const line& ln) const
{
return cross(ln.b - ln.a, a - ln.a) * cross(ln.b - ln.a, b - ln.a) < EPS;
}
// AOJ 2402 Milkey Way
inline bool intersects(const segment& seg) const
{
return ccw(a, b, seg.a) * ccw(a, b, seg.b) <= 0
&& ccw(seg.a, seg.b, a) * ccw(seg.a, seg.b, b) <= 0;
}
// AOJ 1171 Laser Beam Relections
inline P intersection(const line& ln) const
{
// assert(intersects(ln))
const P x = b - a;
const P y = ln.b - ln.a;
return a + x*(cross(y, ln.a - a))/cross(y, x);
}
inline bool parallel(const line& ln) const
{
return abs(cross(ln.b - ln.a, b - a)) < EPS;
}
// AOJ 2402 Milkey Way
inline double distance(const P& p) const
{
if (dot(b-a, p-a) < EPS) {
return abs(p-a);
} else if (dot(a-b, p-b) < EPS) {
return abs(p-b);
} else {
return abs(cross(b-a, p-a))/abs(b-a);
}
}
// AOJ 2402 Milkey Way
inline double distance(const segment& seg) const
{
if (intersects(seg)) {
return 0;
} else {
return
min(
min(distance(seg.a), distance(seg.b)),
min(seg.distance(a), seg.distance(b)));
}
}
};/*}}}*/
struct polygon/*{{{*/
{
vector<P> ps;
polygon() {}
polygon(const vector<P>& v) : ps(v) {}
inline int size() const { return ps.size(); }
inline void push_back(const P& p) { ps.push_back(p); }
inline P& operator[](int i) { return ps[i]; }
inline const P& operator[](int i) const { return ps[i]; }
double area() const
{
// positive if polygon is clockwise
double a = 0.0;
const int N = ps.size();
for (int i = 0; i < N; i++) {
a += cross(ps[(i+1)%N], ps[i]);
}
return a/2.0;
}
polygon cut(const line& ln) const
{
// cut out the left-side of the line
const int N = ps.size();
polygon ret;
for (int i = 0; i < N; i++) {
const segment seg(ps[i], ps[(i+1)%N]);
if (cross(ln.b - ln.a, ps[i] - ln.a) < EPS) {
// ps[i] is right-side of the line
ret.push_back(ps[i]);
if (!seg.parallel(ln) && seg.intersects(ln)) {
const P p = seg.intersection(ln);
if (abs(p - ps[i]) > EPS) {
ret.push_back(p);
}
}
} else if (!seg.parallel(ln) && seg.intersects(ln)) {
ret.push_back(seg.intersection(ln));
}
}
return ret;
}
};/*}}}*/
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int N;
while(cin >> N) {
if(!N) break;
printf("%d\n", N);
vector<P> points;
vector<double> angles;
TIMES(_, N) {
P point;
cin >> point.real() >> point.imag();
points.push_back(point);
double angle = arg(point);
if(angle > PI) angle -= PI;
angles.push_back(angle);
}
sort(angles.begin(), angles.end());
polygon poly(points);
const double target = poly.area() / 2;
TIMES(i, N) {
const int next = (i+1) % N;
const double area_l = poly.cut(line(P(0,0), points[i])).area();
const double area_r = poly.cut(line(P(0,0), points[next])).area();
if((area_l - target) * (area_r - target) <= 0) {
double l = angles[i], r = angles[next];
if(i == N-1) r += PI;
TIMES(_, 100) {
double center = (l+r) / 2;
double area = poly.cut(line(P(0,0), polar(10.0, center))).area();
if(area_l < area_r) {
if(area < target) l = center;
else r = center;
} else {
if(area < target) r = center;
else l = center;
}
}
P ans = polar(10.0, (l+r)/2);
if(EQV(poly.cut(line(P(0,0), ans)).area(), target)) {
printf("%.15f %.15f\n", ans.real(), ans.imag());
break;
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:193:17: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double')
193 | cin >> point.real() >> point.imag();
| ~~~ ^~ ~~~~~~~~~~~~
| | |
| | double
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:1:
/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:193:30: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:193:30: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:193:30: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:193:30: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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>]'
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'double' to 'void*&'
328 | operator>>(void*& __p)
| ~~~~~~~^~~
/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>]'
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]'
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios |
s069818757 | p00674 | C++ | #include <iostream>
#include <complex>
#include <vector>
#include <cstdio>
using namespace std;
#define FOREACH(it,c) for(__typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define TIMES(i,n) for(int i = 0; i < (n); ++i)
typedef complex<double> P;
static const double PI = acos(-1.0);
static const double EPS = 1e-10;
inline bool EQV(double a, double b) {
return abs(a-b) < EPS;
}
inline double dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }
inline double cross(const P& a, const P& b) { return a.real()*b.imag() - b.real()*a.imag(); }
int ccw(const P& a, P b, P c)
{
b -= a;
c -= a;
if (cross(b, c) > EPS) {
return +1;
} else if (cross(b, c) < -EPS) {
return -1;
} else if (dot(b, c) < -EPS) {
return +2;
} else if (dot(b, b) + EPS < dot(c, c)) {
return -2;
} else {
return 0;
}
}
struct line/*{{{*/
{
P a, b;
line() {}
line(const P& p, const P& q) : a(p), b(q) {}
inline bool parallel(const line& ln) const
{
return abs(cross(ln.b - ln.a, b - a)) < EPS;
}
inline bool intersects(const line& ln) const
{
return !parallel(ln);
}
inline P intersection(const line& ln) const
{
// assert(intersects(ln))
const P x = b - a;
const P y = ln.b - ln.a;
return a + x*(cross(y, ln.a - a))/cross(y, x);
}
inline double distance(const P& p) const
{
return abs(cross(p - a, b - a)) / abs(b - a);
}
// AOJ 1171 Laser Beam Reflections
inline P perpendicular(const P& p) const
{
// 点 p から直線上に下ろした垂線の足
const double t = dot(p-a, a-b) / dot(b-a, b-a);
return a + t*(a-b);
}
};/*}}}*/
struct segment/*{{{*/
{
P a, b;
segment() {}
segment(const P& x, const P& y) : a(x), b(y) {}
inline bool intersects(const line& ln) const
{
return cross(ln.b - ln.a, a - ln.a) * cross(ln.b - ln.a, b - ln.a) < EPS;
}
// AOJ 2402 Milkey Way
inline bool intersects(const segment& seg) const
{
return ccw(a, b, seg.a) * ccw(a, b, seg.b) <= 0
&& ccw(seg.a, seg.b, a) * ccw(seg.a, seg.b, b) <= 0;
}
// AOJ 1171 Laser Beam Relections
inline P intersection(const line& ln) const
{
// assert(intersects(ln))
const P x = b - a;
const P y = ln.b - ln.a;
return a + x*(cross(y, ln.a - a))/cross(y, x);
}
inline bool parallel(const line& ln) const
{
return abs(cross(ln.b - ln.a, b - a)) < EPS;
}
// AOJ 2402 Milkey Way
inline double distance(const P& p) const
{
if (dot(b-a, p-a) < EPS) {
return abs(p-a);
} else if (dot(a-b, p-b) < EPS) {
return abs(p-b);
} else {
return abs(cross(b-a, p-a))/abs(b-a);
}
}
// AOJ 2402 Milkey Way
inline double distance(const segment& seg) const
{
if (intersects(seg)) {
return 0;
} else {
return
min(
min(distance(seg.a), distance(seg.b)),
min(seg.distance(a), seg.distance(b)));
}
}
};/*}}}*/
struct polygon/*{{{*/
{
vector<P> ps;
polygon() {}
polygon(const vector<P>& v) : ps(v) {}
inline int size() const { return ps.size(); }
inline void push_back(const P& p) { ps.push_back(p); }
inline P& operator[](int i) { return ps[i]; }
inline const P& operator[](int i) const { return ps[i]; }
double area() const
{
// positive if polygon is clockwise
double a = 0.0;
const int N = ps.size();
for (int i = 0; i < N; i++) {
a += cross(ps[(i+1)%N], ps[i]);
}
return a/2.0;
}
polygon cut(const line& ln) const
{
// cut out the left-side of the line
const int N = ps.size();
polygon ret;
for (int i = 0; i < N; i++) {
const segment seg(ps[i], ps[(i+1)%N]);
if (cross(ln.b - ln.a, ps[i] - ln.a) < EPS) {
// ps[i] is right-side of the line
ret.push_back(ps[i]);
if (!seg.parallel(ln) && seg.intersects(ln)) {
const P p = seg.intersection(ln);
if (abs(p - ps[i]) > EPS) {
ret.push_back(p);
}
}
} else if (!seg.parallel(ln) && seg.intersects(ln)) {
ret.push_back(seg.intersection(ln));
}
}
return ret;
}
};/*}}}*/
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int N;
while(cin >> N) {
if(!N) break;
printf("%d\n", N);
vector<P> points;
vector<double> angles;
TIMES(_, N) {
P point;
cin >> point.real() >> point.imag();
points.push_back(point);
double angle = arg(point);
if(angle > PI) angle -= PI;
angles.push_back(angle);
}
sort(angles.begin(), angles.end());
polygon poly(points);
const double target = poly.area() / 2;
TIMES(i, N) {
const int next = (i+1) % N;
const double area_l = poly.cut(line(P(0,0), points[i])).area();
const double area_r = poly.cut(line(P(0,0), points[next])).area();
if((area_l - target) * (area_r - target) <= 0) {
double l = angles[i], r = angles[next];
if(i == N-1) r += PI;
TIMES(_, 100) {
double center = (l+r) / 2;
double area = poly.cut(line(P(0,0), polar(10.0, center))).area();
if(area_l < area_r) {
if(area < target) l = center;
else r = center;
} else {
if(area < target) r = center;
else l = center;
}
}
P ans = polar(10.0, (l+r)/2);
if(EQV(poly.cut(line(P(0,0), ans)).area(), target)) {
printf("%.15f %.15f\n", ans.real(), ans.imag());
break;
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:193:17: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double')
193 | cin >> point.real() >> point.imag();
| ~~~ ^~ ~~~~~~~~~~~~
| | |
| | double
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:1:
/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:193:30: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:193:30: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:193:30: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:193:30: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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>]'
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'double' to 'void*&'
328 | operator>>(void*& __p)
| ~~~~~~~^~~
/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>]'
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]'
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios |
s111077991 | p00674 | C++ | #include <iostream>
#include <complex>
#include <vector>
#include <cstdio>
using namespace std;
#define FOREACH(it,c) for(__typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define TIMES(i,n) for(int i = 0; i < (n); ++i)
typedef complex<double> P;
static const double PI = acos(-1.0);
static const double EPS = 1e-10;
inline bool EQV(double a, double b) {
return abs(a-b) < EPS;
}
inline double dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }
inline double cross(const P& a, const P& b) { return a.real()*b.imag() - b.real()*a.imag(); }
int ccw(const P& a, P b, P c)
{
b -= a;
c -= a;
if (cross(b, c) > EPS) {
return +1;
} else if (cross(b, c) < -EPS) {
return -1;
} else if (dot(b, c) < -EPS) {
return +2;
} else if (dot(b, b) + EPS < dot(c, c)) {
return -2;
} else {
return 0;
}
}
struct line/*{{{*/
{
P a, b;
line() {}
line(const P& p, const P& q) : a(p), b(q) {}
inline bool parallel(const line& ln) const
{
return abs(cross(ln.b - ln.a, b - a)) < EPS;
}
inline bool intersects(const line& ln) const
{
return !parallel(ln);
}
inline P intersection(const line& ln) const
{
// assert(intersects(ln))
const P x = b - a;
const P y = ln.b - ln.a;
return a + x*(cross(y, ln.a - a))/cross(y, x);
}
inline double distance(const P& p) const
{
return abs(cross(p - a, b - a)) / abs(b - a);
}
// AOJ 1171 Laser Beam Reflections
inline P perpendicular(const P& p) const
{
// 点 p から直線上に下ろした垂線の足
const double t = dot(p-a, a-b) / dot(b-a, b-a);
return a + t*(a-b);
}
};/*}}}*/
struct segment/*{{{*/
{
P a, b;
segment() {}
segment(const P& x, const P& y) : a(x), b(y) {}
inline bool intersects(const line& ln) const
{
return cross(ln.b - ln.a, a - ln.a) * cross(ln.b - ln.a, b - ln.a) < EPS;
}
// AOJ 2402 Milkey Way
inline bool intersects(const segment& seg) const
{
return ccw(a, b, seg.a) * ccw(a, b, seg.b) <= 0
&& ccw(seg.a, seg.b, a) * ccw(seg.a, seg.b, b) <= 0;
}
// AOJ 1171 Laser Beam Relections
inline P intersection(const line& ln) const
{
// assert(intersects(ln))
const P x = b - a;
const P y = ln.b - ln.a;
return a + x*(cross(y, ln.a - a))/cross(y, x);
}
inline bool parallel(const line& ln) const
{
return abs(cross(ln.b - ln.a, b - a)) < EPS;
}
// AOJ 2402 Milkey Way
inline double distance(const P& p) const
{
if (dot(b-a, p-a) < EPS) {
return abs(p-a);
} else if (dot(a-b, p-b) < EPS) {
return abs(p-b);
} else {
return abs(cross(b-a, p-a))/abs(b-a);
}
}
// AOJ 2402 Milkey Way
inline double distance(const segment& seg) const
{
if (intersects(seg)) {
return 0;
} else {
return
min(
min(distance(seg.a), distance(seg.b)),
min(seg.distance(a), seg.distance(b)));
}
}
};/*}}}*/
struct polygon/*{{{*/
{
vector<P> ps;
polygon() {}
polygon(const vector<P>& v) : ps(v) {}
inline int size() const { return ps.size(); }
inline void push_back(const P& p) { ps.push_back(p); }
inline P& operator[](int i) { return ps[i]; }
inline const P& operator[](int i) const { return ps[i]; }
double area() const
{
// positive if polygon is clockwise
double a = 0.0;
const int N = ps.size();
for (int i = 0; i < N; i++) {
a += cross(ps[(i+1)%N], ps[i]);
}
return a/2.0;
}
polygon cut(const line& ln) const
{
// cut out the left-side of the line
const int N = ps.size();
polygon ret;
for (int i = 0; i < N; i++) {
const segment seg(ps[i], ps[(i+1)%N]);
if (cross(ln.b - ln.a, ps[i] - ln.a) < EPS) {
// ps[i] is right-side of the line
ret.push_back(ps[i]);
if (!seg.parallel(ln) && seg.intersects(ln)) {
const P p = seg.intersection(ln);
if (abs(p - ps[i]) > EPS) {
ret.push_back(p);
}
}
} else if (!seg.parallel(ln) && seg.intersects(ln)) {
ret.push_back(seg.intersection(ln));
}
}
return ret;
}
};/*}}}*/
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int N;
while(cin >> N) {
if(!N) break;
printf("%d\n", N);
vector<P> points;
vector<double> angles;
TIMES(_, N) {
P point;
cin >> point.real() >> point.imag();
points.push_back(point);
double angle = arg(point);
if(angle > PI) angle -= PI;
angles.push_back(angle);
}
sort(angles.begin(), angles.end());
polygon poly(points);
const double target = poly.area() / 2;
TIMES(i, N) {
const int next = (i+1) % N;
const double area_l = poly.cut(line(P(0,0), points[i])).area();
const double area_r = poly.cut(line(P(0,0), points[next])).area();
if((area_l - target) * (area_r - target) <= 0) {
double l = angles[i], r = angles[next];
if(i == N-1) r += PI;
TIMES(_, 100) {
double center = (l+r) / 2;
double area = poly.cut(line(P(0,0), polar(10.0, center))).area();
if(area_l < area_r) {
if(area < target) l = center;
else r = center;
} else {
if(area < target) r = center;
else l = center;
}
}
P ans = polar(10.0, (l+r)/2);
if(EQV(poly.cut(line(P(0,0), ans)).area(), target)) {
printf("%.15f %.15f\n", ans.real(), ans.imag());
break;
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:193:17: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double')
193 | cin >> point.real() >> point.imag();
| ~~~ ^~ ~~~~~~~~~~~~
| | |
| | double
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:1:
/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:193:30: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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:193:30: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:193:30: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:193:30: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:193:30: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double'
193 | cin >> point.real() >> point.imag();
| ~~~~~~~~~~^~
/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>]'
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'double' to 'void*&'
328 | operator>>(void*& __p)
| ~~~~~~~^~~
/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>]'
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]'
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios |
s756136835 | p00674 | C++ | #include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define EPSILON 1e-9
#define ALL(x) (x).begin(), (x).end()
class point_t;
class vector_t {
public:
double x;
double y;
double z;
public:
vector_t(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {};
vector_t(const point_t& p);
public:
double operator[](int i) const {
return (i == 0) ? x : (i == 1) ? y : z;
};
double& operator[](int i) {
return (i == 0) ? x : (i == 1) ? y : z;
};
public:
vector_t operator-() const {
return vector_t(-x, -y, -z);
};
vector_t operator+(const vector_t& v) const {
return vector_t(x + v.x, y + v.y, z + v.z);
};
double operator*(const vector_t& v) const {
return x * v.x + y * v.y + z * v.z;
};
vector_t operator*(double a) const {
return vector_t(x * a, y * a, z * a);
};
vector_t operator/(double a) const {
return vector_t(x / a, y / a, z / a);
};
vector_t operator^(const vector_t& v) const {
return vector_t(y * v.z - z * v.y,
z * v.x - x * v.z,
x * v.y - y * v.x);
};
vector_t operator-=(const vector_t& v) {
x -= v.x;
y -= v.y;
z -= v.z;
return *this;
};
public:
double length() const {
return sqrt(*this * *this);
};
vector_t normal() const {
return *this / length();
};
};
class point_t {
public:
double x;
double y;
double z;
double w;
public:
point_t(double x = 0, double y = 0, double z = 0, double w = 1) : x(x), y(y), z(z), w(w) {};
point_t(const vector_t& v) : x(v.x), y(v.y), z(v.z), w(1) {};
public:
double operator[](int i) const {
return (i == 0) ? x : (i == 1) ? y : (i == 2) ? z : w;
};
double& operator[](int i) {
return (i == 0) ? x : (i == 1) ? y : (i == 2) ? z : w;
};
public:
point_t operator+(const vector_t& v) const {
return point_t(x + v.x, y + v.y, z + v.z);
};
vector_t operator-(const point_t& p) const {
return vector_t(x - p.x, y - p.y, z - p.z);
};
point_t operator-() const {
return point_t(-x, -y, -z, w);
};
point_t operator*(double a) const {
return point_t(x * a, y * a, y * a);
};
public:
friend point_t operator*(double a, const point_t& p) {
return p * a;
};
};
vector_t::vector_t(const point_t& p) : x(p.x / p.w), y(p.y / p.w), z(p.z / p.w)
{
}
class matrix_t
{
public:
matrix_t() {
identitize();
};
public:
const double* operator[](int i) const {
return matrix_[i];
};
double* operator[](int i) {
return matrix_[i];
};
public:
void identitize() {
memset(matrix_, 0, sizeof(matrix_));
matrix_[0][0] =
matrix_[1][1] =
matrix_[2][2] =
matrix_[3][3] = 1;
};
void transpose() {
for (int i = 0; i < 4; i ++)
for (int j = i + 1; j < 4; j ++)
if (i != j)
std::swap(matrix_[i][j], matrix_[j][i]);
};
public:
matrix_t operator*(const matrix_t& m) const {
matrix_t r;
for (int i = 0; i < 4; i ++)
for (int j = 0; j < 4; j ++)
r[i][j] =
matrix_[i][0] * m[0][j] +
matrix_[i][1] * m[1][j] +
matrix_[i][2] * m[2][j] +
matrix_[i][3] * m[3][j];
return r;
};
vector_t operator*(const vector_t& v) const {
vector_t r;
for (int i = 0; i < 3; i ++)
r[i] =
matrix_[i][0] * v.x +
matrix_[i][1] * v.y +
matrix_[i][2] * v.z +
matrix_[i][3];
return r;
};
point_t operator*(const point_t& p) const {
point_t r;
for (int i = 0; i < 4; i ++)
r[i] =
matrix_[i][0] * p.x +
matrix_[i][1] * p.y +
matrix_[i][2] * p.z +
matrix_[i][3] * p.w;
return r;
};
public:
static matrix_t translation(double x = 0, double y = 0, double z = 0) {
matrix_t m;
m[0][3] = x;
m[1][3] = y;
m[2][3] = z;
return m;
};
static matrix_t rotation(double theta = 0) {
matrix_t m;
m[0][0] = cos(theta);
m[0][1] = -sin(theta);
m[1][0] = sin(theta);
m[1][1] = cos(theta);
return m;
};
static matrix_t scale(double s = 1) {
matrix_t m;
m[0][0] = m[1][1] = m[2][2] = s;
return m;
};
private:
double matrix_[4][4];
};
class ccw_t : public std::unary_function<point_t, bool>
{
public:
ccw_t(const point_t& p0, const point_t& p1) : p0_(p0), a_(p1 - p0) {};
public:
bool operator()(const point_t& p) const {
vector_t b(p - p0_);
return (a_ ^ b).z > 0;
};
private:
point_t p0_;
vector_t a_;
};
class triangle_area
{
public:
double operator()(const vector_t& a, const vector_t& b) const {
return std::abs((a ^ b).z) / 2;
};
double operator()(const point_t& p0, const point_t& p1, const point_t& p2) const {
return (*this)(p1 - p0, p2 - p0);
};
};
class numeric_predictor : public std::binary_function<double, double, bool>
{
public:
numeric_predictor(double e = 1e-9) : e_(e) {};
public:
bool operator()(double a, double b) const {
return std::abs(a - b) < e_;
};
private:
double e_;
};
class angle_comparator : public std::binary_function<point_t, point_t, bool>
{
public:
bool operator()(const point_t& a, const point_t& b) const {
return normalize(atan2(a.y, a.x)) < normalize(atan2(b.y, b.x));
};
private:
double normalize(double a) const {
while (a < 0)
a += 2 * M_PI;
while (a >= 2 * M_PI)
a -= 2 * M_PI;
return a;
};
};
class extender
{
public:
std::vector<point_t> operator()(std::vector<point_t> points) const {
int size = points.size();
for (int i = 0; i < size; i ++)
points[i] = matrix_t::rotation(1) * points[i];
std::vector<double> a(size);
for (int i = 0; i < size; i ++)
a[i] = normalize(atan2(points[i].y, points[i].x));
std::sort(ALL(a));
a.erase(std::unique(ALL(a), numeric_predictor()), a.end());
std::vector<point_t> pts;
for (int i = 0; i < size; i ++) {
int j = (i + 1) % size;
vector_t v(points[j] - points[i]);
pts.push_back(points[i]);
for (int k = 0; k < a.size(); k ++) {
double A = tan(a[k]);
double t = -(points[i].x - points[i].y / A) / (v.x - v.y / A);
if (EPSILON < t && t < 1 - EPSILON)
pts.push_back(v * t + points[i]);
}
}
for (int i = 0, size = pts.size(); i < size; i ++)
pts[i] = matrix_t::rotation(-1) * pts[i];
std::sort(ALL(pts), angle_comparator());
return pts;
};
private:
double normalize(double a) const {
while (a < 0)
a += M_PI;
while (a >= M_PI)
a -= M_PI;
return a;
};
};
class solver
{
public:
solver(const std::vector<point_t>& points) : points_(points)
{
};
public:
point_t solve() {
points_ = extender()(points_);
int N = points_.size();
for (int i = 0; i < N / 2; i ++) {
int j = i + N / 2;
double a = 0, b = 0;
for (int k = 1; k < N / 2; k ++) {
b += triangle_area()(point_t(), points_[(i+k) % N], points_[(i+k+1) % N]);
a += triangle_area()(point_t(), points_[(j+k) % N], points_[(j+k+1) % N]);
}
double c, d, e, f;
c = a + triangle_area()(point_t(), points_[j], points_[(j+1) % N]);
d = a + triangle_area()(point_t(), points_[i], points_[(i+1) % N]);
e = b + triangle_area()(point_t(), points_[i], points_[(i+1) % N]);
f = b + triangle_area()(point_t(), points_[j], points_[(j+1) % N]);
if (std::abs(d + e - c - f) < EPSILON)
continue;
double t = (e - c) / (d + e - c -f);
if (0 <= t && t <= 1) {
point_t p((1-t) * points_[i] + t * points_[(i+1) % N]);
return vector_t(p).normal() * 1.1;
}
}
return vector_t(points_[0]).normal() * 1.1;
};
private:
std::vector<point_t> points_;
};
int main(int argc, char** argv)
{
while (1) {
int N;
std::cin >> N;
if (N == 0)
break;
std::vector<point_t> points(N);
for (int i = 0; i < N; i ++)
std::cin >> points[i].x >> points[i].y;
point_t p(solver(points).solve());
std::cout << std::fixed << std::setprecision(15) << p.x << ' ';
std::cout << std::fixed << std::setprecision(15) << p.y << std::endl;
}
return 0;
} | a.cc: In member function 'void matrix_t::identitize()':
a.cc:152:5: error: 'memset' was not declared in this scope
152 | memset(matrix_, 0, sizeof(matrix_));
| ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
6 | #include <vector>
+++ |+#include <cstring>
7 |
a.cc: At global scope:
a.cc:243:27: warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations]
243 | class ccw_t : public std::unary_function<point_t, bool>
| ^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:49,
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/iomanip:42,
from a.cc:4:
/usr/include/c++/14/bits/stl_function.h:117:12: note: declared here
117 | struct unary_function
| ^~~~~~~~~~~~~~
a.cc:275:39: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
275 | class numeric_predictor : public std::binary_function<double, double, bool>
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:131:12: note: declared here
131 | struct binary_function
| ^~~~~~~~~~~~~~~
a.cc:290:38: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
290 | class angle_comparator : public std::binary_function<point_t, point_t, bool>
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:131:12: note: declared here
131 | struct binary_function
| ^~~~~~~~~~~~~~~
|
s104704025 | p00675 | C++ | #include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;
typedef int Weight;
struct Edge {
int src, dst;
Weight weight;
Edge(int src, int dst, Weight weight) :
src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
vi k_shortestPath(const Graph &g, int s, int t, int k,int *h) {
int n=g.size();
vi dist[n];
priority_queue<Edge> Q; Q.push(Edge(-1, s, 0));
while (!Q.empty()) {
Edge e = Q.top(); Q.pop();
if (dist[e.dst].size() >= k) continue;
dist[e.dst].push_back(e.weight);
fr(f, g[e.dst]) Q.push(Edge(f->src, f->dst, f->weight+e.weight+h[f->src]-h[f->dst]));
}
rep(i,dist[t].size())dist[t][i]+=h[t]-h[s];
return dist[t];
}
int *buildFail(char *p) {
int m = strlen(p);
int *fail = new int[m+1];
int j = fail[0] = -1;
for (int i = 1; i <= m; ++i) {
while (j >= 0 && p[j] != p[i-1]) j = fail[j];
fail[i] = ++j;
}
return fail;
}
void dfs(int c,const Graph &g,bool *v){
v[c]=1;
fr(i,g[c])if(!v[i->dst])dfs(i->dst,g,v);
}
bool calc_potential(){
fill(h,h+V+1,0);
rep(k,V)rep(i,V)if(v[i]&&rv[i])fr(e,G[i]){
if(h[e->dst]>h[e->src]+e->weight){
h[e->dst]=h[e->src]+e->weight;
if(k==V-1)return 0;
}
}
return 1;
}
inline void push(Graph &g,int src,int dst,int weight){
g[src].pb(Edge(src,dst,weight));
}
bool make_graph(){
int *fail=buildFail(ptn), len=strlen(ptn);
G.clear(); rG.clear();
V=n*(len+1)+1;
s=0; t=V-1;
while(s>=0&&ptn[s]-'0'!=col[0])s=fail[s];
if(++s>=len)return 0;
G.resize(V); rG.resize(V);
vector<vector<pi> > e(n);
rep(i,m)e[a[i]-1].pb(mp(b[i]-1,c[i]));
rep(i,n)rep(j,len+1){
fr(k,e[i]){
int to=j;
while(to>=0&&ptn[to]-'0'!=col[k->first])to=fail[to];
if(++to>=len)continue;
push(G,i*(len+1)+j,k->first*(len+1)+to,k->second);
push(rG,k->first*(len+1)+to,i*(len+1)+j,0);
}
}
rep(j,len){
push(G,(n-1)*(len+1)+j,t,0);
push(rG,t,(n-1)*(len+1)+j,0);
}
rep(i,V)v[i]=rv[i]=0;
dfs(s,G,v); dfs(t,rG,rv);
return v[t]&&rv[s];
}
int n,col[100],m,a[1000],b[1000],c[1000],k;
char ptn[20];
int V,s,t,h[1111];
Graph G,rG;
bool v[1111],rv[1111];
int main(){
while(cin>>n,n){
rep(i,n)cin>>col[i];
cin>>m;
rep(i,m)cin>>a[i]>>b[i]>>c[i];
cin>>k>>ptn;
if(!make_graph()){
cout<<"0 0"<<endl; continue;
}
if(!calc_potential()){
cout<<-1<<endl; continue;
}
vi ans=k_shortestPath(G,s,t,k,h);
int sum=0;
rep(i,ans.size())sum+=ans[i];
cout<<ans.size()<<" "<<sum<<endl;
}
return 0;
} | a.cc: In function 'bool calc_potential()':
a.cc:73:14: error: 'h' was not declared in this scope
73 | fill(h,h+V+1,0);
| ^
a.cc:73:18: error: 'V' was not declared in this scope
73 | fill(h,h+V+1,0);
| ^
a.cc:74:28: error: 'v' was not declared in this scope
74 | rep(k,V)rep(i,V)if(v[i]&&rv[i])fr(e,G[i]){
| ^
a.cc:74:34: error: 'rv' was not declared in this scope
74 | rep(k,V)rep(i,V)if(v[i]&&rv[i])fr(e,G[i]){
| ^~
a.cc:74:45: error: 'G' was not declared in this scope
74 | rep(k,V)rep(i,V)if(v[i]&&rv[i])fr(e,G[i]){
| ^
a.cc:16:30: note: in definition of macro 'fr'
16 | #define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
| ^
a.cc:75:23: error: base operand of '->' is not a pointer
75 | if(h[e->dst]>h[e->src]+e->weight){
| ^~
a.cc:75:33: error: base operand of '->' is not a pointer
75 | if(h[e->dst]>h[e->src]+e->weight){
| ^~
a.cc:75:41: error: base operand of '->' is not a pointer
75 | if(h[e->dst]>h[e->src]+e->weight){
| ^~
a.cc:76:28: error: base operand of '->' is not a pointer
76 | h[e->dst]=h[e->src]+e->weight;
| ^~
a.cc:76:38: error: base operand of '->' is not a pointer
76 | h[e->dst]=h[e->src]+e->weight;
| ^~
a.cc:76:46: error: base operand of '->' is not a pointer
76 | h[e->dst]=h[e->src]+e->weight;
| ^~
a.cc: In function 'bool make_graph()':
a.cc:86:29: error: 'ptn' was not declared in this scope
86 | int *fail=buildFail(ptn), len=strlen(ptn);
| ^~~
a.cc:87:9: error: 'G' was not declared in this scope
87 | G.clear(); rG.clear();
| ^
a.cc:87:20: error: 'rG' was not declared in this scope
87 | G.clear(); rG.clear();
| ^~
a.cc:88:9: error: 'V' was not declared in this scope
88 | V=n*(len+1)+1;
| ^
a.cc:88:11: error: 'n' was not declared in this scope; did you mean 'yn'?
88 | V=n*(len+1)+1;
| ^
| yn
a.cc:88:14: error: 'len' was not declared in this scope
88 | V=n*(len+1)+1;
| ^~~
a.cc:89:9: error: 's' was not declared in this scope
89 | s=0; t=V-1;
| ^
a.cc:89:14: error: 't' was not declared in this scope; did you mean 'tm'?
89 | s=0; t=V-1;
| ^
| tm
a.cc:90:33: error: 'col' was not declared in this scope; did you mean 'cosl'?
90 | while(s>=0&&ptn[s]-'0'!=col[0])s=fail[s];
| ^~~
| cosl
a.cc:95:15: error: 'm' was not declared in this scope
95 | rep(i,m)e[a[i]-1].pb(mp(b[i]-1,c[i]));
| ^
a.cc:15:37: note: in definition of macro 'rep'
15 | #define rep(i,n) for(int i=0;i<(int)n;i++)
| ^
a.cc:95:19: error: 'a' was not declared in this scope
95 | rep(i,m)e[a[i]-1].pb(mp(b[i]-1,c[i]));
| ^
a.cc:95:33: error: 'b' was not declared in this scope
95 | rep(i,m)e[a[i]-1].pb(mp(b[i]-1,c[i]));
| ^
a.cc:95:40: error: 'c' was not declared in this scope
95 | rep(i,m)e[a[i]-1].pb(mp(b[i]-1,c[i]));
| ^
a.cc:100:51: error: 'col' was not declared in this scope; did you mean 'cosl'?
100 | while(to>=0&&ptn[to]-'0'!=col[k->first])to=fail[to];
| ^~~
| cosl
a.cc:110:17: error: 'v' was not declared in this scope
110 | rep(i,V)v[i]=rv[i]=0;
| ^
a.cc:110:22: error: 'rv' was not declared in this scope
110 | rep(i,V)v[i]=rv[i]=0;
| ^~
a.cc:111:17: error: 'v' was not declared in this scope
111 | dfs(s,G,v); dfs(t,rG,rv);
| ^
a.cc:111:30: error: 'rv' was not declared in this scope
111 | dfs(s,G,v); dfs(t,rG,rv);
| ^~
|
s288581449 | p00675 | C++ | #include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef int Weight;
struct Edge {
  int src;
  int dest;
  Weight weight;
  Edge(int src, int dest, Weight weight) : src(src), dest(dest), weight(weight) {;}
  bool operator<(const Edge &rhs) const {
    return weight > rhs.weight;
  }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void PrintMatrix(const Matrix &matrix) {
  for (int y = 0; y < (int)matrix.size(); y++) {
    for (int x = 0; x < (int)matrix[y].size(); x++) {
      printf("%d ", matrix[y][x]);
    }
    puts("");
  }
}
bool end[1100];
static const Weight INF = 2000000000LL;
Weight BellmanFord(const Graph &g, Array &dist) {
  const int n = g.size();
  dist = Array(n, 0x0f0f0f0f);
  dist[0] = 0;
  REP(iter, n) {
    bool e = true;
    REP(i, n) {
      REP(j, g[i].size()) {
        int to = g[i][j].dest;
        Weight ncost = dist[i] + g[i][j].weight;
        if (dist[to] > ncost) {
          dist[to] = ncost;
          e = false;
        }
      }
    }
    if (e) { return 0; }
  }
  return -INF;
}
int n, m, k, len;
int color[110];
char ban[1000];
int memo[20][20];
int OneMove(int pattern, int c) {
  if (ban[pattern] == c) { return pattern + 1; }
  if (memo[pattern][c] != -1) { return memo[pattern][c]; }
  deque<int> now;
  REP(i, pattern) { now.push_back(ban[i]); }
  now.push_back(c);
  while (!now.empty()) {
    now.pop_front();
    REP(i, now.size()) {
      if (now[i] != ban[i]) { goto next; }
    }
    break;
next:;
  }
  return memo[pattern][c] = now.size();
}
Graph Expand(Graph g) {
  MEMSET(memo, -1);
  vector<bool> visit(n * len, false);
  queue<pair<int, int> > que;
  int first = color[0] == ban[0] ? 1 : 0;
  que.push(make_pair(0, first));
  Graph ret(n * len);
  if (len == first) { return ret; }
  while (!que.empty()) {
    int from = que.front().first;
    int pattern = que.front().second;
    que.pop();
    if (visit[from * len + pattern]) { continue; }
    visit[from * len + pattern] = true;
    FORIT(it, g[from]) {
      int to = it->dest;
      int c = color[to];
      int npattern = OneMove(pattern, c);
      if (npattern == len) { continue; }
      ret[from * len + pattern].push_back(Edge(from * len + pattern, to * len + npattern, it->weight));
      que.push(make_pair(to, npattern));
    }
  }
  return ret;
}
Graph revG(Graph g) {
  Graph ret(g.size());
  REP(i, g.size()) {
    FORIT(it, g[i]) {
      ret[it->dest].push_back(Edge(it->dest, it->src, it->weight));
    }
  }
  return ret;
}
void dfs(const Graph &g, int from, vector<bool> &visit) {
  if (visit[from]) { return; }
  visit[from] = true;
  FORIT(it, g[from]) {
    dfs(g, it->dest, visit);
  }
}
Graph Erase(Graph g) {
  MEMSET(end, false);
  vector<bool> visit1(1010, 0);
  vector<bool> visit2(1010, 0);
  Graph rev = revG(g);
  dfs(g, color[0] == ban[0], visit1);
  if (len == 1 && color[0] == ban[0]) { visit1[1] = false; }
  REP(i, len) { dfs(rev, (n - 1) * len + i, visit2); }
  int m = 0;
  map<int, int> mapto;
  REP(i, n * len) {
    if (!visit1[i] || !visit2[i]) { continue; }
    if (i >= (n - 1) * len) { end[m] = true; }
    mapto[i] = m++;
  }
  Graph ret(m);
  REP(i, n * len) {
    if (!mapto.count(i)) { continue; }
    int from = mapto[i];
    FORIT(it, g[i]) {
      if (!mapto.count(it->dest)) { continue; }
      int to = mapto[it->dest];
      ret[from].push_back(Edge(from, to, it->weight));
    }
  }
  return ret;
}
vector<int> dists[1010];
pair<int, int> calc(const Graph &g) {
  if (g.size() == 0) { return make_pair(0, 0); }
  Array dist;
  int v = BellmanFord(g, dist);
  if (v == -INF) { return make_pair(-1, -1); }
  priority_queue<Edge> que;
  que.push(Edge(0, 0, 0));
  REP(i, 1010) { dists[i].clear(); }
  vector<int> ans;
  while (!que.empty()) {
    Edge e = que.top();
    que.pop();
    int from = e.dest;
    if ((int)dists[from].size() == k) { continue; }
    dists[from].push_back(e.weight);
    if (end[from]) { ans.push_back(e.weight + dist[from]); }
    FORIT(it, g[from]) {
      int to = it->dest;
      int ncost = it->weight + e.weight + (dist[from] - dist[to]);
      que.push(Edge(from, to, ncost));
    }
  }
  pair<int, int> ret = make_pair(0, 0);
  sort(ans.begin(), ans.end());
  ret.first = min(k, (int)ans.size());
  REP(i, ret.first) { ret.second += ans[i]; }
  return ret;
}
int main() {
  while (scanf("%d", &n), n) {
    REP(i, n) { scanf("%d", &color[i]); }
    scanf("%d", &m);
    Graph g(n);
    REP(i, m) {
      int f, t, c;
      scanf("%d %d %d", &f, &t, &c);
      f--; t--;
      g[f].push_back(Edge(f, t, c));
    }
    scanf("%d", &k);
    scanf("%s", ban);
    len = strlen(ban);
    REP(i, len) { ban[i] -= '0'; }
    g = Expand(g);
    g = Erase(g);
    pair<int, int> ans = calc(g);
    if (ans.first == -1) {
      puts("-1");
    } else {
      printf("%d %d\n", ans.first, ans.second);
    }
  }
} | a.cc:37:2: error: stray '#' in program
37 |   int src;
| ^
a.cc:38:2: error: stray '#' in program
38 |   int dest;
| ^
a.cc:39:2: error: stray '#' in program
39 |   Weight weight;
| ^
a.cc:40:2: error: stray '#' in program
40 |   Edge(int src, int dest, Weight weight) : src(src), dest(dest), weight(weight) {;}
| ^
a.cc:41:2: error: stray '#' in program
41 |   bool operator<(const Edge &rhs) const {
| ^
a.cc:42:2: error: stray '#' in program
42 |     return weight > rhs.weight;
| ^
a.cc:42:9: error: stray '#' in program
42 |     return weight > rhs.weight;
| ^
a.cc:43:2: error: stray '#' in program
43 |   }
| ^
a.cc:54:2: error: stray '#' in program
54 |   for (int y = 0; y < (int)matrix.size(); y++) {
| ^
a.cc:55:2: error: stray '#' in program
55 |     for (int x = 0; x < (int)matrix[y].size(); x++) {
| ^
a.cc:55:9: error: stray '#' in program
55 |     for (int x = 0; x < (int)matrix[y].size(); x++) {
| ^
a.cc:56:2: error: stray '#' in program
56 |       printf("%d ", matrix[y][x]);
| ^
a.cc:56:9: error: stray '#' in program
56 |       printf("%d ", matrix[y][x]);
| ^
a.cc:56:16: error: stray '#' in program
56 |       printf("%d ", matrix[y][x]);
| ^
a.cc:57:2: error: stray '#' in program
57 |     }
| ^
a.cc:57:9: error: stray '#' in program
57 |     }
| ^
a.cc:58:2: error: stray '#' in program
58 |     puts("");
| ^
a.cc:58:9: error: stray '#' in program
58 |     puts("");
| ^
a.cc:59:2: error: stray '#' in program
59 |   }
| ^
a.cc:68:2: error: stray '#' in program
68 |   const int n = g.size();
| ^
a.cc:69:2: error: stray '#' in program
69 |   dist = Array(n, 0x0f0f0f0f);
| ^
a.cc:70:2: error: stray '#' in program
70 |   dist[0] = 0;
| ^
a.cc:71:2: error: stray '#' in program
71 |   REP(iter, n) {
| ^
a.cc:72:2: error: stray '#' in program
72 |     bool e = true;
| ^
a.cc:72:9: error: stray '#' in program
72 |     bool e = true;
| ^
a.cc:73:2: error: stray '#' in program
73 |     REP(i, n) {
| ^
a.cc:73:9: error: stray '#' in program
73 |     REP(i, n) {
| ^
a.cc:74:2: error: stray '#' in program
74 |       REP(j, g[i].size()) {
| ^
a.cc:74:9: error: stray '#' in program
74 |       REP(j, g[i].size()) {
| ^
a.cc:74:16: error: stray '#' in program
74 |       REP(j, g[i].size()) {
| ^
a.cc:75:2: error: stray '#' in program
75 |         int to = g[i][j].dest;
| ^
a.cc:75:9: error: stray '#' in program
75 |         int to = g[i][j].dest;
| ^
a.cc:75:16: error: stray '#' in program
75 |         int to = g[i][j].dest;
| ^
a.cc:75:23: error: stray '#' in program
75 |         int to = g[i][j].dest;
| ^
a.cc:76:2: error: stray '#' in program
76 |         Weight ncost = dist[i] + g[i][j].weight;
| ^
a.cc:76:9: error: stray '#' in program
76 |         Weight ncost = dist[i] + g[i][j].weight;
| ^
a.cc:76:16: error: stray '#' in program
76 |         Weight ncost = dist[i] + g[i][j].weight;
| ^
a.cc:76:23: error: stray '#' in program
76 |         Weight ncost = dist[i] + g[i][j].weight;
| ^
a.cc:77:2: error: stray '#' in program
77 |         if (dist[to] > ncost) {
| ^
a.cc:77:9: error: stray '#' in program
77 |         if (dist[to] > ncost) {
| ^
a.cc:77:16: error: stray '#' in program
77 |         if (dist[to] > ncost) {
| ^
a.cc:77:23: error: stray '#' in program
77 |         if (dist[to] > ncost) {
| ^
a.cc:78:2: error: stray '#' in program
78 |           dist[to] = ncost;
| ^
a.cc:78:9: error: stray '#' in program
78 |           dist[to] = ncost;
| ^
a.cc:78:16: error: stray '#' in program
78 |           dist[to] = ncost;
| ^
a.cc:78:23: error: stray '#' in program
78 |           dist[to] = ncost;
| ^
a.cc:78:30: error: stray '#' in program
78 |           dist[to] = ncost;
| ^
a.cc:79:2: error: stray '#' in program
79 |           e = false;
| ^
a.cc:79:9: error: stray '#' in program
79 |           e = false;
| ^
a.cc:79:16: error: stray '#' in program
79 |           e = false;
| ^
a.cc:79:23: error: stray '#' in program
79 |           e = false;
| ^
a.cc:79:30: error: stray '#' in program
79 |           e = false;
| ^
a.cc:80:2: error: stray '#' in program
80 |         }
| ^
a.cc:80:9: error: stray '#' in program
80 |         }
| ^
a.cc:80:16: error: stray '#' in program
80 |         }
| ^
a.cc:80:23: error: stray '#' in program
80 |         }
| ^
a.cc:81:2: error: stray '#' in program
81 |       }
| ^
a.cc:81:9: error: stray '#' in program
81 |       }
| ^
a.cc:81:16: error: stray '#' in program
81 |       }
| ^
a.cc:82:2: error: stray '#' in program
82 |     }
| ^
a.cc:82:9: error: stray '#' in program
82 |     }
| ^
a.cc:83:2: error: stray '#' in program
83 |     if (e) { return 0; }
| ^
a.cc:83:9: error: stray '#' in program
83 |     if (e) { return 0; }
| ^
a.cc:84:2: error: stray '#' in program
84 |   }
| ^
a.cc:85:2: error: stray '#' in program
85 |   return -INF;
| ^
a.cc:100:2: error: stray '#' in program
100 |   if (ban[pattern] == c) { return pattern + 1; }
| ^
a.cc:101:2: error: stray '#' in program
101 |   if (memo[pattern][c] != -1) { return memo[pattern][c]; }
| ^
a.cc:102:2: error: stray '#' in program
102 |   deque<int> now;
| ^
a.cc:103:2: error: stray '#' in program
103 |   REP(i, pattern) { now.push_back(ban[i]); }
| ^
a.cc:104:2: error: stray '#' in program
104 |   now.push_back(c);
| ^
a.cc:105:2: error: stray '#' in program
105 |   while (!now.empty()) {
| ^
a.cc:106:2: error: stray '#' in program
106 |     now.pop_front();
| ^
a.cc:106:9: error: stray '#' in program
106 |     now.pop_front();
| ^
a.cc:107:2: error: stray '#' in program
107 |     REP(i, now.size()) {
| ^
a.cc:107:9: error: stray '#' in program
107 |     REP(i, now.size()) {
| ^
a.cc:108:2: error: stray '#' in program
108 |       if (now[i] != ban[i]) { goto next; }
| ^
a.cc:108:9: error: stray '#' in program
108 |       if (now[i] != ban[i]) { goto next; }
| ^
a.cc:108:16: error: stray '#' in program
108 |       if (now[i] != ban[i]) { goto next; }
| ^
a.cc:109:2: error: stray '#' in program
109 |     }
| ^
a.cc:109:9: error: stray '#' in program
109 |     }
| ^
a.cc:110:2: error: stray '#' in program
110 |     break;
| ^
a.cc:110:9: error: stray '#' in program
110 |     break;
| ^
a.cc:112:2: error: stray '#' in program
112 |   }
| ^
a.cc:113:2: error: stray '#' in program
113 |   return memo[pattern][c] = now.size();
| ^
a.cc:120:2: error: stray '#' in program
120 |   MEMSET(memo, -1);
| ^
a.cc:121:2: error: stray '#' in program
121 |   vector<bool> visit(n * len, false);
| ^
a.cc:122:2: error: stray '#' in program
122 |   queue<pair<int, int> > que;
| ^
a.cc:123:2: error: stray '#' in program
123 |   int first = color[0] == ban[0] ? 1 : 0;
| ^
a.cc:124:2: error: stray '#' in program
124 |   que.push(make_pair(0, first));
| ^
a.cc:125:2: error: stray '#' in program
125 |   Graph ret(n * len);
| ^
a.cc:126:2: error: stray '#' in program
126 |   if (len == first) { return ret; }
| ^
a.cc:127:2: error: stray '#' in program
127 |   while (!que.empty()) {
| ^
a.cc:128:2: error: stray '#' in program
128 |     int from = que.front().first;
| ^
a.cc:128:9: error: stray '#' in program
128 |     int from = que.front().first;
| ^
a.cc:129:2: error: stray '#' in program
129 |     int pattern = que.front().second;
| ^
a.cc:129:9: error: stray '#' in program
129 |     int pattern = que.front().second;
| ^
a.cc:130:2: error: stray '#' in program
130 |     que.pop();
| ^
a.cc:130:9: error: stray '#' in program
130 |     que.pop();
| ^
a.cc:131:2: error: stray '#' in program
131 |     if (visit[from * len + pattern]) { continue; }
| ^
a.cc:131:9: error: stray '#' in program
131 |     if (visit[from * len + pattern]) { continue; }
| ^
a.cc:1 |
s688445027 | p00676 | C | $<.each{|s| a,b,c=s.split.map{|x|x.to_f};p Math.sqrt(4*b*b-a*a)*a/4+Math.sqrt(c*c+2*b*c)*b/2} | main.c:1:2: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
1 | $<.each{|s| a,b,c=s.split.map{|x|x.to_f};p Math.sqrt(4*b*b-a*a)*a/4+Math.sqrt(c*c+2*b*c)*b/2}
| ^
|
s166786686 | p00676 | C++ | #include <iostream>
#include <iomanip>
using namespace std;
int main() {
fixed(cout);
cout << setprecision(13);
while (!cin.eof()) {
long a,l,x;
cin >> a >> l >> x;
auto h_1 = sqrt(l * l - a * a / 4.0);
auto h_2 = sqrt((x + l) * (x + l) / 4.0 - l * l / 4.0);
cout << h_1 << endl;
cout << h_2 << endl;
cout << a * h_1 / 2 + l * h_2 << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:28: error: 'sqrt' was not declared in this scope
10 | auto h_1 = sqrt(l * l - a * a / 4.0);
| ^~~~
|
s763029583 | p00676 | C++ | #include <iostream>
#include <iomanip>
using namespace std;
int main() {
fixed(cout);
cout << setprecision(13);
while (!cin.eof()) {
long a,l,x;
cin >> a >> l >> x;
double h_1 = sqrt(l * l - a * a / 4.0);
double h_2 = sqrt((x + l) * (x + l) / 4.0 - l * l / 4.0);
cout << h_1 << endl;
cout << h_2 << endl;
cout << a * h_1 / 2 + l * h_2 << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:22: error: 'sqrt' was not declared in this scope
10 | double h_1 = sqrt(l * l - a * a / 4.0);
| ^~~~
|
s397985442 | p00676 | C++ | #include <iostream>
#include <iomanip>
using namespace std;
int main() {
fixed(cout);
cout << setprecision(13);
while (!cin.eof()) {
long a,l,x;
cin >> a >> l >> x;
auto h_1 = sqrt<double>(l * l - a * a / 4.0);
auto h_2 = sqrt<double>((x + l) * (x + l) / 4.0 - l * l / 4.0);
cout << h_1 << endl;
cout << h_2 << endl;
cout << a * h_1 / 2 + l * h_2 << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:20: error: 'sqrt' was not declared in this scope
10 | auto h_1 = sqrt<double>(l * l - a * a / 4.0);
| ^~~~
a.cc:10:25: error: expected primary-expression before 'double'
10 | auto h_1 = sqrt<double>(l * l - a * a / 4.0);
| ^~~~~~
a.cc:11:25: error: expected primary-expression before 'double'
11 | auto h_2 = sqrt<double>((x + l) * (x + l) / 4.0 - l * l / 4.0);
| ^~~~~~
|
s284584286 | p00676 | C++ |
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double a,l,x;
double s;
cout<<setprecision(10)<<setiosflags(ios::fixed);
while(cin>>a>>l>>x){
x+=l;
s = sqrt(l*l - a*a/4.0) * a / 2.0;
s += sqrt(x*x/4.0 - l*l/4.0) * l;
cout<<s<<endl;
}
} | a.cc: In function 'int main()':
a.cc:10:9: error: 'setprecision' was not declared in this scope
10 | cout<<setprecision(10)<<setiosflags(ios::fixed);
| ^~~~~~~~~~~~
a.cc:4:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
3 | #include<cmath>
+++ |+#include <iomanip>
4 | using namespace std;
a.cc:10:27: error: 'setiosflags' was not declared in this scope
10 | cout<<setprecision(10)<<setiosflags(ios::fixed);
| ^~~~~~~~~~~
a.cc:10:27: note: 'std::setiosflags' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
|
s186375959 | p00676 | C++ | #include<cstdio>
#include<math>
main(){for(float a,l,x;~scanf("%f%f%f",&a,&l,&x);printf("%.9f\n",sqrt(l*l-a*a/4)*a/2+sqrt(x*x/4-l*l/4)*l))x+=l;} | a.cc:2:9: fatal error: math: No such file or directory
2 | #include<math>
| ^~~~~~
compilation terminated.
|
s810517359 | p00676 | C++ | #include<cmath>
main(){for(float a,l,x;~scanf("%f%f%f",&a,&l,&x);printf("%.9f\n",sqrt(l*l-a*a/4)*a/2+sqrt(x*x/4-l*l/4)*l))x+=l;} | a.cc:2:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
2 | main(){for(float a,l,x;~scanf("%f%f%f",&a,&l,&x);printf("%.9f\n",sqrt(l*l-a*a/4)*a/2+sqrt(x*x/4-l*l/4)*l))x+=l;}
| ^~~~
a.cc: In function 'int main()':
a.cc:2:25: error: 'scanf' was not declared in this scope
2 | main(){for(float a,l,x;~scanf("%f%f%f",&a,&l,&x);printf("%.9f\n",sqrt(l*l-a*a/4)*a/2+sqrt(x*x/4-l*l/4)*l))x+=l;}
| ^~~~~
a.cc:2:50: error: 'printf' was not declared in this scope
2 | main(){for(float a,l,x;~scanf("%f%f%f",&a,&l,&x);printf("%.9f\n",sqrt(l*l-a*a/4)*a/2+sqrt(x*x/4-l*l/4)*l))x+=l;}
| ^~~~~~
a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
1 | #include<cmath>
+++ |+#include <cstdio>
2 | main(){for(float a,l,x;~scanf("%f%f%f",&a,&l,&x);printf("%.9f\n",sqrt(l*l-a*a/4)*a/2+sqrt(x*x/4-l*l/4)*l))x+=l;}
|
s615332708 | p00676 | C++ | #include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;
int main() {
double a, l, x;
while(cin>>a>>l>>x) {
double s = (a+l+l)/2;
double S = sqrt(s*(s-a)*(s-l)*(s-l));
x = (l+x)/2;
s = (l+x+x)/2;
S += 2*sqrt(s*(s-l)*(s-x)*(s-x));
printf("%.10f\n", S);
}
} | a.cc: In function 'int main()':
a.cc:20:9: error: 'cin' was not declared in this scope
20 | while(cin>>a>>l>>x) {
| ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
4 | #include <stack>
+++ |+#include <iostream>
5 | using namespace std;
|
s879662807 | p00676 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main() {
double a, l, x;
cout.precision(10);
while (cin >> a >> l >> x) {
double area = sqrt(l * l - a * a / 4.0) * a / 2.0 + sqrt((l + x) * (l + x) / 4.0 - l * l / 4.0) * l;
cout << fixed << area << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:31: error: 'sqrt' was not declared in this scope
10 | double area = sqrt(l * l - a * a / 4.0) * a / 2.0 + sqrt((l + x) * (l + x) / 4.0 - l * l / 4.0) * l;
| ^~~~
|
s865128719 | p00677 | Java | public class Main {
static int s;
static int d;
static int m;
static Map<Integer,Kanmi> Fmap = new HashMap<>();
public static void main(String[] args) {
while(true){
Scanner scan = new Scanner(System.in);
String s = scan.next();
if(s.equals("EOF")){
break;
}
Main.s = new Integer(s);
Main.d = scan.nextInt();
Main.m = scan.nextInt();
ArrayList<Kanmi> list = new ArrayList<>();
for(int i = 0;i < Main.s;i++){
ArrayList<Integer[]> wp = new ArrayList<>();
int k = scan.nextInt();
for(int j = 0;j < k;j++){
wp.add(new Integer[]{scan.nextInt(),scan.nextInt()});
}
list.add(new Kanmi(k,wp));
}
for(int i = 0;i < Main.d;i++){
Main.Fmap.put(i,list.get(scan.nextInt()));
Main.dp.put(i,new HashMap<>());
}
int[] ans = Main.rec(0,Main.m, 0);
System.out.println(ans[1] + " " + (Main.m - ans[0]));
}
}
static Map<Integer,Map<Integer,int[]>> dp = new HashMap<>();
public static int[] rec(int day,int money,int weight){
if(money < 0){
return new int[]{Integer.MAX_VALUE,0};
}
if(day >= Main.d){
return new int[]{money,weight};
}
if(Main.dp.get(day).containsKey(money)){
return Main.dp.get(day).get(money);
}
int[] max = new int[]{Integer.MAX_VALUE,0};
for(Integer[] e : Main.Fmap.get(day).wp){
int[] r = Main.rec(day+1, money-e[1], weight+e[0]);
if(max[1] <= r[1] && max[0] > r[0]){
max = r;
}
}
Main.dp.get(day).put(money, max);
return max;
}
static class Kanmi{
int k;
ArrayList<Integer[]> wp;
public Kanmi(int k,ArrayList<Integer[]> wp){
this.k = k;
this.wp = wp;
}
}
} | Main.java:5: error: cannot find symbol
static Map<Integer,Kanmi> Fmap = new HashMap<>();
^
symbol: class Map
location: class Main
Main.java:33: error: cannot find symbol
static Map<Integer,Map<Integer,int[]>> dp = new HashMap<>();
^
symbol: class Map
location: class Main
Main.java:33: error: cannot find symbol
static Map<Integer,Map<Integer,int[]>> dp = new HashMap<>();
^
symbol: class Map
location: class Main
Main.java:56: error: cannot find symbol
ArrayList<Integer[]> wp;
^
symbol: class ArrayList
location: class Kanmi
Main.java:57: error: cannot find symbol
public Kanmi(int k,ArrayList<Integer[]> wp){
^
symbol: class ArrayList
location: class Kanmi
Main.java:5: error: cannot find symbol
static Map<Integer,Kanmi> Fmap = new HashMap<>();
^
symbol: class HashMap
location: class Main
Main.java:8: error: cannot find symbol
Scanner scan = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:8: error: cannot find symbol
Scanner scan = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:13: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal
Main.s = new Integer(s);
^
Main.java:16: error: cannot find symbol
ArrayList<Kanmi> list = new ArrayList<>();
^
symbol: class ArrayList
location: class Main
Main.java:16: error: cannot find symbol
ArrayList<Kanmi> list = new ArrayList<>();
^
symbol: class ArrayList
location: class Main
Main.java:18: error: cannot find symbol
ArrayList<Integer[]> wp = new ArrayList<>();
^
symbol: class ArrayList
location: class Main
Main.java:18: error: cannot find symbol
ArrayList<Integer[]> wp = new ArrayList<>();
^
symbol: class ArrayList
location: class Main
Main.java:27: error: cannot find symbol
Main.dp.put(i,new HashMap<>());
^
symbol: class HashMap
location: class Main
Main.java:33: error: cannot find symbol
static Map<Integer,Map<Integer,int[]>> dp = new HashMap<>();
^
symbol: class HashMap
location: class Main
14 errors
1 warning
|
s994576267 | p00677 | Java | import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
static int s;
static int d;
static int m;
static Map<Integer,Kanmi> Fmap = new HashMap<>();
public void solve(){
Scanner scan = new Scanner(System.in);
while(scan.hasNextLine()){
Main.s = scan.nextInt();
Main.d = scan.nextInt();
Main.m = scan.nextInt();
ArrayList<Kanmi> list = new ArrayList<>();
for(int i = 0;i < Main.s;i++){
ArrayList<Integer[]> wp = new ArrayList<>();
int k = scan.nextInt();
for(int j = 0;j < k;j++){
wp.add(new Integer[]{scan.nextInt(),scan.nextInt()});
}
list.add(new Kanmi(k,wp));
}
Main.Fmap.clear();
Main.dp.clear();
for(int i = 0;i < Main.d;i++){
Main.Fmap.put(i,list.get(scan.nextInt()));
Main.dp.put(i,new HashMap<>());
}
int[] ans = Main.rec(0,Main.m, 0);
System.out.println(ans[1] + " " + (Main.m - ans[0]));
scan.next();
}
scan.close();
}
public static void main(String[] args) {
new Main().solve();
System.exit(0);
}
static Map<Integer,Map<Integer,int[]>> dp = new HashMap<>();
public static int[] rec(int day,int money,int weight){
if(money < 0){
return new int[]{Integer.MAX_VALUE,0};
}
if(day >= Main.d){
return new int[]{money,weight};
}
if(Main.dp.get(day).containsKey(money)){
return Main.dp.get(day).get(money);
}
int[] max = new int[]{Integer.MAX_VALUE,0};
for(Integer[] e : Main.Fmap.get(day).wp){
int[] r = Main.rec(day+1, money-e[1], weight+e[0]);
if(max[1] <= r[1] && max[0] > r[0]){
max = r;
}
}
Main.dp.get(day).put(money, max);
return max;
}
static class Kanmi{
int k;
ArrayList<Integer[]> wp;
public Kanmi(int k,ArrayList<Integer[]> wp){
this.k = k;
this.wp = wp;
}
} | Main.java:70: error: reached end of file while parsing
}
^
1 error
|
s208768731 | p00677 | C++ | import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
static int s;
static int d;
static int m;
static Map<Integer,Kanmi> Fmap = new HashMap<>();
public static int main(String[] args) {
while(true){
Scanner scan = new Scanner(System.in);
Main.s = scan.nextInt();
if(Main.s < 0){break;}
Main.d = scan.nextInt();
Main.m = scan.nextInt();
ArrayList<Kanmi> list = new ArrayList<>();
for(int i = 0;i < Main.s;i++){
ArrayList<Integer[]> wp = new ArrayList<>();
int k = scan.nextInt();
for(int j = 0;j < k;j++){
wp.add(new Integer[]{scan.nextInt(),scan.nextInt()});
}
list.add(new Kanmi(k,wp));
}
for(int i = 0;i < Main.d;i++){
Main.Fmap.put(i,list.get(scan.nextInt()));
Main.dp.put(i,new HashMap<>());
}
int[] ans = Main.rec(0,Main.m, 0);
System.out.println(ans[1] + " " + (Main.m - ans[0]));
//break;
}
return 0;
}
static Map<Integer,Map<Integer,int[]>> dp = new HashMap<>();
public static int[] rec(int day,int money,int weight){
if(money < 0){
return new int[]{Integer.MAX_VALUE,0};
}
if(day >= Main.d){
return new int[]{money,weight};
}
if(Main.dp.get(day).containsKey(money)){
return Main.dp.get(day).get(money);
}
int[] max = new int[]{Integer.MAX_VALUE,0};
for(Integer[] e : Main.Fmap.get(day).wp){
int[] r = Main.rec(day+1, money-e[1], weight+e[0]);
if(max[1] <= r[1] && max[0] > r[0]){
max = r;
}
}
Main.dp.get(day).put(money, max);
return max;
}
static class Kanmi{
int k;
ArrayList<Integer[]> wp;
public Kanmi(int k,ArrayList<Integer[]> wp){
this.k = k;
this.wp = wp;
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.ArrayList;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.util.HashMap;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.Map;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.Scanner;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
6 | public class Main {
| ^~~~~~
|
s016513731 | p00677 | C++ |
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
static int s;
static int d;
static int m;
static Map<Integer,Kanmi> Fmap = new HashMap<>();
public static void main(String[] args) {
while(true){
Scanner scan = new Scanner(System.in);
Main.s = scan.nextInt();
if(Main.s < 0){break;}
Main.d = scan.nextInt();
Main.m = scan.nextInt();
ArrayList<Kanmi> list = new ArrayList<>();
for(int i = 0;i < Main.s;i++){
ArrayList<Integer[]> wp = new ArrayList<>();
int k = scan.nextInt();
for(int j = 0;j < k;j++){
wp.add(new Integer[]{scan.nextInt(),scan.nextInt()});
}
list.add(new Kanmi(k,wp));
}
for(int i = 0;i < Main.d;i++){
Main.Fmap.put(i,list.get(scan.nextInt()));
Main.dp.put(i,new HashMap<>());
}
int[] ans = Main.rec(0,Main.m, 0);
System.out.println(ans[1] + " " + (Main.m - ans[0]));
//break;
}
System.exit(0);
}
static Map<Integer,Map<Integer,int[]>> dp = new HashMap<>();
public static int[] rec(int day,int money,int weight){
if(money < 0){
return new int[]{Integer.MAX_VALUE,0};
}
if(day >= Main.d){
return new int[]{money,weight};
}
if(Main.dp.get(day).containsKey(money)){
return Main.dp.get(day).get(money);
}
int[] max = new int[]{Integer.MAX_VALUE,0};
for(Integer[] e : Main.Fmap.get(day).wp){
int[] r = Main.rec(day+1, money-e[1], weight+e[0]);
if(max[1] <= r[1] && max[0] > r[0]){
max = r;
}
}
Main.dp.get(day).put(money, max);
return max;
}
static class Kanmi{
int k;
ArrayList<Integer[]> wp;
public Kanmi(int k,ArrayList<Integer[]> wp){
this.k = k;
this.wp = wp;
}
}
} | a.cc:2:1: error: 'import' does not name a type
2 | import java.util.ArrayList;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.HashMap;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.Map;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.Scanner;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
7 | public class Main {
| ^~~~~~
|
s693612062 | p00677 | C++ | #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
static const double EPS = 1e-8;
class Goods{
public:
short w;
short p;
Goods(short _w,short _p) : w(_w), p(_p) {}
};
short dp[101][5001];
const static short MAX_W = 5000;
short main(){
short s,d,m;
while(~scanf("%hd %hd %hd",&s,&d,&m)){
map<short,vector<Goods> > data;
for(short i=0;i<s;i++){
short k;
scanf("%hd",&k);
for(short j=0;j<k;j++){
short w,p;
scanf("%hd %hd",&w,&p);
data[i].push_back(Goods(w,p));
}
}
vector<short> days;
for(short i=0;i<d;i++){
short f;
scanf("%hd",&f);
days.push_back(f);
}
memset(dp,0x3f,sizeof(dp));
dp[0][0] = 0;
for(short idx=0;idx<days.size();idx++){
vector<Goods>& it = data[days[idx]];
for(short i=0;i < it.size();i++){
short w = it[i].w;
short p = it[i].p;
for(short j=0;j<=MAX_W;j++){
if(j-w >= 0){
dp[idx+1][j] = min(min(dp[idx][j],dp[idx+1][j]),(short)(dp[idx][j-w]+p));
}
else{
dp[idx+1][j] = min(dp[idx+1][j],dp[idx][j]);
}
}
}
}
short resw=0;
short resm=0;
for(short i=0;i<=MAX_W;i++){
if(dp[d][i] <= m){
resm = dp[d][i];
resw = i;
}
}
printf("%hd %hd\n",resw,resm);
}
} | cc1plus: error: '::main' must return 'int'
|
s975963449 | p00677 | C++ | #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
static const double EPS = 1e-8;
class Goods{
public:
short w;
short p;
Goods(short _w,short _p) : w(_w), p(_p) {}
};
short dp[101][5001];
const static short MAX_W = 5000;
int main(){
short s,d,m;
while(~scanf("%hd %hd %hd",&s,&d,&m)){
map<short,vector<Goods> > data;
for(short i=0;i<s;i++){
short k;
scanf("%hd",&k);
for(short j=0;j<k;j++){
short w,p;
scanf("%hd %hd",&w,&p);
data[i].push_back(Goods(w,p));
}
}
vector<short> days;
for(short i=0;i<d;i++){
short f;
scanf("%hd",&f);
days.push_back(f);
}
memset(dp,0x3f,sizeof(dp));
dp[0][0] = 0;
for(short idx=0;idx<days.size();idx++){
vector<Goods>& it = data[days[idx]];
for(short i=0;i < it.size();i++){
short w = it[i].w;
short p = it[i].p;
for(short j=0;j<=MAX_W;j++){
if(j-w >= 0){
dp[idx+1][j] = min(min(dp[idx][j],dp[idx+1][j]),dp[idx][j-w]+p);
}
else{
dp[idx+1][j] = min(dp[idx+1][j],dp[idx][j]);
}
}
}
}
short resw=0;
short resm=0;
for(short i=0;i<=MAX_W;i++){
if(dp[d][i] <= m){
resm = dp[d][i];
resw = i;
}
}
printf("%hd %hd\n",resw,resm);
}
} | a.cc: In function 'int main()':
a.cc:79:67: error: no matching function for call to 'min(const short int&, int)'
79 | dp[idx+1][j] = min(min(dp[idx][j],dp[idx+1][j]),dp[idx][j-w]+p);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:4:
/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:79:67: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
79 | dp[idx+1][j] = min(min(dp[idx][j],dp[idx+1][j]),dp[idx][j-w]+p);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:8:
/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:79:67: note: mismatched types 'std::initializer_list<_Tp>' and 'short int'
79 | dp[idx+1][j] = min(min(dp[idx][j],dp[idx+1][j]),dp[idx][j-w]+p);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s276924348 | p00678 | C++ | #include <bits/stdc++.h>
using namespace std;
#define REP(i, s, e) for(int i = (int)s; i < (int) e; i++)
#define rep(i, n) REP(i, 0 ,n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long ll;
double dist(double x, double y){
return sqrt(x*x+y*y);
}
int main(){
int n;
while(cin>> n && n){
vector<double> x(n), y(n), r(n);
rep(i, n) cin>>x[i]>>y[i]>>r[i];
auto check = [&](double m){
rep(i, n) rep(j, i) if(dist(x[i]-x[j], y[i]-y[j]) > (r[i]+r[j])*m+EPS) return false;
return true;
};
double ng = 0.0, ok = 1e8;
rep(i, 10000){
double m = (ng + ok) / 2.0;
if(check(m)) ok = m;
else ng = m;
}
printf("%.15lf\n", ok);
}
} | a.cc: In lambda function:
a.cc:27:79: error: 'EPS' was not declared in this scope
27 | rep(i, n) rep(j, i) if(dist(x[i]-x[j], y[i]-y[j]) > (r[i]+r[j])*m+EPS) return false;
| ^~~
|
s261763709 | p00679 | C++ | #include <bits/stdc++.h>
using namespace std;
#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
print_tuple<Cdr...>(os,t);
os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
print_tuple<Args...>(os<<'(',t);
return os<<')';
}
template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
os<<'[';
for(auto i=begin(c);i!=end(c);++i)
os<<(i==begin(c)?"":" ")<<*i;
return os<<']';
}
constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;
struct Point{
int x,y,z;
Point():x(0),y(0),z(0){}
Point(int x,int y,int z):x(x),y(y),z(z){}
};
ostream& operator<<(ostream& os,const Point& p){
return os<<'('<<p.x<<','<<p.y<<','<<p.z<<')';
}
double Distance(Point a,Point b){
double x=a.x-b.x,y=a.y-b.y,z=a.z-b.z;
return sqrt(x*x+y*y+z*z);
}
template<typename T> void chmin(T& a,const T& b){a=min(a,b);}
template<typename T> void chmax(T& a,const T& b){a=max(a,b);}
int main()
{
#ifndef _GLIBCXX_DEBUG
ios_base::sync_width_stdio(false);
cin.tie(nullptr);
constexpr char endl='\n';
#endif
for(int n,q;cin>>n>>q && n|q;){
vector<Point> warps(n); // warp
for(auto& p:warps) cin>>p.x>>p.y>>p.z;
vector<vector<Point>> paths(q); // path
rep(i,q){
int m; cin>>m;
paths[i].resize(m);
for(auto& p:paths[i]) cin>>p.x>>p.y>>p.z;
}
Point offset(INF,INF,INF);
for(auto p:warps)
chmin(offset.x,p.x),chmin(offset.y,p.y),chmin(offset.z,p.z);
rep(i,q) for(auto p:paths[i])
chmin(offset.x,p.x),chmin(offset.y,p.y),chmin(offset.z,p.z);
for(auto& p:warps)
p.x-=offset.x,p.y-=offset.x,p.z-=offset.z;
rep(i,q) for(auto& p:paths[i])
p.x-=offset.x,p.y-=offset.x,p.z-=offset.z;
const int c=cbrt(n/10.+1); // 分割数.1区画あたり10個くらいの点があるように分割する.
Point size(0,0,0); // 1区画あたりの大きさ
for(auto p:warps)
chmax(size.x,p.x),chmax(size.y,p.y),chmax(size.z,p.z);
rep(i,q) for(auto p:paths[i])
chmax(size.x,p.x),chmax(size.y,p.y),chmax(size.z,p.z);
size.x=(size.x+c)/c,size.y=(size.y+c)/c,size.z=(size.z+c)/c;
typedef vector<Point> vp;
typedef vector<vp> vvp;
typedef vector<vvp> vvvp;
typedef vector<vvvp> vvvvp;
vvvvp grid(c,vvvp(c,vvp(c)));
for(auto p:warps)
grid[p.x/size.x][p.y/size.y][p.z/size.z].push_back(p);
for(auto path:paths){
vd nears;
for(auto p:path){
double mn=INF;
int ix=p.x/size.x,iy=p.y/size.y,iz=p.z/size.z;
repi(i,max(ix-1,0),min(ix+2,c))
repi(j,max(iy-1,0),min(iy+2,c))
repi(k,max(iz-1,0),min(iz+2,c))
for(auto q:grid[i][j][k])
mn=min(mn,Distance(p,q));
nears.push_back(mn);
}
double sum=0;
rep(i,path.size()-1)
sum+=min(Distance(path[i],path[i+1]),nears[i]+nears[i+1]);
printf("%.9f\n",sum);
}
}
} | a.cc: In function 'int main()':
a.cc:74:19: error: 'sync_width_stdio' is not a member of 'std::ios_base'
74 | ios_base::sync_width_stdio(false);
| ^~~~~~~~~~~~~~~~
|
s587440225 | p00679 | C++ | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
struct po {
int index;
vector<long long int> coors;
po(int _d):coors(_d) {
index = -1;
}
po(int index_, const vector<long long int>&coors_) :index(index_), coors(coors_) {
}
po() {}
};
template<class T>
class axisSorter {
int k;
public:
axisSorter(int _k) : k(_k) {}
bool operator()(const T &a, const T &b) {
return a.coors[k] < b.coors[k];
}
};
long long int getdis(const po&l, const po&r) {
long long int dis = 0;
for (int i = 0; i < l.coors.size(); ++i) {
dis += (l.coors[i] - r.coors[i])*(l.coors[i] - r.coors[i]);
}
return dis;
}
template<class T, int Dim = 3>
struct kdtree {
public:
T val;
shared_ptr<kdtree<T>> ltree, rtree;
int depth;
int axis;
kdtree(const T &p_) :val(p_), ltree(nullptr), rtree(nullptr) {
}
kdtree(vector<T>&ps_, const int& l, const int& r, const int depth_ = 0) : ltree(nullptr), rtree(nullptr), depth(depth_), axis(depth%Dim) {
init(ps_, l, r);
}
vector<T>query(const T & amin, const T&amax) {
vector<T>ans;
bool aok = true;
for (int i = 0; i < Dim; ++i) {
if (amin.coors[i] <= val.coors[i] && val.coors[i] <= amax.coors[i]) {
}
else {
aok = false;
break;
}
}
if (aok) {
ans.emplace_back(val);
}
axisSorter<T> as(axis);
if (as(val, amax) || val.coors[axis] == amax.coors[axis]) {
if (rtree != nullptr) {
vector<T>tans(rtree->query(amin, amax));
ans.insert(ans.end(), tans.begin(), tans.end());
}
}
if (as(amin, val) || val.coors[axis] == amin.coors[axis]) {
if (ltree != nullptr) {
vector<T>tans(ltree->query(amin, amax));
ans.insert(ans.end(), tans.begin(), tans.end());
}
}
return ans;
}
void get_closest(const T& apo, long long int &ans) {
ans = min(ans, getdis(apo, val));
axisSorter<T> as(axis);
if (as(apo, val) || val.coors[axis] == apo.coors[axis]) {
if (ltree)ltree->get_closest(apo, ans);
long long int dis = apo.coors[axis] - val.coors[axis];
if (dis*dis >= ans)return;
else {
if (rtree)rtree->get_closest(apo, ans);
}
}
else {
if (rtree)rtree->get_closest(apo, ans);
long long int dis = val.coors[axis] - apo.coors[axis];
if (dis*dis >= ans)return;
else {
if (ltree)ltree->get_closest(apo, ans);
}
}
}
private:
void init(vector<T>&ps, const int& l, const int& r) {
if (l >= r) {
return;
}
const int mid = (l + r) / 2;
nth_element(ps.begin() + l, ps.begin() + mid, ps.begin() + r, axisSorter<T>(axis));
val = ps[mid];
ltree = make_kdtree(ps, l, mid, depth + 1);
rtree = make_kdtree(ps, mid + 1, r, depth + 1);
}
};
//[l..r)
template<class T>
unique_ptr<kdtree<T>>make_kdtree(vector<T>&ps_, const int& l, const int& r, const int& depth = 0) {
if (l >= r)return nullptr;
else {
return make_unique<kdtree<T>>(ps_, l, r, depth);
}
}
int main() {
cout << setprecision(10) << fixed;
while (1) {
int N, Q; cin >> N >> Q;
if (!N)break;
vector<po>pos;
for (int i = 0; i < N; ++i) {
int x, y, z; cin >> x >> y >> z;
pos.push_back(po(i, vector<long long int>{x, y, z}));
}
int l = 0, r = N;
kdtree<po>tree(pos,l,r);
while (Q--) {
int M; cin >> M;
vector<po>points;
for (int i = 0; i < M; ++i) {
int x, y, z; cin >> x >> y >> z;
po p(0, vector<int>{x, y, z});
points.push_back(p);
}
ld ans = 0;
for (int i = 0; i < M - 1; ++i) {
po from(points[i]);
po to(points[i + 1]);
long long int dis = getdis(from, to);
long long int amax = 1e18, bmax = 1e18;
tree.get_closest(from, amax);
tree.get_closest(to, bmax);
ans += min(sqrt(dis), sqrt(amax) + sqrt(bmax));
}
cout << ans << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:141:61: error: no matching function for call to 'po::po(int, std::vector<int>)'
141 | po p(0, vector<int>{x, y, z});
| ^
a.cc:19:9: note: candidate: 'po::po()'
19 | po() {}
| ^~
a.cc:19:9: note: candidate expects 0 arguments, 2 provided
a.cc:16:9: note: candidate: 'po::po(int, const std::vector<long long int>&)'
16 | po(int index_, const vector<long long int>&coors_) :index(index_), coors(coors_) {
| ^~
a.cc:16:52: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<long long int>&'
16 | po(int index_, const vector<long long int>&coors_) :index(index_), coors(coors_) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
a.cc:13:9: note: candidate: 'po::po(int)'
13 | po(int _d):coors(_d) {
| ^~
a.cc:13:9: note: candidate expects 1 argument, 2 provided
a.cc:10:8: note: candidate: 'po::po(const po&)'
10 | struct po {
| ^~
a.cc:10:8: note: candidate expects 1 argument, 2 provided
a.cc:10:8: note: candidate: 'po::po(po&&)'
a.cc:10:8: note: candidate expects 1 argument, 2 provided
|
s316449087 | p00679 | C++ | #include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<iostream>
#include<cmath>
#include<ctime>
#define INF 1000001LL
#define INF2 1000001000000LL
using namespace std;
typedef long long ll;
struct cord{
int d,k;
vector<ll> c;
cord(void){d = k = 0;c.clear();}
cord(vector<ll> v){d = v.size(); k = 0; c = v;}
bool operator<(const cord a)const{return c[k]<a.c[k];}
bool operator==(const cord a)const{return c==a.c;}
};
ll dis(cord a, cord b){
if(a.d != b.d)return INF;
ll res = 0;
for(int i=0;i<a.d;i++)res += (a.c[i]-b.c[i]) * (a.c[i]-b.c[i]);
return res;
}
struct KDTree{
int n,d,root;
vector<cord> v;
KDTree(void){n = d = root = 0;v.clear();}
KDTree(vector<cord> x){
n = x.size();
if(!n)return;
d = x[0].c.size();
if(!d)return;
v = x;
compose(0,n,0);
}
void compose(int l, int r, int depth){
if(r-l<=1)return;
for(int i=l;i<r;i++)v[i].k = depth;
sort(v.begin()+l,v.begin()+r);
compose(l,(l+r)/2,(depth+1)%d);
compose((l+r)/2+1,r,(depth+1)%d);
return;
}
void search(int l,int r,vector<ll> &range, cord p, int depth, ll &dist){
if(r-l<1)return;
for(int i=0;i<d;i++){
if(range[2*i]>p.c[i] && (range[2*i]-p.c[i])*(range[2*i]-p.c[i]) > dist)return;
if(range[2*i+1]<p.c[i] && (range[2*i+1]-p.c[i])*(range[2*i+1]-p.c[i]) > dist)return;
}
int mid = (l+r)/2;
dist = min(dist,dis(p,v[mid]));
ll tmp = range[2*depth];
range[2*depth] = v[mid].c[depth];
search(mid+1,r,range,p,(depth+1)%d,dist);
range[2*depth] = tmp;
tmp = range[2*depth+1];
range[2*depth+1] = v[mid].c[depth];
search(l,mid,range,p,(depth+1)%d,dist);
range[2*depth+1] = tmp;
}
};
int n,q,m;
vector<cord> v;
cord p,r;
vector<ll> tmp;
int main(){
vector<ll> range;
for(int i=0;i<3;i++){
range.push_back(-INF);
range.push_back(INF);
}
while(scanf("%d%d",&n,&q)!=EOF,n||q){
v.resize(n); tmp.resize(3);
for(int i=0;i<n;i++){
for(int j=0;j<3;j++)scanf("%lld",&tmp[j]);
v[i] = cord(tmp);
}
for(int i=0;i<n;i++)a[i] = v[i];
KDTree kd(v);
for(int i=0;i<q;i++){
scanf("%d",&m);
double ans = 0;
ll now, prv;
for(int j=0;j<3;j++)scanf("%lld",&tmp[j]);
p = cord(tmp); prv = INF2;
kd.search(0,n,range,p,0,prv);
for(int j=1;j<m;j++){
for(int k=0;k<3;k++)scanf("%lld",&tmp[k]);
r = cord(tmp); now = INF2;
kd.search(0,n,range,r,0,now);
ans += min(sqrt(prv) + sqrt(now), sqrt(dis(p,r)) );
prv = now; p = r;
}
printf("%.10lf\n",ans);
}
}
} | a.cc: In function 'int main()':
a.cc:97:25: error: 'a' was not declared in this scope
97 | for(int i=0;i<n;i++)a[i] = v[i];
| ^
|
s719415966 | p00680 | C++ | #include<bits/stdc++.h>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
typedef pair<int,int> ii;
bool LT(double a,double b) { return !equals(a,b) && a < b ; }
struct Edge {
int to,cap;
double cost;
int rev;
};
const int MAX_V = 1000, IINF = INT_MAX;
int V;
vector<Edge> G[MAX_V];
double h[MAX_V],dist[MAX_V];//////// fpwjefoajfpojeawfopefa
int prevv[MAX_V], preve[MAX_V];
inline void add_edge(int from,int to,int cap,double cost){
G[from].push_back((Edge){to,cap,cost,G[to].size()});
G[to].push_back((Edge){from,0,-cost,G[from].size()-1});
}
double min_cost_flow(int s,int t,int f){
double res = 0;
fill(h,h+V,0);
while(LT(0,f)){
priority_queue<ii,vector<ii>,greater<ii> > Q;
fill(dist,dist+V,INT_MAX);
dist[s] = 0;
Q.push(ii(0,s));
while( !Q.empty() ){
ii p = Q.top(); Q.pop();
int v = p.second;
if( LT(dist[v],p.first) ) continue;
for(int i=0;i<G[v].size();i++) {
Edge &e = G[v][i];
if( LT(0,e.cap) && LT(dist[v]+e.cost+h[v]-h[e.to],dist[e.to]) ) {
dist[e.to] = dist[v]+e.cost+h[v]-h[e.to];
prevv[e.to] = v;
preve[e.to] = i;
Q.push(ii(dist[e.to],e.to));
}
}
}
if( equals(dist[t],INT_MAX) ) return -1;
rep(v,V) h[v] += dist[v];
int d = f;
for(int v=t;v!=s;v=prevv[v]) d = min(d,G[prevv[v]][preve[v]].cap);
f -= d;
res += d * h[t];
for(int v=t;v!=s;v=prevv[v]) {
Edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
}
typedef vector<double> vd;
typedef vector<vd> mat;
vector<double> f(const mat& A,const vd& b){
int n = A.size();
mat B(n,vd(n+1));
rep(i,n) rep(j,n) B[i][j] = A[i][j];
rep(i,n) B[i][n] = b[i];
rep(i,n){
int pivot = i;
REP(j,i,n) if( LT(abs(B[pivot][i]),abs(B[j][i])) ) pivot = j;
swap(B[i],B[pivot]);
if( abs(B[i][i]) < EPS ) return vd();
REP(j,i+1,n+1) B[i][j] /= B[i][i];
rep(j,n){
if( i != j ){
REP(k,i+1,n+1) B[j][k] -= B[j][i] * B[i][k];
}
}
}
vd x(n);
rep(i,n) x[i] = B[i][n];
return x;
}
void init(int size=MAX_V){
rep(i,size) G[i].clear();
}
int main(){
int T;
cin >> T;
while( T-- ){
int N,s,t,F;
cin >> N >> s >> t#include<bits/stdc++.h>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
typedef pair<int,int> ii;
bool LT(double a,double b) { return !equals(a,b) && a < b ; }
struct Edge {
int to,cap;
double cost;
int rev;
};
const int MAX_V = 1000, IINF = INT_MAX;
int V;
vector<Edge> G[MAX_V];
double h[MAX_V],dist[MAX_V];//////// fpwjefoajfpojeawfopefa
int prevv[MAX_V], preve[MAX_V];
inline void add_edge(int from,int to,int cap,double cost){
G[from].push_back((Edge){to,cap,cost,G[to].size()});
G[to].push_back((Edge){from,0,-cost,G[from].size()-1});
}
double min_cost_flow(int s,int t,int f){
double res = 0;
fill(h,h+V,0);
while(LT(0,f)){
priority_queue<ii,vector<ii>,greater<ii> > Q;
fill(dist,dist+V,INT_MAX);
dist[s] = 0;
Q.push(ii(0,s));
while( !Q.empty() ){
ii p = Q.top(); Q.pop();
int v = p.second;
if( LT(dist[v],p.first) ) continue;
for(int i=0;i<G[v].size();i++) {
Edge &e = G[v][i];
if( LT(0,e.cap) && LT(dist[v]+e.cost+h[v]-h[e.to],dist[e.to]) ) {
dist[e.to] = dist[v]+e.cost+h[v]-h[e.to];
prevv[e.to] = v;
preve[e.to] = i;
Q.push(ii(dist[e.to],e.to));
}
}
}
if( equals(dist[t],INT_MAX) ) return -1;
rep(v,V) h[v] += dist[v];
int d = f;
for(int v=t;v!=s;v=prevv[v]) d = min(d,G[prevv[v]][preve[v]].cap);
f -= d;
res += d * h[t];
for(int v=t;v!=s;v=prevv[v]) {
Edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
}
typedef vector<double> vd;
typedef vector<vd> mat;
vector<double> f(const mat& A,const vd& b){
int n = A.size();
mat B(n,vd(n+1));
rep(i,n) rep(j,n) B[i][j] = A[i][j];
rep(i,n) B[i][n] = b[i];
rep(i,n){
int pivot = i;
REP(j,i,n) if( LT(abs(B[pivot][i]),abs(B[j][i])) ) pivot = j;
swap(B[i],B[pivot]);
if( abs(B[i][i]) < EPS ) return vd();
REP(j,i+1,n+1) B[i][j] /= B[i][i];
rep(j,n){
if( i != j ){
REP(k,i+1,n+1) B[j][k] -= B[j][i] * B[i][k];
}
}
}
vd x(n);
rep(i,n) x[i] = B[i][n];
return x;
}
void init(int size=MAX_V){
rep(i,size) G[i].clear();
}
int main(){
int T;
cin >> T;
while( T-- ){
int N,s,t,F;
cin >> N >> s >> t >> F;
mat A(N,vector<double>(N,0));
vector<double> b(N,0);
rep(i,N) {
rep(j,N) {
cin >> A[i][j];
}
cin >> b[i];
}
vector<double> ans = f(A,b);
init();
rep(i,N) {
int M;
cin >> M;
vector<ii> vec(M);
rep(j,M) cin >> vec[j].first;
rep(j,M) cin >> vec[j].second;
rep(j,M) {
add_edge(i,vec[j].first,vec[j].second,abs(ans[i]-ans[vec[j].first]));
}
}
V = N;
double temp = min_cost_flow(s,t,F);
if( equals(temp,-1) ) puts("impossible");
else printf("%.10f\n",temp);
}
return 0;
}
>> F;
mat A(N,vector<double>(N,0));
vector<double> b(N,0);
rep(i,N) {
rep(j,N) {
cin >> A[i][j];
}
cin >> b[i];
}
vector<double> ans = f(A,b);
init();
rep(i,N) {
int M;
cin >> M;
vector<ii> vec(M);
rep(j,M) cin >> vec[j].first;
rep(j,M) cin >> vec[j].second;
rep(j,M) {
add_edge(i,vec[j].first,vec[j].second,abs(ans[i]-ans[vec[j].first]));
}
}
V = N;
double temp = min_cost_flow(s,t,F);
if( equals(temp,-1) ) puts("impossible");
else printf("%.10f\n",temp);
}
return 0;
} | a.cc:108:23: error: stray '#' in program
108 | cin >> N >> s >> t#include<bits/stdc++.h>
| ^
a.cc: In function 'void add_edge(int, int, int, double)':
a.cc:29:50: warning: narrowing conversion of 'G[to].std::vector<Edge>::size()' from 'std::vector<Edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
29 | G[from].push_back((Edge){to,cap,cost,G[to].size()});
| ~~~~~~~~~~^~
a.cc:30:53: warning: narrowing conversion of '(G[from].std::vector<Edge>::size() - 1)' from 'std::vector<Edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
30 | G[to].push_back((Edge){from,0,-cost,G[from].size()-1});
| ~~~~~~~~~~~~~~^~
a.cc: In function 'int main()':
a.cc:108:23: error: expected ';' before 'include'
108 | cin >> N >> s >> t#include<bits/stdc++.h>
| ^~~~~~~~
| ;
a.cc:119:28: error: a function-definition is not allowed here before '{' token
119 | bool LT(double a,double b) { return !equals(a,b) && a < b ; }
| ^
a.cc:135:58: error: a function-definition is not allowed here before '{' token
135 | inline void add_edge(int from,int to,int cap,double cost){
| ^
a.cc:140:40: error: a function-definition is not allowed here before '{' token
140 | double min_cost_flow(int s,int t,int f){
| ^
a.cc:182:43: error: a function-definition is not allowed here before '{' token
182 | vector<double> f(const mat& A,const vd& b){
| ^
a.cc:206:20: error: local variable 'MAX_V' may not appear in this context
206 | void init(int size=MAX_V){
| ^~~~~
a.cc:206:26: error: a function-definition is not allowed here before '{' token
206 | void init(int size=MAX_V){
| ^
a.cc:210:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
210 | int main(){
| ^~
a.cc:210:9: note: remove parentheses to default-initialize a variable
210 | int main(){
| ^~
| --
a.cc:210:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:210:11: error: a function-definition is not allowed here before '{' token
210 | int main(){
| ^
a.cc:248:2: error: expected primary-expression before '>>' token
248 | >> F;
| ^~
|
s096034647 | p00682 | Java | import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.math.BigInteger;
import java.math.BigDecimal;
public class Main{
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
static final long LINF=Long.MAX_VALUE/2;
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
while(true){
n=ir.nextInt();
if(n==0) break;
Vector[] vs=new Vector[n];
for(int i=0;i<n;i++) vs[i]=new Vector(ir.nextInt(),ir.nextInt());
double ans=0;
for(int i=0;i<n-1;i++) ans+=(double)Math.abs(vs[i].crossP(vs[i+1]))/2;
ans+=(double)Math.abs(vs[n-1].crossP(vs[0]))/2;
out.println(ans);
}
out.flush();
}
static class Vector{
int x;
int y;
public Vector(int x,int y){this.x=x; this.y=y;}
public int crossP(Vector v){return this.x*v.y-this.y*v.x;}
public int dotP(Vector v){return this.x*v.x+this.y*this.y;}
public double length(){return Math.hypot(x,y);}
public String toString{return "("+this.x+","+this.y+")";}
}
static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;
public InputReader(InputStream in) {this.in=in;}
public int readByte() {
if(lenbuf==-1) throw new InputMismatchException();
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}
catch (IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0)
return -1;
}
return buffer[curbuf++];
}
public boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;}
public String next() {
int b=skip();
StringBuilder sb=new StringBuilder();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
public int nextInt() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public long nextLong() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public int[] toIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
}
} | Main.java:52: error: ';' expected
public String toString{return "("+this.x+","+this.y+")";}
^
1 error
|
s030211770 | p00682 | Java | import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.math.BigInteger;
import java.math.BigDecimal;
public class Main{
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
static final long LINF=Long.MAX_VALUE/2;
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
while(true){
n=ir.nextInt();
if(n==0) break;
Vector[] vs=new Vector[n];
for(int i=0;i<n;i++) vs[i]=new Vector(ir.nextInt(),ir.nextInt());
double ans=0;
for(int i=0;i<n-1;i++) ans+=(double)Math.abs(vs[i].crossP(vs[i+1]))/2;
ans+=(double)Math.abs(vs[n-1].crossP(vs[0]))/2;
out.println(ans);
}
out.flush();
}
static class Vector{
int x;
int y;
public Vector(int x,int y){this.x=x; this.y=y;}
public int crossP(Vector v){return this.x*v.y-this.y*v.x;}
public int dotP(Vector v){return this.x*v.x+this.y*this.y;}
public double length(){return Math.hypot(x,y);}
public String toString(){return "("+this.x+","+this.y+")";}
}
static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;
public InputReader(InputStream in) {this.in=in;}
public int readByte() {
if(lenbuf==-1) throw new InputMismatchException();
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}
catch (IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0)
return -1;
}
return buffer[curbuf++];
}
public boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;}
public String next() {
int b=skip();
StringBuilder sb=new StringBuilder();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
public int nextInt() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public long nextLong() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public int[] toIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
}
} | Main.java:27: error: cannot find symbol
n=ir.nextInt();
^
symbol: variable n
location: class Main
Main.java:28: error: cannot find symbol
if(n==0) break;
^
symbol: variable n
location: class Main
Main.java:29: error: cannot find symbol
Vector[] vs=new Vector[n];
^
symbol: variable n
location: class Main
Main.java:30: error: cannot find symbol
for(int i=0;i<n;i++) vs[i]=new Vector(ir.nextInt(),ir.nextInt());
^
symbol: variable n
location: class Main
Main.java:32: error: cannot find symbol
for(int i=0;i<n-1;i++) ans+=(double)Math.abs(vs[i].crossP(vs[i+1]))/2;
^
symbol: variable n
location: class Main
Main.java:33: error: cannot find symbol
ans+=(double)Math.abs(vs[n-1].crossP(vs[0]))/2;
^
symbol: variable n
location: class Main
6 errors
|
s192464709 | p00682 | Java | public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int Case = 1;
while(true){
int n = sc.nextInt();
if(n==0)break;
double a[][] = new double[n][2];
for(int i=0;i<n;i++){
a[i][0] = sc.nextDouble();
a[i][1] = sc.nextDouble();
}
double area = 0;
for(int i=0;i<n-1;i++) area+=(a[i][0]*a[i+1][1]-a[i][1]*a[i+1][0])/2;
area+=(a[n-1][0]*a[0][1]-a[n-1][1]*a[0][0])/2;
System.out.printf("%d %.1f\n", Case++, -area);
}
}
} | Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s143551312 | p00682 | Java | import java.io.*;
import java.util.*;
public class AreaofPolygons {
public static void main(String[] args) throws IOException{
int j = 1;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in),1);
while(true){
ArrayList<Integer> x = new ArrayList<>();
ArrayList<Integer> y = new ArrayList<>();
int n = Integer.parseInt(br.readLine());
if(n == 0)
{
break;
}
for(int i = 0;i<n;i++)
{
String st = br.readLine();
String[] num = st.split(" ",0);
x.add(Integer.parseInt(num[0]));
y.add(Integer.parseInt(num[1]));
}
int s = 0;
for(int i = 0;i<n;i++)
{
if(i != n - 1)
{
s += (x.get(i)*y.get(i+1) - x.get(i+1)*y.get(i));
}else{
s += (x.get(i)*y.get(0) - x.get(0)*y.get(i));
}
}
double S = Math.abs(s)/2.0;
System.out.print(j+" ");
System.out.printf("%.1f",S);
System.out.println("");
String musi = br.readLine();
j++;
}
}
} | Main.java:4: error: class AreaofPolygons is public, should be declared in a file named AreaofPolygons.java
public class AreaofPolygons {
^
1 error
|
s989684732 | p00682 | Java | import java.io.*;
import java.util.*;
public class AreaofPolygons {
public static void main(String[] args) throws IOException{
int j = 1;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in),1);
while(true){
ArrayList<Integer> x = new ArrayList<>();
ArrayList<Integer> y = new ArrayList<>();
int n = Integer.parseInt(br.readLine());
if(n == 0)
{
break;
}
for(int i = 0;i<n;i++)
{
String st = br.readLine();
String[] num = st.split(" ",0);
x.add(Integer.parseInt(num[0]));
y.add(Integer.parseInt(num[1]));
}
int s = 0;
for(int i = 0;i<n;i++)
{
if(i != n - 1)
{
s += (x.get(i)*y.get(i+1) - x.get(i+1)*y.get(i));
}else{
s += (x.get(i)*y.get(0) - x.get(0)*y.get(i));
}
}
double S = Math.abs(s)/2.0;
System.out.print(j+" ");
System.out.printf("%.1f",S);
System.out.println("");
String musi = br.readLine();
j++;
}
}
} | Main.java:4: error: class AreaofPolygons is public, should be declared in a file named AreaofPolygons.java
public class AreaofPolygons {
^
1 error
|
s096459799 | p00682 | Java | import java.util.Scanner;
public class polygons {
public static void main(String args[]){
int n;
int cnt=0;
Scanner sc=new Scanner(System.in);
while (true){
n=sc.nextInt();
if (n==0) break;
double s=0.0;
int [][] ver=new int[n][2];
for (int i=0;i<n;i++){
ver[i][0]=sc.nextInt();
ver[i][1]=sc.nextInt();
if(i>1){
s+=cal(ver[i],ver[i-1],ver[0]);
}
}
cnt++;
System.out.println(cnt+" "+Math.abs(s/2));
}
}
private static double cal(int [] a,int [] b,int [] o){
a[0]=a[0]-o[0];
a[1]=a[1]-o[1];
b[0]=b[0]-o[0];
b[1]=b[1]-o[1];
return(a[0]*b[1]-a[1]*b[0]);
}
} | Main.java:2: error: class polygons is public, should be declared in a file named polygons.java
public class polygons {
^
1 error
|
s988652198 | p00682 | Java | import java.util.Scanner;
public class main {
public static void main(String args[]){
int n;
int cnt=0;
Scanner sc=new Scanner(System.in);
while (true){
n=sc.nextInt();
if (n==0) break;
double s=0.0;
int [][] ver=new int[n][2];
for (int i=0;i<n;i++){
ver[i][0]=sc.nextInt();
ver[i][1]=sc.nextInt();
if(i>1){
s+=cal(ver[i],ver[i-1],ver[0]);
}
}
cnt++;
System.out.println(cnt+" "+Math.abs(s/2));
}
}
private static double cal(int [] a,int [] b,int [] o){
a[0]=a[0]-o[0];
a[1]=a[1]-o[1];
b[0]=b[0]-o[0];
b[1]=b[1]-o[1];
return(a[0]*b[1]-a[1]*b[0]);
}
} | Main.java:2: error: class main is public, should be declared in a file named main.java
public class main {
^
1 error
|
s042242955 | p00682 | Java | import java.util.*;
public class Main {
private static Scanner sc = new Scanner(System.in);
public static void main(String...args) {
while(sc.hasNext()) {
final int n = sc.nextInt();
if (n == 0)
break;
solve(n);
}
private static void solve(final int n) {
final int[] x = new int[n];
final int[] y = new int[n];
for(int i = 0; i < n; i++) {
x[i] = sc.nextInt();
y[i] = sc.nextInt();
}
int ans = 0;
for(int i = 2; i < n; i++)
ans += x[i-1] * y[i] - x[i] * y[i-1];
System.out.println(Math.abs(ans));
}
} | Main.java:12: error: illegal start of expression
private static void solve(final int n) {
^
1 error
|
s261965245 | p00682 | Java | import java.util.*;
public class Main {
private static Scanner sc = new Scanner(System.in);
public static void main(String...args) {
while(sc.hasNext()) {
final int n = sc.nextInt();
if (n == 0)
break;
solve(n);
}
private static int case = 1;
private static void solve(final int n) {
final int[] x = new int[n];
final int[] y = new int[n];
for(int i = 0; i < n; i++) {
x[i] = sc.nextInt();
y[i] = sc.nextInt();
}
int ans = 0;
for(int i = 2; i < n; i++)
ans += x[i-1] * y[i] - x[i] * y[i-1];
System.out.println(case++ + " " + (.5 * Math.abs(ans)));
}
} | Main.java:12: error: illegal start of expression
private static int case = 1;
^
Main.java:12: error: <identifier> expected
private static int case = 1;
^
Main.java:23: error: illegal start of expression
System.out.println(case++ + " " + (.5 * Math.abs(ans)));
^
Main.java:23: error: : or -> expected
System.out.println(case++ + " " + (.5 * Math.abs(ans)));
^
4 errors
|
s917963362 | p00682 | Java | import java.util.*;
public class Main {
private static Scanner sc = new Scanner(System.in);
public static void main(String...args) {
while(sc.hasNext()) {
final int n = sc.nextInt();
if (n == 0)
break;
solve(n);
}
}
private static int case = 1;
private static void solve(final int n) {
final int[] x = new int[n];
final int[] y = new int[n];
for(int i = 0; i < n; i++) {
x[i] = sc.nextInt();
y[i] = sc.nextInt();
}
int ans = 0;
for(int i = 2; i < n; i++)
ans += x[i-1] * y[i] - x[i] * y[i-1];
System.out.println(case++ + " " + (.5 * Math.abs(ans)));
}
} | Main.java:13: error: <identifier> expected
private static int case = 1;
^
Main.java:24: error: illegal start of expression
System.out.println(case++ + " " + (.5 * Math.abs(ans)));
^
Main.java:24: error: : or -> expected
System.out.println(case++ + " " + (.5 * Math.abs(ans)));
^
3 errors
|
s770988645 | p00682 | Java | import java.util.*;
import java.lang.Math;
public class AOJ1100
{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
for(int a=1;;a++){
Polygo pol =new Polygo();
int n=sc.nextInt();
if(n==0)break;
for(int i=0;i<n;i++){
pol.addXY(sc.nextDouble(),sc.nextDouble());
}
System.out.println(a+" "+Math.abs(pol.getArea()));
}
}
}
class Polygo
{
ArrayList<Double> x=new ArrayList<Double>();
ArrayList<Double> y=new ArrayList<Double>();
Polygo()
{
}
public void addXY(double x,double y)
{
this.x.add(x);
this.y.add(y);
}
public StringBuffer getX()
{
StringBuffer s= new StringBuffer();
for(int i=0;i<x.size();i++){
s.append(x.get(i));
s.append(" ");
}
return s;
}
public StringBuffer getY()
{
StringBuffer s= new StringBuffer();
for(int i=0;i<y.size();i++){
s.append(y.get(i));
s.append(" ");
}
return s;
}
public double getArea()
{
double S=0;
double[] x1=new double[2];
double[] y1=new double[2];
int d[]={1,0};
x1[0]=x.get(0);
y1[0]=y.get(0);
for(int i=1;i<x.size();i++){
x1[i%2]=x.get(i);
y1[i%2]=y.get(i);
S+=(x1[d[i%2]]-x1[i%2])*(y1[d[i%2]]+y1[i%2]);
}
S+=(x.get(x.size()-1)-x.get(0))*(y.get(x.size()-1)+y.get(0));
return S/2;
}
} | Main.java:3: error: class AOJ1100 is public, should be declared in a file named AOJ1100.java
public class AOJ1100
^
1 error
|
s290656674 | p00682 | Java | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main{
static int N, D, money;
static int[] prices;
private static int solve(){
int answer = 0;
if (prices[0] * 2 > money) return 0;
if (prices[prices.length - 1] + prices[prices.length - 2] <= money) return prices[prices.length - 1] + prices[prices.length - 2];
for (int i = 0; i < N - 1; i++)
{
int index = Arrays.binarySearch(prices, i + 1, prices.length - i - 1, money - prices[i]);
if (index > i) return prices[i] + prices[index];
index = ~index - 1;
if (index == i) continue;
answer = Math.max(prices[i] + prices[index], answer);
}
return answer;
}
public static void main(String args[]){
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] strs = br.readLine().split(",");
N = Integer.parseInt(strs[0]); D = Integer.parseInt(strs[1]);
prices = new int[N];
for (int i = 0; i < N; i++)
prices[i] = Integer.parseInt(be.readLine());
Arrays.Sort(prices);
for (int i = 0; i < D; i++)
{
money = Integer.parseInt(be.readLine());
System.out.println(solve());
}
}
} | Main.java:28: error: cannot find symbol
prices[i] = Integer.parseInt(be.readLine());
^
symbol: variable be
location: class Main
Main.java:29: error: cannot find symbol
Arrays.Sort(prices);
^
symbol: method Sort(int[])
location: class Arrays
Main.java:32: error: cannot find symbol
money = Integer.parseInt(be.readLine());
^
symbol: variable be
location: class Main
3 errors
|
s990664127 | p00682 | C | #include <math.h>
#include <stdio.h>
#pragma warning(disable : 4996)
int n, c, x[100], y[100];
double s(int xa, int ya, int xb, int yb, int xc, int yc) {
return abs((xb - xa) * (yc - ya) - (xc - xa) * (yb - ya)) * 0.5;
}
int main() {
while (true) {
scanf("%d", &n);
if (n == 0) break;
for (int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);
double ret = 0;
for (int i = 2; i < n; i++) {
ret += s(x[0], y[0], x[1], y[1], x[i], y[i]);
}
printf("%d %.1f\n", ++c, ret);
}
return 0;
} | main.c: In function 's':
main.c:6:16: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
6 | return abs((xb - xa) * (yc - ya) - (xc - xa) * (yb - ya)) * 0.5;
| ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
2 | #include <stdio.h>
+++ |+#include <stdlib.h>
3 | #pragma warning(disable : 4996)
main.c: In function 'main':
main.c:9:16: error: 'true' undeclared (first use in this function)
9 | while (true) {
| ^~~~
main.c:3:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
2 | #include <stdio.h>
+++ |+#include <stdbool.h>
3 | #pragma warning(disable : 4996)
main.c:9:16: note: each undeclared identifier is reported only once for each function it appears in
9 | while (true) {
| ^~~~
|
s471012434 | p00682 | C | import java.util.*;
public class Main {
private static Scanner sc = new Scanner(System.in);
public static void main(String...args) {
while(sc.hasNext()) {
final int n = sc.nextInt();
if (n == 0)
break;
solve(n);
}
}
private static int case = 1;
private static void solve(final int n) {
final int[] x = new int[n];
final int[] y = new int[n];
for(int i = 0; i < n; i++) {
x[i] = sc.nextInt();
y[i] = sc.nextInt();
}
int ans = 0;
for(int i = 2; i < n; i++)
ans += x[i-1] * y[i] - x[i] * y[i-1];
System.out.println(case++ + " " + (.5 * Math.abs(ans)));
}
} | main.c:1:1: error: unknown type name 'import'
1 | import java.util.*;
| ^~~~~~
main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
1 | import java.util.*;
| ^
main.c:3:1: error: unknown type name 'public'
3 | public class Main {
| ^~~~~~
main.c:3:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main'
3 | public class Main {
| ^~~~
|
s362129453 | p00682 | C | #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>
using namespace std;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define repc(i,n) for(int i=0;i<=(n);++i)
#define repcn(i,m,n) for(int i=(m);i<=(n);++i)
#define repcd(i,n) for(int i=(n);i>=0;--i)
#define repcnd(i,m,n) for(int i=(n);i>=(m);--i)
#define repc0(i,n) for(i=0;i<=(n);++i)
#define repcn0(i,m,n) for(i=(m);i<=(n);++i)
#define repcd0(i,n) for(i=(n);i>=0;--i)
#define repcnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE cout<<"LINE:"<<__LINE__<<endl;
const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int dx[]={1,-1,0,0,1,1,-1,-1,0};
const int dy[]={0,0,1,-1,1,-1,1,-1,0};
int x[100], y[100];
int main() {
int n, res, count = 0;
IL{
cin >> n;
if (n == 0) break;
rep (i, n) cin >> x[i] >> y[i];
res = 0;
rep (i, n - 1) res += (x[i + 1] - x[i]) * (y[i + 1] + y[i]);
res += (x[0] - x[n - 1]) * (y[0] + y[n + 1]);
res = abs(res);
printf("%d %.1f\n", ++count, (double)res / 2);
}
return 0;
} | main.c:1:9: fatal error: cstdio: No such file or directory
1 | #include<cstdio>
| ^~~~~~~~
compilation terminated.
|
s978208697 | p00682 | C++ | #include <stdio.h>
int main(){
int n, cnt = 1;
scanf_s("%d", &n);
while (n){
float s = 0, x0, y0, xa, xb, ya, yb;
scanf_s("%f %f", &x0, &y0);
xb = x0;
yb = y0;
for (int i = n - 1; i>0; i--){
xa = xb;
ya = yb;
scanf_s("%f %f", &xb, &yb);
s += (xb + xa)*(yb - ya);
}
s += (x0 + xb)*(y0 - yb);
printf("%d %.1f\n", cnt++, s>0 ? s / 2 : (-s) / 2);
scanf_s("%d", &n);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:5:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
5 | scanf_s("%d", &n);
| ^~~~~~~
| scanf
|
s319374532 | p00682 | C++ | e#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
typedef long long ll;
using namespace std;
typedef struct {
int x;
int y;
} Position;
double getS(Position p1, Position p2) {
double ret = fabs(p1.x * p2.y - p1.y * p2.x);
return ret / 2;
}
int main() {
cin.tie(0); //?????±?????????????????????
int n;
Position pBase;
Position pPrev;
Position pNow;
int count = 0;
while (cin >> n, count++, n != 0) {
Position pos[100];
int ave_x = 0, ave_y = 0;
for (int i = 0; i < n; i++) {
int x = 0, y = 0;
cin >> x >> y;
pos[i] = { x, y };
ave_x += x;
ave_y += y;
}
ave_x /= n;
ave_y /= n;
for (int i = 0; i < n; i++) {
pos[i].x -= ave_x;
pos[i].y -= ave_y;
}
Position pPrev { pos[0].x, pos[0].y };
Position pNow;
double sum = 0;
for (int i = 1; i < n; i++) {
pNow = { pos[i].x, pos[i].y };
sum += getS(pPrev, pNow);
pPrev = { pNow.x, pNow.y };
}
sum += getS(pNow, pos[0]);
printf("%d %.1lf\n", count, sum);
}
return 0;
} | a.cc:1:2: error: stray '#' in program
1 | e#include <iostream>
| ^
a.cc:1:1: error: 'e' does not name a type
1 | e#include <iostream>
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | |
s988887942 | p00682 | C++ | printf("www"); | a.cc:1:7: error: expected constructor, destructor, or type conversion before '(' token
1 | printf("www");
| ^
|
s090044104 | p00682 | C++ | #include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ Classes ------ //
class Point {
public:
long double px, py;
Point() : px(0), py(0) {};
Point(long double px_, long double py_) : px(px_), py(py_) {};
friend bool operator==(const Point& p1, const Point& p2) { return p1.px == p2.px && p1.py == p2.py; }
friend bool operator!=(const Point& p1, const Point& p2) { return p1.px != p2.px || p1.py != p2.py; }
friend bool operator<(const Point& p1, const Point& p2) { return p1.px < p2.px ? true : (p1.px == p2.px && p1.py < p2.py); }
friend bool operator>(const Point& p1, const Point& p2) { return p1.px > p2.px ? true : (p1.px == p2.px && p1.py > p2.py); }
friend bool operator<=(const Point& p1, const Point& p2) { return !(p1 > p2); }
friend bool operator>=(const Point& p1, const Point& p2) { return !(p1 < p2); }
friend Point operator+(const Point& p1, const Point& p2) { return Point(p1.px + p2.px, p1.py + p2.py); }
friend Point operator-(const Point& p1, const Point& p2) { return Point(p1.px - p2.px, p1.py - p2.py); }
friend Point operator*(const Point& p1, long double d) { return Point(p1.px * d, p1.py + d); }
friend Point operator*(long double d, const Point& p1) { return p1 * d; }
friend Point operator/(const Point& p1, long double d) { return Point(p1.px / d, p1.py / d); }
Point& operator+=(const Point& p1) { px += p1.px; py += p1.py; return *this; }
Point& operator-=(const Point& p1) { px -= p1.px; py -= p1.py; return *this; }
Point& operator*=(long double d) { px *= d; py *= d; return *this; }
Point& operator/=(long double d) { px /= d; py /= d; return *this; }
};
// ------ Functions ------ //
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
long double area(vector<Point> v) {
long double ret = 0.0L;
for (int i = 0; i < v.size(); i++) ret += crs(v[i], v[(i + 1) % v.size()]);
return ret / 2;
}
// ------ Main ------ //
int n, c; vector<Point> v;
int main() {
while(scanf("%d", &n), n) {
p.resize(n);
for(int i = 0; i < n; i++) cin >> v[i].px >> v[i].py;
printf("%d %.2f\n", ++c, area(v));
}
} | a.cc: In function 'int main()':
a.cc:42:17: error: 'p' was not declared in this scope
42 | p.resize(n);
| ^
|
s796358714 | p00682 | C++ | #include<iostream>
#include<cstdio>
#include<cmath>
#include<complex>
#include<vector>
#include<queue>
using namespace std;
typedef complex<int> xy_t;
int main()
{
int n;
double x,y,sum = 0.0;
queue<int> answer;
while(cin >> n && n > 0){
vector<xy_t> p(n);
for( int i = 0; i < n; ++i){
cin >> x >> y;
p[i] = xy_t(x,y);
}
for( int i = 0; i + 2 < n; ++i){
xy_t a = p[0],b = p[i + 1],c = p[i + 2];
sum += ((conj(b - a)*(c - a)).imag())/2.0;
}
answer.push(abs(sum));
}
while(!answer.empty()){
printf("%.1f\n",answer.top());
answer.pop();
}
} | a.cc: In function 'int main()':
a.cc:27:28: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
27 | printf("%.1f\n",answer.top());
| ^~~
| pop
|
s790395998 | p00682 | C++ | vf | a.cc:1:1: error: 'vf' does not name a type
1 | vf
| ^~
|
s589487844 | p00682 | C++ | #incluce <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
struct vertex{
int x;
int y;
vertex(int x0, int y0){x = x0, y = y0;}
};
typedef std::vector<vertex> convex;
int judgeCurve(vertex p1, vertex p2, vertex p3){
double vec1_x = p2.x - p1.x, vec1_y = p2.y - p1.y;
double vec2_x = p3.x - p1.x, vec2_y = p3.y - p1.y;
double ang1 = atan2(vec1_y, vec1_x);
double vec_x = cos(ang1) * vec2_x + sin(ang1) * vec2_y;
double vec_y = -sin(ang1) * vec2_x + cos(ang1) * vec2_y;
double ang2 = atan2(vec_y, vec_x);
if(ang2 > 0) return -1;
else return 1;
}
double areaTriangle(vertex p1, vertex p2, vertex p3)
{
double vec1_x = p2.x - p1.x, vec1_y = p2.y - p1.y;
double vec2_x = p3.x - p1.x, vec2_y = p3.y - p1.y;
return fabs(vec1_x * vec2_y - vec1_y * vec2_x) / 2;
}
double areaConvex(convex conv)
{
double area = 0;
for(int i = 1; i+1 < (int)conv.size(); i++){
area += areaTriangle(conv[0], conv[i], conv[i+1]);
}
return area;
}
int main(void)
{
int cnt = 0;
int n;
std::vector<vertex> p;
convex main_conv;
std::vector<convex> sub_conv;
double area;
while(1){
cin >> n;
///scanf("%d", &n);
if(n == 0) break;
int tmp_x, tmp_y;
p.clear();
main_conv.clear();
sub_conv.clear();
for(int i = 0; i < n; i++){
cin >> tmp_x >> tmp_y;
//scanf("%d %d", &tmp_x, &tmp_y);
p.push_back(vertex(tmp_x, tmp_y));
}
while(judgeCurve(p[n-1], p[0], p[1]) == -1){
p.push_back(p[0]);
p.erase(p.begin());
}
bool reverseFlag = false;
int reverse_start, reverse_end;
convex tmp;
for(int i = 0; i <= n; i++){
int prev = (n + i - 1) % n, now = (n + i) % n, next = (n + i + 1) % n;
if(judgeCurve(p[prev], p[now], p[next]) == 1){
main_conv.push_back( p[now] );
if(reverseFlag){
reverseFlag = false;
reverse_end = now;
tmp.clear();
for(int i = reverse_start; i <= reverse_end; i++){
tmp.push_back( p[i] );
}
sub_conv.push_back( tmp );
}
}else{
reverseFlag = true;
reverse_start = prev;
}
}
p.pop_back();
area = 0;
area = areaConvex(main_conv);
for(int i = 0; i < (int)sub_conv.size(); i++){
area -= areaConvex(sub_conv[i]);
}
cnt++;
printf("%d %.1f\n", cnt, area);
}
return 0;
}
| a.cc:1:2: error: invalid preprocessing directive #incluce; did you mean #include?
1 | #incluce <iostream>
| ^~~~~~~
| include
a.cc: In function 'int main()':
a.cc:57:1: error: 'cin' was not declared in this scope; did you mean 'sin'?
57 | cin >> n;
| ^~~
| sin
|
s623139835 | p00682 | C++ | #include <stdio.h>
#include <math>
struct vertex{
int x;
int y;
};
double areaTriangle(vertex p1, vertex p2, vertex p3)
{
double vec1_x = p2.x - p1.x, vec1_y = p2.y - p1.y;
double vec2_x = p3.x - p1.x, vec2_y = p3.y - p1.y;
return (vec1_x * vec2_y - vec1_y * vec2_x) / 2;
}
int main(void)
{
int cnt = 0;
int n;
vertex p[50];
double area;
while(1){
scanf("%d", &n);
if(n == 0) break;
for(int i = 0; i < n; i++){
scanf("%d %d", &p[i].x, &p[i].y);
}
area = 0;
for(int i = 1; i+1 < n; i++){
area += areaTriangle(p[0], p[i], p[i+1]);
}
area = fabs(area);
cnt++;
printf("%d %.1f\n", cnt, area);
}
return 0;
} | a.cc:2:10: fatal error: math: No such file or directory
2 | #include <math>
| ^~~~~~
compilation terminated.
|
s316206657 | p00682 | C++ | import java.util.Scanner;
public class Main {
public static void main(String args[]){
int n;
int cnt=0;
Scanner sc=new Scanner(System.in);
while (true){
n=sc.nextInt();
if (n==0) break;
double s=0.0;
int [][] ver=new int[n][2];
for (int i=0;i<n;i++){
ver[i][0]=sc.nextInt();
ver[i][1]=sc.nextInt();
if(i>1){
s+=cal(ver[i],ver[i-1],ver[0]);
}
}
cnt++;
System.out.println(cnt+" "+Math.abs(s/2));
}
}
private static double cal(int [] a,int [] b,int [] o){
a[0]=a[0]-o[0];
a[1]=a[1]-o[1];
b[0]=b[0]-o[0];
b[1]=b[1]-o[1];
return(a[0]*b[1]-a[1]*b[0]);
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Scanner;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: expected unqualified-id before 'public'
2 | public class Main {
| ^~~~~~
|
s047439866 | p00682 | C++ | #include <vector>
#include <complex>
using namespace std;
typedef complex<double> P;
double area(vector<P> polygon)
{
const int N = polygon.size();
double s = 0.0;
for (int i = 0; i < N; i++) {
s += polygon[i].real()*polygon[(i+1)%N].imag() - polygon[i].imag()*polygon[(i+1)%N].real();
}
return abs(s)/2.0;
}
int main()
{
int c = 1;
int n;
while (cin >> n && n != 0) {
vector<P> polygon(n);
for (int i = 0; i < n; i++) {
cin >> polygon[i].real() >> polygon[i].imag();
}
printf("%d %.1f\n", c, area(polygon));
c++;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:20:10: error: 'cin' was not declared in this scope
20 | while (cin >> n && n != 0) {
| ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include <complex>
+++ |+#include <iostream>
3 | using namespace std;
|
s720118512 | p00682 | C++ | #include <iostream>
#include <math>
#include <string>
using namespace std;
int main()
{
int n;
int c=1;
double x[100] = {0};
double y[100] = {0};
while( cin >> n , n)
{
double out = 0;
for( int i = 0; i < n; i++)
{
cin >> x[i] >> y[i];
}
for( int i = 0; i < n - 1 ; i++)
{
out += x[i]*y[i+1] - x[i+1]*y[i];
}
cout << c << " " << (float)abs(0.5*out) <<endl;
c++;
for( int i = 0; i < 100; i++)
{
x[i] = 0;
y[i] = 0;
}
}
return 0;
} | a.cc:2:10: fatal error: math: No such file or directory
2 | #include <math>
| ^~~~~~
compilation terminated.
|
s091571605 | p00682 | C++ | #include <iostream>
#include <math>
using namespace std;
int main()
{
int n;
int c=1;
double x[100] = {0};
double y[100] = {0};
while( cin >> n , n)
{
double out = 0;
for( int i = 0; i < n; i++)
{
cin >> x[i] >> y[i];
}
for( int i = 0; i < n - 1 ; i++)
{
out += x[i]*y[i+1] - x[i+1]*y[i];
}
cout << c++ << " " << 0.5*abs(out) <<endl;
for( int i = 0; i < 100; i++)
{
x[i] = 0;
y[i] = 0;
}
}
return 0;
} | a.cc:2:10: fatal error: math: No such file or directory
2 | #include <math>
| ^~~~~~
compilation terminated.
|
s122339854 | p00682 | C++ | #include <vector>
#include <cmath>
using namespace std;
/*
double area(double x1,double y1,
double x2,double y2,
double x3,double y3){
double vx1 = x2-x1;
double vy1 = y2-y1;
double vx2 = x3-x1;
double vy2 = y3-y1;
return (abs(vx1*vy2)+abs(vy1*vx2))/2.0;
}*/
int main(){
int count=0;
while(true){
++count;
int n;
double ans = 0.0;
vector<double> vx;
vector<double> vy;
cin >> n;
if(n==0)return 0;
for(int i=0;i<n;i++){
double x,y;
cin >> x >> y;
vx.push_back(x);
vy.push_back(y);
}
for(int i =0;i<vx.size();i++){
if(i==vx.size()-1){
ans+=(vx[i]-vx[0])*(vy[i]+vy[0]);
break;
}
ans+=(vx[i]-vx[i+1])*(vy[i]+vy[i+1]);
}
cout << count << " " << abs(ans/2.0) << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:28:9: error: 'cin' was not declared in this scope
28 | cin >> n;
| ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include <cmath>
+++ |+#include <iostream>
3 |
a.cc:43:9: error: 'cout' was not declared in this scope
43 | cout << count << " " << abs(ans/2.0) << endl;
| ^~~~
a.cc:43:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:43:49: error: 'endl' was not declared in this scope
43 | cout << count << " " << abs(ans/2.0) << endl;
| ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
2 | #include <cmath>
+++ |+#include <ostream>
3 |
|
s932177347 | p00682 | C++ | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int c = 0;
while(true){
c++;
int n = sc.nextInt();
if(n==0) break;
double a[][] = new double[n][2];
for(int i=0 ;i<n ;i++){
a[i][0] = sc.nextDouble(); //x
a[i][1] = sc.nextDouble(); //y
}
double s = 0;
for(int i=0;i<n-1;i++){
// s += ((a[i][0]-a[i+1][0])*(a[i][1]+a[i+1][1]))/2;
s += (a[i][0]*a[i+1][1]-a[i][1]*a[i+1][0])/2;
}
s += (a[n-1][0]*a[0][1]-a[n-1][1]*a[0][0])/2;
if(s<0){
s*=-1;
}
//System.out.print("%d %.1f",c,s);
System.out.println(c+" "+s);
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
4 | public class Main{
| ^~~~~~
|
s592483703 | p00682 | C++ | #include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
#define cin in
ifstream in("input.txt");
#endif // ONLINE_JUDGE
int nb_points;
int cas = 1;
while(cin>>nb_points)
{
if(nb_points == 0) break;
cout<<cas<<" ";
cas++;
vector<Point> points(nb_points);
for(int c=0;c<nb_points;c++)
{
cin>>points[c].x>>points[c].y;
}
double res = 0;
int deb = 0;
for(int c=0;c<nb_points;c++)
{
res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
}
cout<<fixed<<setprecision(1)<<(res>0?res:-res)/2.<<endl;
}
} | a.cc: In function 'int main()':
a.cc:33:16: error: 'Point' was not declared in this scope
33 | vector<Point> points(nb_points);
| ^~~~~
a.cc:33:21: error: template argument 1 is invalid
33 | vector<Point> points(nb_points);
| ^
a.cc:33:21: error: template argument 2 is invalid
a.cc:36:24: error: invalid types 'int[int]' for array subscript
36 | cin>>points[c].x>>points[c].y;
| ^
a.cc:36:37: error: invalid types 'int[int]' for array subscript
36 | cin>>points[c].x>>points[c].y;
| ^
a.cc:42:25: error: invalid types 'int[int]' for array subscript
42 | res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
| ^
a.cc:42:37: error: invalid types 'int[int]' for array subscript
42 | res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
| ^
a.cc:42:65: error: invalid types 'int[int]' for array subscript
42 | res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
| ^
a.cc:42:79: error: invalid types 'int[int]' for array subscript
42 | res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
| ^
|
s547317212 | p00683 | Java | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.math.BigInteger;
import java.math.BigDecimal;
public class Main{
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
static final long LINF=Long.MAX_VALUE/2;
static int MAX=10000;
static char[] str=new char[MAX+1];
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(in));
int n=Integer.parseInt(br.readLine());
while(n-->0){
String line=br.readLine();
int cur=0;
for(int i=0;i<=MAX;i++) str[i]='';
for(int i=0;i<line.length();i++) str[i]=line.charAt(i);
int m=Integer.parseInt(br.readLine());
while(m-->0){
String[] com=br.readLine().split(" ");
if("forward".equals(com[0])){
if("char".equals(com[1])&&str[cur]!='') cur++;
else{
while(str[cur]==' ') cur++;
while(str[cur]!=' '&&str[cur]!='') cur++;
}
}
else if("backward".equals(com[0])){
if("char".equals(com[1])&&cur!=0) cur--;
else{
while(cur!=0&&str[cur-1]==' ') cur--;
while(cur!=0&&str[cur-1]!=' ') cur--;
}
}
else if("insert".equals(com[0])){
String insertionStr=com[1].substring(1,com[1].length()-1);
for(int i=MAX-insertionStr.length();i>=cur;i--){
str[i+insertionStr.length()]=str[i];
}
for(int i=0;i<insertionStr.length();i++){
str[cur+i]=insertionStr.charAt(i);
}
}
else{
if("char".equals(com[1])&&str[cur]!=''){
for(int i=cur;i<=MAX;i++){
if(str[i]=='') break;
str[i]=str[i+1];
}
}
else{
int cnt=cur;
boolean flag=false;
while(str[cnt]==' ') cnt++;
while(str[cnt]!=' '&&str[cnt]!=''){
cnt++;
flag=true;
}
if(flag){
for(int i=cnt;i<=MAX;i++){
if(str[i-cnt+cur]=='') break;
str[i-cnt+cur]=str[i];
}
}
}
}
}
for(int i=0;;i++){
if(str[i]=='') break;
if(i==cur) out.print("^");
out.print(str[i]);
}
out.println();
}
out.flush();
}
} | Main.java:33: error: empty character literal
for(int i=0;i<=MAX;i++) str[i]='';
^
Main.java:39: error: empty character literal
if("char".equals(com[1])&&str[cur]!='') cur++;
^
Main.java:42: error: empty character literal
while(str[cur]!=' '&&str[cur]!='') cur++;
^
Main.java:40: error: 'else' without 'if'
else{
^
Main.java:62: error: empty character literal
if("char".equals(com[1])&&str[cur]!=''){
^
Main.java:64: error: empty character literal
if(str[i]=='') break;
^
Main.java:72: error: empty character literal
while(str[cnt]!=' '&&str[cnt]!=''){
^
Main.java:78: error: empty character literal
if(str[i-cnt+cur]=='') break;
^
Main.java:68: error: 'else' without 'if'
else{
^
Main.java:86: error: empty character literal
if(str[i]=='') break;
^
10 errors
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.