submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s581694284 | p00150 | C++ | int main(void){
int i,j;
int isprime[1000];
//???????????????????????°????´???°?????¨??????
for(i=0;i<=1000;i++){
isprime[i]=1;
}
//????????????????????????????????????
isprime[0]=isprime[1]=0;
//2??????????????????
for(i=2;i<=1000;i++){
if(isprime[i]==1){
for(j=2*i;j<=1000;j+=i){
isprime[j]=0;
}
}
}
//???????´???°?????????????????????
for(i=2;i<=1000;i++){
if(isprime[i-2]==1 && isprime[i]==1){
print("(%d,%d)",i-2,i);
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:22:25: error: 'print' was not declared in this scope; did you mean 'int'?
22 | print("(%d,%d)",i-2,i);
| ^~~~~
| int
|
s004855361 | p00150 | C++ | int main(void){
int i,j;
int isprime[1000];
for(i=0;i<=1000;i++){
isprime[i]=1;
}
isprime[0]=isprime[1]=0;
for(i=2;i<=1000;i++){
if(isprime[i]==1){
for(j=2*i;j<=1000;j+=i){
isprime[j]=0;
}
}
}
for(i=2;i<=1000;i++){
if(isprime[i-2]==1 && isprime[i]==1){
printf("(%d,%d)",i-2,i);
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:17:25: error: 'printf' was not declared in this scope
17 | printf("(%d,%d)",i-2,i);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | int main(void){
|
s803906683 | p00150 | C++ | #include <stdio.h>
int isprime(int n){
for(int i = 2 ; i*i<=n ;i++){
if(n%i==0)return 0;
}
return 1;
}
int main(){
int n ,i , fir ,sec;
while(scanf("%d" ,&n)){
if(n==0)break;
fir = 0 ,sec = 0;
for(i=n ;i>3 ;i--){
if(number[i] && number[i-2]){
fir = i-2;
sec = i;
break;
}
}
printf("%d %d\n" ,fir ,sec);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:14:10: error: 'number' was not declared in this scope
14 | if(number[i] && number[i-2]){
| ^~~~~~
|
s486772518 | p00150 | C++ | 1
| a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 1
| ^
|
s798227611 | p00150 | C++ | #import<algo.h>
int i,j,n,P[9999];
int main()
{
for(i=2;i*i<9999;i++)for(j=i;j<9999;P[j+=i]=1);
for(;std::cin>>n,n;printf("%d %d\n",i-2,i))
for(i=n;P[i]||P[i-2];i--);
} | a.cc:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
1 | #import<algo.h>
| ^~~~~~
a.cc:1:8: fatal error: algo.h: No such file or directory
1 | #import<algo.h>
| ^~~~~~~~
compilation terminated.
|
s326908009 | p00150 | C++ | #include <iostream>
using namespace std;
int dummy_prime(int n,int i){return i>1 ? n%i ? dummy_prime(n,i-1) : 0 : 1;}
int isprime(int n){return n>1 ? dummy_prime(n,(int)sqrt(n)) : 0;}
int main(){
int n;
while(cin >> n && n){
while(n>4){
if(isprime(n) && isprime(n-2)){
cout << n-2 << " " << n << endl;
break;
}
n--;
}
}
} | a.cc: In function 'int isprime(int)':
a.cc:5:52: error: 'sqrt' was not declared in this scope
5 | int isprime(int n){return n>1 ? dummy_prime(n,(int)sqrt(n)) : 0;}
| ^~~~
|
s567505837 | p00150 | C++ | #include <iostream>
#include <cstdlib>
using namespace std;
int dummy_prime(int n,int i){return i>1 ? n%i ? dummy_prime(n,i-1) : 0 : 1;}
int isprime(int n){return n>1 ? dummy_prime(n,(int)sqrt(n)) : 0;}
int main(){
int n;
while(cin >> n && n){
while(n>4){
if(isprime(n) && isprime(n-2)){
cout << n-2 << " " << n << endl;
break;
}
n--;
}
}
} | a.cc: In function 'int isprime(int)':
a.cc:6:52: error: 'sqrt' was not declared in this scope
6 | int isprime(int n){return n>1 ? dummy_prime(n,(int)sqrt(n)) : 0;}
| ^~~~
|
s002422036 | p00150 | C++ | int i,j,k;char s[9];p(int n){if(n<2)return 0;else if(n==2)return 1;if(n%2==0)return 0;for(i=3;i*i<=n;i+=2)if(n%i==0)return 0;return 1;}main(){while(scanf("%d",&j)){if(!j)break;while(k++<j){if(p(k-1)&&p(k-3)){sprintf(s,"%d %d",k-3,k-1);}}puts(s);}} | a.cc:1:21: error: ISO C++ forbids declaration of 'p' with no type [-fpermissive]
1 | int i,j,k;char s[9];p(int n){if(n<2)return 0;else if(n==2)return 1;if(n%2==0)return 0;for(i=3;i*i<=n;i+=2)if(n%i==0)return 0;return 1;}main(){while(scanf("%d",&j)){if(!j)break;while(k++<j){if(p(k-1)&&p(k-3)){sprintf(s,"%d %d",k-3,k-1);}}puts(s);}}
| ^
a.cc:1:136: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
1 | int i,j,k;char s[9];p(int n){if(n<2)return 0;else if(n==2)return 1;if(n%2==0)return 0;for(i=3;i*i<=n;i+=2)if(n%i==0)return 0;return 1;}main(){while(scanf("%d",&j)){if(!j)break;while(k++<j){if(p(k-1)&&p(k-3)){sprintf(s,"%d %d",k-3,k-1);}}puts(s);}}
| ^~~~
a.cc: In function 'int main()':
a.cc:1:149: error: 'scanf' was not declared in this scope
1 | int i,j,k;char s[9];p(int n){if(n<2)return 0;else if(n==2)return 1;if(n%2==0)return 0;for(i=3;i*i<=n;i+=2)if(n%i==0)return 0;return 1;}main(){while(scanf("%d",&j)){if(!j)break;while(k++<j){if(p(k-1)&&p(k-3)){sprintf(s,"%d %d",k-3,k-1);}}puts(s);}}
| ^~~~~
a.cc:1:209: error: 'sprintf' was not declared in this scope
1 | int i,j,k;char s[9];p(int n){if(n<2)return 0;else if(n==2)return 1;if(n%2==0)return 0;for(i=3;i*i<=n;i+=2)if(n%i==0)return 0;return 1;}main(){while(scanf("%d",&j)){if(!j)break;while(k++<j){if(p(k-1)&&p(k-3)){sprintf(s,"%d %d",k-3,k-1);}}puts(s);}}
| ^~~~~~~
a.cc:1:1: note: 'sprintf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | int i,j,k;char s[9];p(int n){if(n<2)return 0;else if(n==2)return 1;if(n%2==0)return 0;for(i=3;i*i<=n;i+=2)if(n%i==0)return 0;return 1;}main(){while(scanf("%d",&j)){if(!j)break;while(k++<j){if(p(k-1)&&p(k-3)){sprintf(s,"%d %d",k-3,k-1);}}puts(s);}}
a.cc:1:238: error: 'puts' was not declared in this scope
1 | int i,j,k;char s[9];p(int n){if(n<2)return 0;else if(n==2)return 1;if(n%2==0)return 0;for(i=3;i*i<=n;i+=2)if(n%i==0)return 0;return 1;}main(){while(scanf("%d",&j)){if(!j)break;while(k++<j){if(p(k-1)&&p(k-3)){sprintf(s,"%d %d",k-3,k-1);}}puts(s);}}
| ^~~~
|
s137770637 | p00150 | C++ | #include <iostream>
using namespace std;
bool t[10000] = {false};
int main()
{
int n, i;
t[0] = true;
for (i = 2; i * i <= 10000; i++)
{
if (!t[i-1])
{
for (j = i+i; j <= 10000; j+=i)
t[j-1] = true;
}
}
while (cin >> n, n)
{
for (i = n; i >= 5; i--)
{
if ((!t[i-1]) && (!t[i-3]))
{
cout << i-2 << " " << i << endl;
break;
}
}
}
} | a.cc: In function 'int main()':
a.cc:12:30: error: 'j' was not declared in this scope
12 | for (j = i+i; j <= 10000; j+=i)
| ^
|
s529329881 | p00150 | C++ | #include <iostream>
using namespace std;
bool isPrime[10001];
void setPrime( bool *p, int size )
{
memset(p, true, size);
p[0] = p[1] = false;
for(int i=2; i < size; ++i) {
if(!p[i]) continue;
for(int j=i+i; j < size; j+=i) {
p[j] = false;
}
}
}
int main( void )
{
setPrime(isPrime, 10001);
int n;
while(cin >> n, n) {
bool hit = true;
for(int i=n-2; i > 0 && hit; --i) {
if(isPrime[i]) {
if(isPrime[i+2]) {
cout << i << ' ' << i+2 << endl;
hit = false;
}
}
}
}
return 0;
} | a.cc: In function 'void setPrime(bool*, int)':
a.cc:9:9: error: 'memset' was not declared in this scope
9 | memset(p, true, size);
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 |
|
s480858130 | p00150 | C++ | //10018
#include <iostream>
#include <cstdio>
using namespace std;
int p(int n){
for(!n%2){
return 0;
}
else{
for(int i=0;i*i<n;i-=2){
if(!n%1){
return 0;
}
}
return 1;
}
}
int main(){
cin >> n;
for(int k=n;k>0;k--){
if(p(n) && p(n-2)){
cout << n-2 << n << endl;
break;
}
}
} | a.cc: In function 'int p(int)':
a.cc:7:17: error: expected ';' before ')' token
7 | for(!n%2){
| ^
| ;
a.cc:10:9: error: expected primary-expression before 'else'
10 | else{
| ^~~~
a.cc:9:10: error: expected ';' before 'else'
9 | }
| ^
| ;
10 | else{
| ~~~~
a.cc:10:9: error: expected primary-expression before 'else'
10 | else{
| ^~~~
a.cc:9:10: error: expected ')' before 'else'
9 | }
| ^
| )
10 | else{
| ~~~~
a.cc:7:12: note: to match this '('
7 | for(!n%2){
| ^
a.cc:10:9: error: expected primary-expression before 'else'
10 | else{
| ^~~~
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
18 | }
| ^
a.cc: In function 'int main()':
a.cc:24:16: error: 'n' was not declared in this scope
24 | cin >> n;
| ^
|
s809266270 | p00150 | C++ | #include <iostream>
using namespace std;
bool isPrime[10002];
void PrimeCalc()
{
memset(isPrime, 1, sizeof(isPrime));
isPrime[0] = isPrime[1] = false;
for(int i = 2; i < 10001; ++i)
{
if(isPrime[i])
{
for(int j = 2 * i; j < 10001; j += i)
{
isPrime[j] = false;
}
}
}
}
void solve()
{
PrimeCalc();
int n;
while(cin >> n, n)
{
for(int i = n; i >= 7; --i)
{
if(isPrime[i] && isPrime[i - 2])
{
cout << i - 2 << " " << i << endl;
break;
}
}
}
}
int main()
{
solve();
return(0);
} | a.cc: In function 'void PrimeCalc()':
a.cc:8:9: error: 'memset' was not declared in this scope
8 | memset(isPrime, 1, sizeof(isPrime));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 |
|
s905386442 | p00150 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX_N 10000
int prime[MAX_N];
bool is_prime[MAX_N+1];
int sieve(int n){
int p=0;
memset(is_prime,true,sizeof(is_prime));
is_prime[0]=is_prime[1]=false;
for(int i=2;i<=n;i++){
if(is_prime[i]){
prime[p++]=i;
for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
}
}
return p;
}
int main(){
sieve(MAX_N);
vector<int> p;
for(int i=2;i<=MAX_N-2;i++)
if(is_prime[i]&&is_prime[i+2])p.push_back(i+2);
int n;
while(cin>>n&&n){
int a=upper_bound(p.begin(),p.end(),n)-p.begin();
cout<<p[a-1]-2<<' '<<p[a-1]<<endl;
}
return 0;
} | a.cc: In function 'int sieve(int)':
a.cc:12:9: error: 'memset' was not declared in this scope
12 | memset(is_prime,true,sizeof(is_prime));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<vector>
+++ |+#include <cstring>
4 | using namespace std;
|
s568769848 | p00151 | C++ | /*Grid*/
#include<stdio.h>
void func(int,int);
int n;
int i,j;
char a[30][30];
int cnt,max;
int dx[8]={0,1,1,1,0,-1,-1,-1};
int dy[8]={1,1,0,-1,-1,-1,0,1};
int main(void)
{
//int i,j;
while(1){
scanf("%d",&n);
if(n==0) break;
for(i=0;i<n;i++) scanf("%s",a[i]);
//for(i=1;i<n;i++) printf("%s\n",a[i]);
max=0;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(a[i][j]=='1'){
cnt=1;
func(i,j);
//if(max<cnt) max=cnt;
}
}
}
//printf("\n");
//for(i=0;i<n;i++) printf("%s\n",a[i]);
printf("%d\n",max);
}
return 0;
}
void func(int y,int x)
{
int xx,yy,i1;
a[y][x]='0';
for(i1=0;i1<8;i1++){
xx=x+dx[i1]; yy=y+dy[i1];
if(xx>n||xx<=0||yy>n||yy<=0||a[yy][xx]=='0'){
if(max<cnt) max=cnt,/*printf("%d\n",cnt)*/,cnt=0,
func(i,j);
}
else if(xx<n&&xx>=0&&yy<n&&yy>=0&&a[yy][xx]=='1'){
cnt++; func(yy,xx);
}
}
}
| a.cc: In function 'void func(int, int)':
a.cc:41:67: error: expected primary-expression before ',' token
41 | if(max<cnt) max=cnt,/*printf("%d\n",cnt)*/,cnt=0,
| ^
|
s900350288 | p00151 | C++ | /*Grid*/
#include<stdio.h>
void func(int,int);
int n;
int i,j;
char a[255][255];
int cnt,max;
int dx[8]={0,1,1,1,0,-1,-1,-1};
int dy[8]={1,1,0,-1,-1,-1,0,1};
int main(void)
{
//int i,j;
while(1){
scanf("%d",&n);
if(n==0) break;
for(i=0;i<n;i++) scanf("%s",a[i]);
//for(i=1;i<n;i++) printf("%s\n",a[i]);
max=0;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(a[i][j]=='1'){
cnt=1;
func(i,j);
//if(max<cnt) max=cnt;
}
}
}
//printf("\n");
//for(i=0;i<n;i++) printf("%s\n",a[i]);
printf("%d\n",max);
}
return 0;
}
void func(int y,int x)
{
int xx,yy,i1;
a[y][x]='0';
for(i1=0;i1<8;i1++){
xx=x+dx[i1]; yy=y+dy[i1];
if(xx>n||xx<=0||yy>n||yy<=0||a[yy][xx]=='0'){
if(max<cnt) max=cnt,/*printf("%d\n",cnt)*/,cnt=0,
func(i,j);
}
else if(xx<n&&xx>=0&&yy<n&&yy>=0&&a[yy][xx]=='1'){
cnt++; func(yy,xx);
}
}
}
| a.cc: In function 'void func(int, int)':
a.cc:41:67: error: expected primary-expression before ',' token
41 | if(max<cnt) max=cnt,/*printf("%d\n",cnt)*/,cnt=0,
| ^
|
s919207355 | p00151 | C++ | #include <stdio.h>
#include <algorithm>
using namespace std;
int n, a[255][255];
int check(int x, int y, int dx, int dy) {
int ret = 0;
while(0 <= x && x < n && 0 <= y && y < n) {
if(a[y][x] == 0) return ret;
x += dx, y += dy, ret++;
}
return ret;
}
int main() {
while(~scanf("%d", &n), n) {
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) scanf("%d", &a[i][j]);
}
int ret = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
for(int k = -1; k <= 1; k++) {
for(int l = -1; l <= 1; l++) {
if(k != 0 || l != 0) {
ret = max(ret, checK(j, i, l, k));
}
}
}
}
}
printf("%d\n", ret);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:72: error: 'checK' was not declared in this scope; did you mean 'check'?
24 | ret = max(ret, checK(j, i, l, k));
| ^~~~~
| check
|
s250342572 | p00151 | C++ | #include<bits/stdc++.h>
using namespace std;
#define s second
#define f first
int dx[]={1,0,1,-1};
int dy[]={0,1,1,1};
int main(){
int n;
while(cin>>n,n){
string s[n];
for(int i=0;i<n;i++)cin>>s[i];
pair<pair<int,int>,pair<int,int> > a[n][n];
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
a[i][j].f.f=a[i][j].f.s=a[i][j].s.f=a[i][j].s.s=s[i][j]-'0';
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
for(int k=0;k<4;k++){
int x=j+dx[k],y=i+dy[k];
if(x>=0&&y>=0&&y<n&&x<n){
if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
if(k==1&&a[y][x])a[y][x].f.s+=a[i][j].f.s;
if(k==2&&a[y][x])a[y][x].s.f+=a[i][j].s.f;
if(k==3&&a[y][x])a[y][x].s.s+=a[i][j].s.s;
}
}
int res=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++){
res=max(res,a[i][j].f.f);
res=max(res,a[i][j].f.s);
res=max(res,a[i][j].s.f);
res=max(res,a[i][j].s.s);
}
cout<<res<<endl;
}
} | a.cc: In function 'int main()':
a.cc:21:16: error: no match for 'operator&&' (operand types are 'bool' and 'std::pair<std::pair<int, int>, std::pair<int, int> >')
21 | if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
| ~~~~^~~~~~~~~
| | |
| bool std::pair<std::pair<int, int>, std::pair<int, int> >
a.cc:21:16: note: candidate: 'operator&&(bool, bool)' (built-in)
21 | if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
| ~~~~^~~~~~~~~
a.cc:21:16: note: no known conversion for argument 2 from 'std::pair<std::pair<int, int>, std::pair<int, int> >' to 'bool'
In file included from /usr/include/c++/14/valarray:605,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
from a.cc:1:
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:21:24: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
21 | if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:21:24: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
21 | if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:21:24: note: 'std::pair<std::pair<int, int>, std::pair<int, int> >' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
21 | if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:21:24: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
21 | if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:21:24: note: 'std::pair<std::pair<int, int>, std::pair<int, int> >' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
21 | if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
| ^
/usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const valarray<_Tp>&, const valarray<_Tp>&)'
1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed:
a.cc:21:24: note: mismatched types 'const std::valarray<_Tp>' and 'bool'
21 | if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
| ^
/usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed:
a.cc:21:24: note: mismatched types 'const std::valarray<_Tp>' and 'bool'
21 | if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
| ^
/usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed:
a.cc:21:24: note: 'std::pair<std::pair<int, int>, std::pair<int, int> >' is not derived from 'const std::valarray<_Tp>'
21 | if(k==0&&a[y][x])a[y][x].f.f+=a[i][j].f.f;
| ^
a.cc:22:16: error: no match for 'operator&&' (operand types are 'bool' and 'std::pair<std::pair<int, int>, std::pair<int, int> >')
22 | if(k==1&&a[y][x])a[y][x].f.s+=a[i][j].f.s;
| ~~~~^~~~~~~~~
| | |
| bool std::pair<std::pair<int, int>, std::pair<int, int> >
a.cc:22:16: note: candidate: 'operator&&(bool, bool)' (built-in)
22 | if(k==1&&a[y][x])a[y][x].f.s+=a[i][j].f.s;
| ~~~~^~~~~~~~~
a.cc:22:16: note: no known conversion for argument 2 from 'std::pair<std::pair<int, int>, std::pair<int, int> >' to 'bool'
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:22:24: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
22 | if(k==1&&a[y][x])a[y][x].f.s+=a[i][j].f.s;
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:22:24: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
22 | if(k==1&&a[y][x])a[y][x].f.s+=a[i][j].f.s;
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:22:24: note: 'std::pair<std::pair<int, int>, std::pair<int, int> >' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
22 | if(k==1&&a[y][x])a[y][x].f.s+=a[i][j].f.s;
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std |
s122991172 | p00151 | C++ | #include<cstdio.h>
#include<iostream.h>
using namespace std;
int main(void){
int i,j,k,n,max,cnt,x,y;
int dx[4]={1,1,0,-1},dy[4]={0,-1,-1,-1};
char xy[225][225];
while(1){
max=0;
cin>>n;
if(n==0) break;
for(i=0;i<n;i++) cin>>xy[i];
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(xy[i][j]=='1'){
for(k=0;k<4;k++){
cnt=1;
y=i; x=j;
while(1){
y=y+dy[k]; x=x+dx[k];
if(y>=n||x>=n||y<0||x<0||xy[y][x]!='1') break;
cnt++;
}
if(max<cnt) max=cnt;
}
}
}
}
cout<<max<<endl;
}
return 0;
} | a.cc:1:9: fatal error: cstdio.h: No such file or directory
1 | #include<cstdio.h>
| ^~~~~~~~~~
compilation terminated.
|
s266799602 | p00151 | C++ | #include<cstdio>
#include<iostream.h>
using namespace std;
int main(void){
int i,j,k,n,max,cnt,x,y;
int dx[4]={1,1,0,-1},dy[4]={0,-1,-1,-1};
char xy[225][225];
while(1){
max=0;
cin>>n;
if(n==0) break;
for(i=0;i<n;i++) cin>>xy[i];
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(xy[i][j]=='1'){
for(k=0;k<4;k++){
cnt=1;
y=i; x=j;
while(1){
y=y+dy[k]; x=x+dx[k];
if(y>=n||x>=n||y<0||x<0||xy[y][x]!='1') break;
cnt++;
}
if(max<cnt) max=cnt;
}
}
}
}
cout<<max<<endl;
}
return 0;
} | a.cc:2:9: fatal error: iostream.h: No such file or directory
2 | #include<iostream.h>
| ^~~~~~~~~~~~
compilation terminated.
|
s012432161 | p00151 | C++ | #include<cstdio.h>
#include<iostream>
using namespace std;
int main(void){
int i,j,k,n,max,cnt,x,y;
int dx[4]={1,1,0,-1},dy[4]={0,-1,-1,-1};
char xy[225][225];
while(1){
max=0;
cin>>n;
if(n==0) break;
for(i=0;i<n;i++) cin>>xy[i];
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(xy[i][j]=='1'){
for(k=0;k<4;k++){
cnt=1;
y=i; x=j;
while(1){
y=y+dy[k]; x=x+dx[k];
if(y>=n||x>=n||y<0||x<0||xy[y][x]!='1') break;
cnt++;
}
if(max<cnt) max=cnt;
}
}
}
}
cout<<max<<endl;
}
return 0;
} | a.cc:1:9: fatal error: cstdio.h: No such file or directory
1 | #include<cstdio.h>
| ^~~~~~~~~~
compilation terminated.
|
s152397046 | p00151 | C++ | #include<cstdio>
#include<iostream>
using namespace std;
int main(void){
int i,j,k,n,max,cnt,x,y;
int dx[]={1,1,0,-1},dy[]={0,1,1,1};
char xy[225][226];
while(1){
max=0;
cin>>n;
if(n==0) break;
for(i=0;i<n;i++) cin>>xy[i];
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(xy[i][j]=='1'){
for(k=0;k<4;k++){
cnt=1;
y=i; x=j;
while(1){
y=y+dy[k]; x=x+dx[k];
if(y>=n||x>=n||y<0||x<0) break;
if(xy[y][x]!='1')break;
cnt++;
}
if(max<cnt) max=cnt;
}
}
}
}
cout<<max\n;
}
return 0;
} | a.cc:30:26: error: stray '\' in program
30 | cout<<max\n;
| ^
a.cc: In function 'int main()':
a.cc:30:26: error: expected ';' before 'n'
30 | cout<<max\n;
| ^~
| ;
|
s272279939 | p00151 | C++ | #include <iostream>
#include <cmath>
using namespace std;
const int MAX_N = 255;
int n;
char grid[MAX_N][MAX_N];
int dp[MAX_N][MAX_N][4];
int main()
{
while(cin >> n && n) {
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
cin >> grid[i][j];
memset(dp, 0, sizeof(dp));
for(int j = 0; j < n; j++)
for(int k = 0; k < 4; k++)
dp[0][j][k] = grid[0][j] - '0';
int ans = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(grid[i][j] == '0') {
for(int k = 0; k < 4; k++)
dp[i][j][k] = 0;
} else {
dp[i][j][0] = (j) ? dp[i-1][j-1][0] + 1 : 1;
dp[i][j][1] = dp[i-1][j][1] + 1;
dp[i][j][2] = (j != n - 1) ? dp[i-1][j+1][2] + 1 : 1;
dp[i][j][3] = (j) ? dp[i][j-1][3] + 1 : 1;
}
for(int k = 0; k < 4; k++)
ans = max(ans, dp[i][j][k]);
}
}
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:18:9: error: 'memset' was not declared in this scope
18 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <cmath>
+++ |+#include <cstring>
3 |
|
s799056843 | p00151 | C++ | #include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
const int MAX_N = 255;
int n;
char grid[MAX_N][MAX_N];
int dp[MAX_N][MAX_N][4];
int main()
{
while(cin >> n && n) {
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
cin >> grid[i][j];
memset(dp, 0, sizeof(dp));
for(int j = 0; j < n; j++)
for(int k = 0; k < 4; k++)
dp[0][j][k] = grid[0][j] - '0';
int ans = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(grid[i][j] == '0') {
for(int k = 0; k < 4; k++)
dp[i][j][k] = 0;
} else {
dp[i][j][0] = (j) ? dp[i-1][j-1][0] + 1 : 1;
dp[i][j][1] = dp[i-1][j][1] + 1;
dp[i][j][2] = (j != n - 1) ? dp[i-1][j+1][2] + 1 : 1;
dp[i][j][3] = (j) ? dp[i][j-1][3] + 1 : 1;
}
for(int k = 0; k < 4; k++)
ans = max(ans, dp[i][j][k]);
}
}
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:18:9: error: 'memset' was not declared in this scope
18 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <cstdio>
+++ |+#include <cstring>
4 | using namespace std;
|
s801205949 | p00151 | C++ | #include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
const int MAX_N = 255;
int n;
char grid[MAX_N][MAX_N];
int dp[MAX_N][MAX_N][4];
int main()
{
while(cin >> n && n) {
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
cin >> grid[i][j];
memset(dp, 0, sizeof(dp));
for(int j = 0; j < n; j++)
for(int k = 0; k < 4; k++)
dp[0][j][k] = grid[0][j] - '0';
int ans = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(grid[i][j] == '0') {
for(int k = 0; k < 4; k++)
dp[i][j][k] = 0;
} else {
dp[i][j][0] = (j) ? dp[i-1][j-1][0] + 1 : 1;
dp[i][j][1] = dp[i-1][j][1] + 1;
dp[i][j][2] = (j != n - 1) ? dp[i-1][j+1][2] + 1 : 1;
dp[i][j][3] = (j) ? dp[i][j-1][3] + 1 : 1;
}
for(int k = 0; k < 4; k++)
ans = max(ans, dp[i][j][k]);
}
}
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:18:9: error: 'memset' was not declared in this scope
18 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <cstdlib>
+++ |+#include <cstring>
4 | using namespace std;
|
s724031623 | p00151 | C++ | #include <iostream>
#include <string>
#include <cmath>
using namespace std;
int n;
const int MAX = 255;
int M[MAX][MAX];
int solve()
{
int mval = 0;
for(int i=0; i<n; i++)
{
int c = 0;
for(int j=0; j<n; j++)
{
if(M[i][j]==1)
{
c++;
}
else
{
if(c > mval) mval =c;
c = 0;
}
}
if(c > mval)
{
mval = c;
}
}
for(int i=0; i<n; i++)
{
int c = 0;
for(int j=0; j<n; j++)
{
if(M[j][i]==1)
{
c++;
}
else
{
if(c > mval) mval =c;
c = 0;
}
}
if(c > mval)
{
mval = c;
}
}
for(int i=0; i<n; i++)
{
int c = 0;
for(int j=0; j<=i; j++)
{
if(M[i-j][j]==1) c++;
else
{
mval = max(c, mval);
c = 0;
}
}
mval = max(c, mval);
c = 0;
for(int j=0; j<n-i; j++)
{
if(M[i+j][j]==1) c++;
else
{
mval = max(c, mval);
c = 0;
}
}
mval = max(c, mval);
c = 0;
for(int j=0; j<=i; j++)
{
if(M[i-j][n-j-1]==1) c++;
else
{
mval = max(c, mval);
c = 0;
}
}
mval = max(c, mval);
c = 0;
for(int j=0; j<n-i; j++)
{
if(M[i+j][n-j-1]==1) c++;
else
{
mval = max(c, mval);
c = 0;
}
}
mval = max(c, mval);
}
return mval;
}
int main(int argc, char** argv)
{
string tmp;
char c[1];
while(cin >> n, n)
{
for(int i=0; i<n; i++)
{
cin >> tmp;
for(int j=0; j<n; j++)
{
memcpy(c, &tmp[j], sizeof(char));
M[i][j] = atoi(c);
}
}
cout << solve() << endl;;
}
} | a.cc: In function 'int main(int, char**)':
a.cc:128:33: error: 'memcpy' was not declared in this scope
128 | memcpy(c, &tmp[j], sizeof(char));
| ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <cmath>
+++ |+#include <cstring>
4 |
|
s292496687 | p00151 | C++ | #include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;
int n;
const int MAX = 255;
int M[MAX][MAX];
int solve()
{
int mval = 0;
for(int i=0; i<n; i++)
{
int c = 0;
for(int j=0; j<n; j++)
{
if(M[i][j]==1)
{
c++;
}
else
{
if(c > mval) mval =c;
c = 0;
}
}
if(c > mval)
{
mval = c;
}
}
for(int i=0; i<n; i++)
{
int c = 0;
for(int j=0; j<n; j++)
{
if(M[j][i]==1)
{
c++;
}
else
{
if(c > mval) mval =c;
c = 0;
}
}
if(c > mval)
{
mval = c;
}
}
for(int i=0; i<n; i++)
{
int c = 0;
for(int j=0; j<=i; j++)
{
if(M[i-j][j]==1) c++;
else
{
mval = max(c, mval);
c = 0;
}
}
mval = max(c, mval);
c = 0;
for(int j=0; j<n-i; j++)
{
if(M[i+j][j]==1) c++;
else
{
mval = max(c, mval);
c = 0;
}
}
mval = max(c, mval);
c = 0;
for(int j=0; j<=i; j++)
{
if(M[i-j][n-j-1]==1) c++;
else
{
mval = max(c, mval);
c = 0;
}
}
mval = max(c, mval);
c = 0;
for(int j=0; j<n-i; j++)
{
if(M[i+j][n-j-1]==1) c++;
else
{
mval = max(c, mval);
c = 0;
}
}
mval = max(c, mval);
}
return mval;
}
int main(int argc, char** argv)
{
string tmp;
char c[1];
while(cin >> n, n)
{
for(int i=0; i<n; i++)
{
cin >> tmp;
for(int j=0; j<n; j++)
{
memcpy(c, &tmp[j], sizeof(char));
M[i][j] = atoi(c);
}
}
cout << solve() << endl;;
}
} | a.cc: In function 'int main(int, char**)':
a.cc:130:33: error: 'memcpy' was not declared in this scope
130 | memcpy(c, &tmp[j], sizeof(char));
| ^~~~~~
a.cc:6:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include <vector>
+++ |+#include <cstring>
6 |
|
s692735050 | p00151 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
int n;
// arr[y][x]
int arr[260][260];
/*
0: ツ湘」
1: ツ債カ
2: ツ債カツ湘」
3: ツ右ツ湘」
*/
int dp[4][260][260];
int main() {
for(;;) {
scanf(" %d", &n);
if(!n) break;
for(int y = 0; y < n; y++) {
char line[260];
scanf(" %s", line);
for(int x = 0; x < n; x++) {
arr[y][x] = line[x] - '0';
}
}
memset(dp, 0, sizeof dp);
for(int y = 0; y < n; y++) {
for(int x = 0; x < n; x++) {
if(arr[y][x] == 1) {
for(int i = 0; i < 4; i++) {
dp[i][y][x] = 1;
}
if(y >= 1) {
dp[0][y][x] += dp[0][y - 1][x];
}
if(x >= 1) {
dp[1][y][x] += dp[1][y][x - 1];
}
if(x >= 1 && y >= 1) {
dp[2][y][x] += dp[2][y - 1][x - 1];
}
if(y >= 1 && x < n - 1) {
dp[3][y][x] += dp[3][y - 1][x + 1];
}
}
}
}
int maxv = 0;
for(int y = 0; y < n; y++) {
for(int x = 0; x < n; x++) {
for(int k = 0; k < 4; k++) {
maxv = max(maxv, dp[k][y][x]);
}
}
}
printf("%d\n", maxv);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:30:17: error: 'memset' was not declared in this scope
30 | memset(dp, 0, 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;
|
s599252904 | p00151 | C++ | #include<algorithm>
using namespace std;
int main(){
int n;
int field[255][255];
int d;
string tmp;
while(1){
cin >> n;
if(!n)break;
for(int i=0;i<n;i++){
cin >> tmp;
for(int j=0;j<n;j++)field[i][j] = tmp[j]-'0';
}
int ans = 0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(field[i][j]){
d = 1;
while(i+d<n && j-d>=0 && field[i+d][j-d])d++;
ans = max(ans,d);
d = 1;
while(i+d<n && field[i+d][j])d++;
ans = max(ans,d);
d = 1;
while(i+d<n && j+d<n && field[i+d][j+d])d++;
ans = max(ans,d);
d = 1;
while(j+d<n && field[i][j+d])d++;
ans = max(ans,d);
}
}
}
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:8:3: error: 'string' was not declared in this scope
8 | string tmp;
| ^~~~~~
a.cc:2:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
1 | #include<algorithm>
+++ |+#include <string>
2 | using namespace std;
a.cc:11:5: error: 'cin' was not declared in this scope
11 | cin >> n;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include<algorithm>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:15:14: error: 'tmp' was not declared in this scope
15 | cin >> tmp;
| ^~~
a.cc:43:5: error: 'cout' was not declared in this scope
43 | cout << ans << endl;
| ^~~~
a.cc:43:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:43:20: error: 'endl' was not declared in this scope
43 | cout << ans << endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include<algorithm>
+++ |+#include <ostream>
2 | using namespace std;
|
s351141431 | p00151 | C++ | #include<iostream>
#include<algorithm>
#include<numeric>
#include<iterator>
#include<vector>
using namespace std;
typedef unsigned int val;
int tate(char mass[256][256],int n)
{
int count=0,a=0,b=0,ans=-1;
while(1)
{
if(b==n)break;
if(mass[a][b]=='0' || a==n)
{
if(ans<count) ans=count;
a=0;b++;count=0;continue;
}
a++;count++;
}
return ans;
}
int yoko(char mass[256][256],int n)
{
int count=0,a=0,b=0,ans=-1;
while(1)
{
if(a==n)break;
if(mass[a][b]=='0' || b==n)
{
if(ans<count) ans=count;
b=0;a++;count=0;continue;
}
b++;count++;
}
return ans;
}
int main()
{
int n;
while(cin>>n && n)
{
char mass[260][260];
for(int i=0; i<n; i++) cin >> mass[i];
int ans=-1;
if( ans < tate( mass, n ) ) ans = tate( mass, n );
if( ans < yoko( mass, n ) ) ans = yoko( mass, n );
for(int i=0; i<n ;i++)
{
for(int j=0; j<n; j++)
{
if(mass[i][j]=='1')
{
int a=i,b=j,count=0;
while(1)
{
if( mass[a][b] == '0' || b<0 || n<a) break;
mass[a][b]='0';
count++;
a++;b--;
if(b==n){ a++;b=n-1; }
}
if(ans<count) ans=count;
}
}
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:70:33: error: cannot convert 'char (*)[260]' to 'char (*)[256]'
70 | if( ans < tate( mass, n ) ) ans = tate( mass, n );
| ^~~~
| |
| char (*)[260]
a.cc:10:15: note: initializing argument 1 of 'int tate(char (*)[256], int)'
10 | int tate(char mass[256][256],int n)
| ~~~~~^~~~~~~~~~~~~~
a.cc:70:57: error: cannot convert 'char (*)[260]' to 'char (*)[256]'
70 | if( ans < tate( mass, n ) ) ans = tate( mass, n );
| ^~~~
| |
| char (*)[260]
a.cc:10:15: note: initializing argument 1 of 'int tate(char (*)[256], int)'
10 | int tate(char mass[256][256],int n)
| ~~~~~^~~~~~~~~~~~~~
a.cc:71:33: error: cannot convert 'char (*)[260]' to 'char (*)[256]'
71 | if( ans < yoko( mass, n ) ) ans = yoko( mass, n );
| ^~~~
| |
| char (*)[260]
a.cc:34:15: note: initializing argument 1 of 'int yoko(char (*)[256], int)'
34 | int yoko(char mass[256][256],int n)
| ~~~~~^~~~~~~~~~~~~~
a.cc:71:57: error: cannot convert 'char (*)[260]' to 'char (*)[256]'
71 | if( ans < yoko( mass, n ) ) ans = yoko( mass, n );
| ^~~~
| |
| char (*)[260]
a.cc:34:15: note: initializing argument 1 of 'int yoko(char (*)[256], int)'
34 | int yoko(char mass[256][256],int n)
| ~~~~~^~~~~~~~~~~~~~
|
s149260535 | p00152 | C | #include <stdio.h>
int main(void){
int n, i, j;
int classnum[40];
int score[40][21];
scanf("%d", &n);
for(i=0; i<n; i++){
scanf("%d", &classnum[i]);
for(j=0; | main.c: In function 'main':
main.c:14:2: error: expected expression at end of input
14 | for(j=0;
| ^~~
main.c:14:2: error: expected declaration or statement at end of input
main.c:14:2: error: expected declaration or statement at end of input
|
s105406988 | p00152 | C | #include <stdio.h>
int main (void)
{
int a,i,j=0;
int s[][22]={};
do{
scanf("%d",&a);
for(i=0;i<a;i++)
scnaf(s[j][] | main.c: In function 'main':
main.c:9:1: error: implicit declaration of function 'scnaf'; did you mean 'scanf'? [-Wimplicit-function-declaration]
9 | scnaf(s[j][]
| ^~~~~
| scanf
main.c:9:12: error: expected expression before ']' token
9 | scnaf(s[j][]
| ^
main.c:9:12: error: expected declaration or statement at end of input
main.c:9:12: error: expected declaration or statement at end of input
|
s646023443 | p00152 | C++ | #pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
// エイリアス
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using namespace std;
// モジュール
// 処理内容
int main() {
ll m;
while (cin >> m, m) {
vector<ll> id(m);
vector<ll> score(m, 0);
REP(i, m) {
cin >> id[i];
ll sl = 0, r = 0;
ll b = 0;
vector<ll> pins(12, 0);
vector<ll> fpin(12, 0);
vector<bool> strike(12, false);
vector<ll> term(12, 0);
while (sl < 10) {
ll x; cin >> x;
r += x;
if (b == 0) fpin[sl] = x;
b++;
if (r == 10 || b == 2) {
pins[sl] = r;
strike[sl] = r == 10 && b == 1;
b = 0;
r = 0;
sl++;
}
}
if (pins[9] == 10) {
ll x; cin >> x;
fpin[10] = pins[10] = x;
if (x == 10) {
strike[10] = true;
cin >> x;
fpin[11] = pins[11] = x;
strike[11] = x == 10;
}
}
REP(j, 9) {
term[j] = pins[j];
if (pins[j] == 10) {
if (strike[j]) {
if (j+1 < 12) {
term[j] += pins[j+1];
if (strike[j+1] && j+2 < 12) {
term[j] += fpin[j+2];
}
}
} else {
if (j+1 < 12) term[j] += fpin[j+1];
}
}
}
term[9] = pins[9] + pins[10] + pins[11];
score[i] = accumulate(ALL_OF(term), 0LL);
}
vector<ll> rank(m, 0);
iota(ALL_OF(rank), 0LL);
sort(ALL_OF(rank), [&](ll i, ll j) -> bool {
if (score[i] != score[j]) {
return score[i] > score[j];
} else {
return id[i] < id[j];
}
});
REP(_i, m) {
ll i = rank[_i];
cout << id[i] << " " << score[i] << "\n";
}
}
}
| In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:5:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<long long int, std::allocator<long long int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = long long int]': target specific option mismatch
182 | ~allocator() _GLIBCXX_NOTHROW { }
| ^
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:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
132 | struct _Vector_impl
| ^~~~~~~~~~~~
|
s452478075 | p00152 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
bool exist[10000][301];
int main(){
while(true){
int n;
cin >> n;
if(n == 0){
break;
}
for(int i = 0; i < 10000; i++){
for(int j = 0; j < 301; j++){
exist[i][j] = false;
}
}
int id, score, round, round_small, dummy, rest;
bool strike1, strike2, spare;
bool last_throw;
for(int loop = 0; loop < n; loop++){
cin >> id;
round = 1;
round_small = 1;
rest = 10;
score = 0;
strike1 = false;
strike2 = false;
spare = false;
last_throw = false;
while(true){
if(round <= 9){
cin >> dummy;
score += dummy;
if(strike1){
score += dummy;
}
if(strike2){
score += dummy;
}
if(spare){
score += dummy;
spare = false;
}
strike2 = strike1;
strike1 = false;
if(rest == dummy){
if(dummy == 10){
strike1 = true;
}else{
spare = true;
}
round++;
round_small = 1;
rest = 10;
}else{
round_small++;
rest -= dummy;
if(round_small >= 3){
round_small = 1;
round++;
rest = 10;
}
}
}else if(round == 10){
cin >> dummy;
score += dummy;
if(strike1){
score += dummy;
}
if(strike2){
score += dummy;
}
if(spare){
score += dummy;
spare = false;
}
strike2 = strike1;
strike1 = false;
if(rest == dummy){
last_throw = true;
round_small++;
rest = 10
}else{
round_small++;
rest -= dummy;
}
if(round_small >= 3){
if(last_throw){
cin >> dummy;
score += dummy;
}
break;
}
}
//cout << "round_next = " << round << " : rest_next = " << rest << ", score = " << score << endl;
}
exist[id][score] = true;
}
for(int i = 300; i >= 0; i--){
for(int j = 0; j < 10000; j++){
if(exist[j][i]){
cout << j << " " << i << endl;
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:91:58: error: expected ';' before '}' token
91 | rest = 10
| ^
| ;
92 | }else{
| ~
|
s366220136 | p00152 | C++ | #include<iostream>
#include<algorithm>
#include<string>
using namespace std;
pair<int,int> d[40];
int cnt,sparecnt,throwcnt,plus[2];
int numcnt;
void Sc(int u){
if(numcnt>9)plus[0]--;
if(numcnt>10)plus[0]--;
d[u].first+=cnt*plus[0];
plus[0]=plus[1];
plus[1]=1;
throwcnt++;
sparecnt+=cnt;
if(throwcnt==2){
if(sparecnt==10){
plus[0]++;
}
throwcnt=0;
sparecnt=0;
numcnt++;
}
if(cnt==10){
plus[0]++;
plus[1]++;
throwcnt=0;
sparecnt=0;
numcnt++;
}
cnt=0;
}
int main(){
int m;
while(true){
cin>>m;
if(!m)break;
string s;
for(int u=0;u<m;u++){
cin>>d[u].second;
getline(cin,s);
d[u].second=10000-d[u].second;
d[u].first=0;
cnt=0,sparecnt=0,throwcnt=-1,plus[0]=1,plus[1]=1;
numcnt=0;
for(int i=0;i<s.size();i++){
if(s[i]==' '){
Sc(u);
}
else{
cnt*=10;
cnt+=s[i]-'0';
}
}
Sc(u);
}
sort(d,d+m);
for(int i=m-1;i>=0;i--){
cout<<10000-d[i].second<<" "<<d[i].first<<endl;
}
}
return 0;
} | a.cc: In function 'void Sc(int)':
a.cc:9:21: error: reference to 'plus' is ambiguous
9 | if(numcnt>9)plus[0]--;
| ^~~~
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/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
a.cc:10:22: error: reference to 'plus' is ambiguous
10 | if(numcnt>10)plus[0]--;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
a.cc:11:25: error: reference to 'plus' is ambiguous
11 | d[u].first+=cnt*plus[0];
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
a.cc:12:9: error: reference to 'plus' is ambiguous
12 | plus[0]=plus[1];
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
a.cc:12:17: error: reference to 'plus' is ambiguous
12 | plus[0]=plus[1];
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
a.cc:13:9: error: reference to 'plus' is ambiguous
13 | plus[1]=1;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
a.cc:18:25: error: reference to 'plus' is ambiguous
18 | plus[0]++;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
a.cc:25:17: error: reference to 'plus' is ambiguous
25 | plus[0]++;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
a.cc:26:17: error: reference to 'plus' is ambiguous
26 | plus[1]++;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
a.cc: In function 'int main()':
a.cc:44:46: error: reference to 'plus' is ambiguous
44 | cnt=0,sparecnt=0,throwcnt=-1,plus[0]=1,plus[1]=1;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
a.cc:44:56: error: reference to 'plus' is ambiguous
44 | cnt=0,sparecnt=0,throwcnt=-1,plus[0]=1,plus[1]=1;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:6:27: note: 'int plus [2]'
6 | int cnt,sparecnt,throwcnt,plus[2];
| ^~~~
|
s614939306 | p00152 | C++ | #include<iostream>
#include<algorithm>
#include<string>
using namespace std;
pair<int,int> d[40];
int cnt,sparecnt,throwcnt;
int plus[2];
int numcnt;
void Sc(int u){
if(numcnt>9)plus[0]--;
if(numcnt>10)plus[0]--;
d[u].first+=cnt*plus[0];
plus[0]=plus[1];
plus[1]=1;
throwcnt++;
sparecnt+=cnt;
if(throwcnt==2){
if(sparecnt==10){
plus[0]++;
}
throwcnt=0;
sparecnt=0;
numcnt++;
}
if(cnt==10){
plus[0]++;
plus[1]++;
throwcnt=0;
sparecnt=0;
numcnt++;
}
cnt=0;
}
int main(){
int m;
while(true){
cin>>m;
if(!m)break;
string s;
for(int u=0;u<m;u++){
cin>>d[u].second;
getline(cin,s);
d[u].second=10000-d[u].second;
d[u].first=0;
cnt=0,sparecnt=0,throwcnt=-1;
plus[0]=1,plus[1]=1;
numcnt=0;
for(int i=0;i<s.size();i++){
if(s[i]==' '){
Sc(u);
}
else{
cnt*=10;
cnt+=s[i]-'0';
}
}
Sc(u);
}
sort(d,d+m);
for(int i=m-1;i>=0;i--){
cout<<10000-d[i].second<<" "<<d[i].first<<endl;
}
}
return 0;
} | a.cc: In function 'void Sc(int)':
a.cc:10:21: error: reference to 'plus' is ambiguous
10 | if(numcnt>9)plus[0]--;
| ^~~~
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/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
a.cc:11:22: error: reference to 'plus' is ambiguous
11 | if(numcnt>10)plus[0]--;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
a.cc:12:25: error: reference to 'plus' is ambiguous
12 | d[u].first+=cnt*plus[0];
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
a.cc:13:9: error: reference to 'plus' is ambiguous
13 | plus[0]=plus[1];
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
a.cc:13:17: error: reference to 'plus' is ambiguous
13 | plus[0]=plus[1];
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
a.cc:14:9: error: reference to 'plus' is ambiguous
14 | plus[1]=1;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
a.cc:19:25: error: reference to 'plus' is ambiguous
19 | plus[0]++;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
a.cc:26:17: error: reference to 'plus' is ambiguous
26 | plus[0]++;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
a.cc:27:17: error: reference to 'plus' is ambiguous
27 | plus[1]++;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
a.cc: In function 'int main()':
a.cc:46:17: error: reference to 'plus' is ambiguous
46 | plus[0]=1,plus[1]=1;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
a.cc:46:27: error: reference to 'plus' is ambiguous
46 | plus[0]=1,plus[1]=1;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:7:5: note: 'int plus [2]'
7 | int plus[2];
| ^~~~
|
s195398717 | p00152 | C++ | #include <iostream>
#include <string>
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef pair<int, string> Ps;
Ps data[40];
int cnt[11];
int main(){
int m, a, b, c, score;
while(cin >> m && m){
rep(i, m){
score = 0;
fill(cnt, cnt + 10, 0);
cin >> data[i].second;
rep(j, 10){
cin >> a;
score += a;
rep(k, 10) if(cnt[k] > 0){
cnt[k]--;
score += a;
}
if(a == 10){
if(j != 9)cnt[j]+=2;
else{
cin >> b >> c;
score += b + c;
rep(k, 10)if(cnt[k]){
cnt[k]--;
score += b;
}
}
}else{
cin >> b;
score += b;
rep(k, 10) if(cnt[k] > 0){
cnt[k]--;
score += b;
}
if(a + b == 10){
if(j != 9)cnt[j]++;
else{
cin >> c;
score += c;
}
}
}
}
data[i].first = -score;
}
sort(data, data + m);
rep(i, m){
cout << data[i].second << " " << -data[i].first << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:18:14: error: reference to 'data' is ambiguous
18 | cin >> data[i].second;
| ^~~~
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:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:4: note: 'Ps data [40]'
9 | Ps data[40];
| ^~~~
a.cc:56:7: error: reference to 'data' is ambiguous
56 | data[i].first = -score;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:4: note: 'Ps data [40]'
9 | Ps data[40];
| ^~~~
a.cc:58:10: error: reference to 'data' is ambiguous
58 | sort(data, data + m);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:4: note: 'Ps data [40]'
9 | Ps data[40];
| ^~~~
a.cc:58:16: error: reference to 'data' is ambiguous
58 | sort(data, data + m);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:4: note: 'Ps data [40]'
9 | Ps data[40];
| ^~~~
a.cc:58:5: error: 'sort' was not declared in this scope; did you mean 'short'?
58 | sort(data, data + m);
| ^~~~
| short
a.cc:60:15: error: reference to 'data' is ambiguous
60 | cout << data[i].second << " " << -data[i].first << endl;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:4: note: 'Ps data [40]'
9 | Ps data[40];
| ^~~~
a.cc:60:41: error: reference to 'data' is ambiguous
60 | cout << data[i].second << " " << -data[i].first << endl;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:4: note: 'Ps data [40]'
9 | Ps data[40];
| ^~~~
|
s511103796 | p00152 | C++ |
#if 1
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }
void input(vector<vint>& v)
{
rep(i, 10)
{
int f;
cin >> f;
v[i][0] = f;
// 2Úª éê
if(f != 10 || i == 9)
{
int s;
cin >> s;
v[i][1] = s;
}
}
// 10t[ÚÌÅãÌ
if(v[9][0] + v[9][1] == 10 || v[9][1] == 10 || v[9][0] == 10)
{
int l;
cin >> l;
v[9][2] = l;
}
}
int calc(vector<vint> v)
{
// Åã©çßÄ¢
// 10t[ÚÌÝÊ
int res = v[9][0] + v[9][1] + (v[9][2] != -1 ? v[9][2] : 0);
rep(i, 9)
{
if(v[i][0] == 10)
{
res += 10 + v[i + 1][0] + (v[i + 1][1] != -1 ? v[i + 1][1] : (i < 8 ? v[i + 2][0] : v[i + 1][2]));
}
else if(v[i][0] + v[i][1] == 10)
{
res += 10 + v[i + 1][0];
}
else res += v[i][0] + v[i][1];
}
return res;
}
bool pred(pint a, pint b)
{
return a.first > b.first || (a.first == b.first && a.second < b.second);
}
int main()
{
int n;
while(cin >> n && n)
{
vector<pint> pnt(n);
rep(i, n)
{
cin >> pnt[i].second;
vector<vint> v(10, vint(3, -1));
// üÍðó¯æé
input(v);
// ¾_ðvZ·é
pnt[i].first = calc(v);
}
// å«¢Å\[g
sort(ALL(pnt), pred);
rep(i, n)
cout << pnt[i].second << " " << pnt[i].first << endl;
}
} | a.cc:2: error: unterminated #if
2 | #if 1
|
s238589101 | p00152 | C++ | test | a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s561899958 | p00152 | C++ | #include<iostream>
#include<map>
#include<functional>
using namespace std;
int main(void){
int n;
while(1){
scanf("%d",&n);
if(n==0)break;
multimap<int,int, greater<int> > s;
for(int i=0;i<n;i++){
int num,sc[10][3],sck[10],res=0;
memset(sc,0,sizeof(sc));
memset(sck,0,sizeof(sck));
scanf("%d",&num);
for(int j=0;j<10;j++){
if(j<9)for(int k=0;k<2;k++){
scanf("%d",&sc[j][k]);
if(sc[j][k]==10)break;
}
if(j==9)for(int k=0;k<3;k++){
scanf("%d",&sc[j][k]);
if(k==1 && sc[j][0]+sc[j][1]<10)break;
}
}
sck[9]=sc[9][0]+sc[9][1]+sc[9][2];
for(int j=0;j<9;j++){
if(sc[j][0]==10){
sck[j]=10;
if(sc[j+1][0]==10)sck[j]+=10+sc[j+2][0];
else sck[j]+=sc[j+1][0]+sc[j+1][1];
}else if(sc[j][0]+sc[j][1]==10){
sck[j]=10+sc[j+1][0];
}else sck[j]=sc[j][0]+sc[j][1];
}
for(int j=0;j<=9;j++)res+=sck[j];
s.insert(make_pair(res,num));
}
multimap<int,int, greater<int> >::iterator it=s.begin();
while(it!=s.end()){
cout << (*it).second << " " << (*it).first << endl;
it++;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:14:25: error: 'memset' was not declared in this scope
14 | memset(sc,0,sizeof(sc));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<functional>
+++ |+#include <cstring>
4 | using namespace std;
|
s860174318 | p00152 | C++ | #include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
int da[25],sc[41],i,j,k,n,fr;
char ch[100];
while(cin >> n) {
if (n==0) break;
cin.ignore();
for (j=0;j<n;j++) {
gets(ch); k=fr=sc[j]=0;
for (i=0;i<25;i++) da[i]=0;
for (i=0;ch[i]!='\0';i++) if (ch[i]>='0' && ch[i]<='9') da[k]=da[k]*10+ch[i]-'0'; else k++;
k++; i=fr=1; sc[j]=0;
for (fr=1;fr<10;fr++) {
if (da[i]==10) {sc[j]+=10+da[i+1]+da[i+2]; i++;} else {
if (da[i]+da[i+1]==10) sc[j]+=10+da[i+2]; else sc[j]+=da[i]+da[i+1];
i+=2;} }
sc[j]=(sc[j]+da[i]+da[i+1]+da[i+2])*10000+da[0];
}
sort(sc,sc+n);
for (i=n-1;i>=0;i--) cout << sc[i] % 10000 << ' ' << sc[i]/10000 << endl;
}
re | a.cc: In function 'int main()':
a.cc:13:6: error: 'gets' was not declared in this scope; did you mean 'getw'?
13 | gets(ch); k=fr=sc[j]=0;
| ^~~~
| getw
a.cc:26:2: error: 're' was not declared in this scope
26 | re
| ^~
a.cc:26:4: error: expected '}' at end of input
26 | re
| ^
a.cc:6:13: note: to match this '{'
6 | int main() {
| ^
|
s340218321 | p00152 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
typedef pair<int,int> P;
vector<int> Point(string s){
stringstream ss(s);
int num;
vector<int> v;
while(ss >> num){
v.push_back(num);
}
return v;
}
int getScore(string s){
vector<int> a = Point(s);
int len = (int)a.size();
int score = 0 , sum = 0;
int plus[10] = {0};
int p = 0,n = 0;
for(int i = 0 ; i < len ; i++){
if(p >= 9){
p++;
score += a[i];
}else{
if(a[i] == 10){
score += a[i];
plus[p++] = a[i+1] + a[i+2];
}else{
n++;
sum += a[i];
if(n == 2){
n = 0;
score += sum;
if(sum == 10){
plus[p++] = a[i+1];
}else{
p++;
}
sum = 0;
}
}
}
}
for(int i = 0 ; i < 10 ; i++){
score += plus[i];
}
return -score;
}
int main(){
int m;
while(cin >> m ,m){
vector<P> v;
string pin;
for(int i = 0 ; i < m ; i++){
int score = 0,num;
cin >> num;
getline(cin,pin);
score = getScore(pin);
v.push_back(P(score,num));
}
sort(v.begin(),v.end());
for(int i = 0 ; i < m ; i++){
cout << v[i].second << " " << -v[i].first << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:73:5: error: 'sort' was not declared in this scope; did you mean 'short'?
73 | sort(v.begin(),v.end());
| ^~~~
| short
|
s611174711 | p00153 | Java |
import java.util.Arrays;
import java.util.Scanner;
/**
* AOJ id=0153
* Triangle and Circle
* @author scache
*
*/
public class Main0153 {
public static void main(String[] args) {
Main0153 p = new Main0153();
}
public Main0153() {
Scanner sc = new Scanner(System.in);
while(true){
int[] x = new int[3];
int[] y = new int[3];
for(int i=0;i<3;i++){
x[i] = sc.nextInt();
y[i] = sc.nextInt();
if(i==0 && x[i]==0 && y[i]==0)
return;
}
int rx = sc.nextInt();
int ry = sc.nextInt();
int r = sc.nextInt();
System.out.println(solve(x, y, rx, ry, r));
}
}
private String solve(int[] x, int[] y, int rx, int ry, int r) {
int[] vx = new int[3];
int[] vy = new int[3];
for(int i=0;i<3;i++){
vx[i] = x[(i+1)%3]-x[i];
vy[i] = y[(i+1)%3]-y[i];
}
int inCircle = 0;
for(int i=0;i<3;i++){
int xd = (x[i]-rx)*(x[i]-rx);
int yd = (y[i]-ry)*(y[i]-ry);
if(r*r >= xd+yd)
inCircle++;
}
if(inCircle==3)
return "b";
// else if(inCircle==1 || inCircle==2)
// // 接している場合は三角形の中に円がはいっている可能性がある?
// return "c";
int l=0;
for(int i=0;i<3;i++){
if(vx[i]*(ry-y[i])-(rx-x[i])*vy[i]<0)
l++;
}
if(l==3 || l==0)
return "a";
for(int i=0;i<3;i++){
int vrx = rx-x[i];
int vry = ry-y[i];
int inp = vx[i]*vrx+vy[i]*vry;
if(inp<0){
if(vrx*vrx+vry*vry < r*r)
return "c";
}else{
if(inp > vx[i]*vx[i]+vy[i]*vy[i]){
if((rx-x[(i+1)%3])*(rx-x[(i+1)%3])+(ry-y[(i+1)%3])*(ry-y[(i+1)%3]) <r*r)
return "c";
}else{
if(vrx*vrx+vry*vry-inp*inp < (long)(vx[i]*vx[i]+vy[i]*vy[i])*r*r){
return "c";
}
}
}
}
return "d";
}
} | Main.java:11: error: class Main0153 is public, should be declared in a file named Main0153.java
public class Main0153 {
^
1 error
|
s361456590 | p00153 | C | #define hypot _hypot
float q;
A,B,C,D,E,F,R;
M(a,b,c,d,e,f){
e=c-a;
f=d-b;
q=fabs(-f*a+e*b)/hypot(e,f);
if(a*e+b*f<0&&c*e+d*f>0&&q<=R)
if(q<R)
return 2;
else
return 1;
return 0;
}
I(){
q=E*B-F*A;
return(C*F-D*E)*q>0&q*(A*D-B*C)>0;
}
main(v,w,o,c){
for(;scanf("%d%d%d%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F,&v,&w,&R),A;){
A-=v,B-=w;
C-=v,D-=w;
E-=v,F-=w;
o=(A*A+B*B>R*R)+(C*C+D*D>R*R)+(E*E+F*F>R*R);
if(!o)
puts("b");
else if(o==3){
c=M(C,D,E,F)|M(E,F,A,B)|M(A,B,C,D);
if(c&2)
puts("c");
else if(c&1){
if(I())
puts("a");
else
puts("c");
}else{
if(I())
puts("a");
else
puts("d");
}
}else
puts("c");
}
return 0;
} | main.c:3:1: warning: data definition has no type or storage class
3 | A,B,C,D,E,F,R;
| ^
main.c:3:1: error: type defaults to 'int' in declaration of 'A' [-Wimplicit-int]
main.c:3:3: error: type defaults to 'int' in declaration of 'B' [-Wimplicit-int]
3 | A,B,C,D,E,F,R;
| ^
main.c:3:5: error: type defaults to 'int' in declaration of 'C' [-Wimplicit-int]
3 | A,B,C,D,E,F,R;
| ^
main.c:3:7: error: type defaults to 'int' in declaration of 'D' [-Wimplicit-int]
3 | A,B,C,D,E,F,R;
| ^
main.c:3:9: error: type defaults to 'int' in declaration of 'E' [-Wimplicit-int]
3 | A,B,C,D,E,F,R;
| ^
main.c:3:11: error: type defaults to 'int' in declaration of 'F' [-Wimplicit-int]
3 | A,B,C,D,E,F,R;
| ^
main.c:3:13: error: type defaults to 'int' in declaration of 'R' [-Wimplicit-int]
3 | A,B,C,D,E,F,R;
| ^
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
4 | M(a,b,c,d,e,f){
| ^
main.c: In function 'M':
main.c:4:1: error: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c:4:1: error: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c:4:1: error: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:4:1: error: type of 'd' defaults to 'int' [-Wimplicit-int]
main.c:4:1: error: type of 'e' defaults to 'int' [-Wimplicit-int]
main.c:4:1: error: type of 'f' defaults to 'int' [-Wimplicit-int]
main.c:7:11: error: implicit declaration of function 'fabs' [-Wimplicit-function-declaration]
7 | q=fabs(-f*a+e*b)/hypot(e,f);
| ^~~~
main.c:1:1: note: include '<math.h>' or provide a declaration of 'fabs'
+++ |+#include <math.h>
1 | #define hypot _hypot
main.c:7:11: warning: incompatible implicit declaration of built-in function 'fabs' [-Wbuiltin-declaration-mismatch]
7 | q=fabs(-f*a+e*b)/hypot(e,f);
| ^~~~
main.c:7:11: note: include '<math.h>' or provide a declaration of 'fabs'
main.c:1:15: error: implicit declaration of function '_hypot'; did you mean 'hypot'? [-Wimplicit-function-declaration]
1 | #define hypot _hypot
| ^~~~~~
main.c:7:26: note: in expansion of macro 'hypot'
7 | q=fabs(-f*a+e*b)/hypot(e,f);
| ^~~~~
main.c: At top level:
main.c:15:1: error: return type defaults to 'int' [-Wimplicit-int]
15 | I(){
| ^
main.c:19:1: error: return type defaults to 'int' [-Wimplicit-int]
19 | main(v,w,o,c){
| ^~~~
main.c: In function 'main':
main.c:19:1: error: type of 'v' defaults to 'int' [-Wimplicit-int]
main.c:19:1: error: type of 'w' defaults to 'int' [-Wimplicit-int]
main.c:19:1: error: type of 'o' defaults to 'int' [-Wimplicit-int]
main.c:19:1: error: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:20:14: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
20 | for(;scanf("%d%d%d%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F,&v,&w,&R),A;){
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | #define hypot _hypot
main.c:20:14: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
20 | for(;scanf("%d%d%d%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F,&v,&w,&R),A;){
| ^~~~~
main.c:20:14: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:26:25: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
26 | puts("b");
| ^~~~
main.c:26:25: note: include '<stdio.h>' or provide a declaration of 'puts'
|
s857223525 | p00153 | 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 sig(double r) { return r < -EPS ? -1 : r > EPS ? 1 : 0; }
struct P {
double x, y;
P() {}
P(double x, double y) : x(x), y(y) {}
P operator+(const P &a) const { return P(x + a.x, y + a.y); }
P operator-(const P &a) const { return P(x - a.x, y - a.y); }
P operator*(const P &a) const { return P(x * a.x - y * a.y, x * a.y + y * a.x); }
P operator-() const { return P(-x, -y); }
P operator*(const double &k) const { return P(x * k, y * k); }
P operator/(const double &k) const { return P(x / k, y / k); }
double abs2() const { return x * x + y * y; }
double abs() const { return sqrt(abs2()); }
double arg() const { return atan2(y, x); }
double dot(const P &a) const { return x * a.x + y * a.y; }
double det(const P &a) const { return x * a.y - y * a.x; }
P proj(const P &a) const { double k = dot(a) / abs2(); return P(x * k, y * k); }
bool operator<(const P &a) const { return x != a.x ? x < a.x : y < a.y; }
bool operator==(const P &a) const { return sig(x - a.x) == 0 && sig(y - a.y) == 0; }
};
ostream &operator<<(ostream&os, const P&a) { os << "(" << a.x << ", " << a.y << ")"; return os; }
double tri(P a, P b, P c) { return (b - a).det(c - a); }
struct L {
P a, b;
L() {}
L(P a, P b) : a(a), b(b) {}
P vec() const { return b - a; }
P proj(const P &p) const { return a + vec().proj(p - a); }
P refl(const P &p) const { return proj(p) * 2 - p; }
int iSP(const P &p) const {
int s = sig(vec().det(p - a));
if (s != 0) return s;
if (sig(vec().dot(p - a)) < 0) return -2;
if (sig(vec().dot(p - b)) < 0) return 2;
return 0;
}
int iLL(const L &l) const {
if (sig(vec().det(l.vec()))) return 1;
if (sig(vec().det(l.a - a))) return 0;
return -1;
}
bool iLS(const L &l) const { return sig(tri(a, b, l.a)) * sig(tri(a, b, l.b)) <= 0; }
bool iSS(const L &l) const { return iLS(l) && l.iLS(*this); }
P pLL(const L &l) const { return a + vec() * (l.a - a).det(l.vec()) / b.det(l.vec()); }
double dLP(const P &p) const { return abs(tri(a, b, p)) / vec().abs(); }
double dSP(const P &p) const {
if (sig(vec().dot(p - a)) <= 0) return (p - a).abs();
if (sig(vec().dot(p - b)) >= 0) return (p - b).abs();
return dLP(p);
}
double dLL(const L &l) const { return iLL(l) ? 0 : dLP(l.a); }
double dLS(const L &l) const { return iLS(l) ? 0 : min(dLP(l.a), dLP(l.b)); }
double dSS(const L &l) const { return iSS(l) ? 0 : min(min(dSP(l.a), dSP(l.b)), min(l.dSP(a), l.dSP(b))); }
};
struct C {
P p;
double r;
C() {}
C(P p, double r) : p(p), r(r) {}
int iCC(C c) {
double d = (c.p - p).abs();
if (sig(d) == 0 && sig(r - c.r) == 0) return -1;
if (sig(r - c.r - d) > 0) return 2;
if (sig(c.r - r - d) > 0) return -2;
return (sig(r + c.r - d) >= 0) ? 1 : 0;
}
bool iCS(L l) {
return (sig(r - l.dSP(p)) >= 0&& sig(r - max((l.a - p).abs(), (l.b - p).abs())) <= 0);
}
pair<P,P> pCC(C c) {
double d = (c.p - p).abs();
double x = (d * d + r * r - c.r * c.r) / (d * 2);
P e = (c.p - p) / d, w = e * P(0, 1) * sqrt(max(r * r - x * x, 0.0));
return make_pair(p + e * x - w, p + e * x + w);
}
pair<P,P> pCL(L l) {
P h = l.proj(p);
double d = (h - p).abs();
double y = sqrt(max(r * r - d * d, 0.0));
P e = (l.b - l.a) / (l.b - l.a).abs();
return make_pair(h - e * y, h + e * y);
}
pair<P,P> tCP(P p) {
double d2 = (p - this->p).abs2();
double x = sqrt(max(d2 - r * r, 0.0));
P h = this->p + (p - this->p) * (r * r / d2);
P w = (p - this->p) * P(0, 1) * (x * r / d2);
return make_pair(h - w, h + w);
}
double aCC(C c) {
double d = (p - c.p).abs();
if (sig(r - c.r - d) >= 0) return c.r * c.r * PI;
if (sig(c.r - r - d) >= 0) return r * r * PI;
if (sig(r + c.r - d) <= 0) return 0;
double x = (d * d + r * r - c.r * c.r) / (d * 2);
double h = sqrt(r * r - x * x);
return r * r * atan2(h, x) + c.r * c.r * atan2(h, d - x) - d * h;
}
};
int main() {
int x[3], y[3];
int xx, yy, r;
P p[3],g;
L s[3];
C c;
IL {
cin >> x[0] >> y[0];
if (x[0] == 0 && y[0] == 0) break;
cin >> x[1] >> y[1];
cin >> x[2] >> y[2];
cin >> xx >> yy;
cin >> r;
rep(i, 3) p[i] = P(x[i], y[i]);
g = (p[0] + p[1] + p[2]) / 3;
rep(i, 3) s[i] = L(p[i], p[(i+1)%3]);
c = C(P(xx, yy), r);
if (!(L(g, c.p)).iSS(s[0]) && !(L(g, c.p)).iSS(s[1]) && !(L(g, c.p)).iSS(s[2]) && sig(s[0].dSP(c.p) - c.r) > 0 && sig(s[1].dSP(c.p) - c.r) > 0 && sig(s[2].dSP(c.p) - c.r) > 0) {
cout << "a" << endl;
continue;
}
if (sig((c.p - p[0]).abs() - r) < 0 && sig((c.p - p[1]).abs() - r) < 0 && sig((c.p - p[2]).abs() - r) < 0) {
cout << "b" << endl;
continue;
}
if (sig(s[0].dSP(c.p) - c.r) <= 0 || sig(s[1].dSP(c.p) - c.r) <= 0 || sig(s[2].dSP(c.p) - c.r) <= 0) {
cout << "c" << endl;
continue;
}
cout << "d" << endl;
}
return 0;
} | main.c:1:9: fatal error: cstdio: No such file or directory
1 | #include<cstdio>
| ^~~~~~~~
compilation terminated.
|
s608959672 | p00153 | C | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
int i,j,n,m;
int x1,y1,x2,y2,x3,y3,wx,wy,r;
int crosscheck(int tx,int ty,int sx,int sy,int wx,int wy,int rr){
int abx=sx-tx,aby=sy-ty;
int awx=wx-tx,awy=wy-ty;
int bwx=wx-sx,bwy=wy-sy;
int rr2=rr*rr;
int aw2=awx*awx+awy*awy;
int bw2=bwx*bwx+bwy*bwy;
int ab2=abx*abx+aby*aby;
int tim=abx*awy-aby*awx;
int abw=abx*awx+aby*awy;
if(aw2<rr2 && bw2<rr2)return 0;
if(aw2<rr2 || bw2<rr2)return 1;
if( tim*tim/ab2 > (double)rr2)return 0;
if(abw<0)return 0;
if(abw>ab2)return 0;
return 1;
}
int main(){
if(crosscheck(10,3,10,9,10,10,1))printf("OK\n");
while(scanf("%d %d",&x1,&y1)*x1){
scanf("%d %d %d %d %d %d %d",&x2,&y2,&x3,&y3,&wx,&wy,&r);
if(crosscheck(x1,y1,x2,y2,wx,wy,r)){printf("c\n");continue;}
if(crosscheck(x2,y2,x3,y3,wx,wy,r)){printf("c\n");continue;}
if(crosscheck(x3,y3,x1,y1,wx,wy,r)){printf("c\n");continue;}
int d1=(x1-wx)*(x1-wx)+(y1-wy)*(y1-wy)-r*r;
int d2=(x2-wx)*(x2-wx)+(y2-wy)*(y2-wy)-r*r;
int d3=(x3-wx)*(x3-wx)+(y3-wy)*(y3-wy)-r*r;
if(d1<=0 && d2<=0 && d3<=0){printf("b\n");continue;}
if(d1==0 || d2==0 || d3==0){printf("d\n");continue;}
int tim1=(wx-x1)*(y2-y1)-(wy-y1)*(x2-x1);
int tim2=(wx-x2)*(y3-y2)-(wy-y2)*(x3-x2);
int tim3=(wx-x3)*(y1-y3)-(wy-y3)*(x1-x3);
if(tim1*tim2>0 && tim2*tim3>0){printf("a\n");continue;}
printf("d\n");
}
return 0;
} | main.c:6:8: error: 'y1' redeclared as different kind of symbol
6 | int x1,y1,x2,y2,x3,y3,wx,wy,r;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
from /usr/include/stdio.h:28,
from main.c:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration of 'y1' with type 'double(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
|
s072647946 | p00153 | C++ | #include "stdafx.h"
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <fstream>
using namespace std;
struct Point{
int x;
int y;
};
struct Delta{
Point p[3];
};
struct Circle{
Point p;
int radius;
};
double distance(Point p1, Point p2){
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
double dist_line(Point pl1, Point pl2, Point p){
int a = pl1.x - pl2.x;
int b = pl2.y - pl1.y;
int c = pl1.y * pl2.x - pl1.x * pl2.y;
double ans = b * p.x + a * p.y + c;
ans = (ans >= 0) ? ans : -ans;
return ans / sqrt(a*a + b*b);
}
int main(void){
string str;
ifstream ifs("../input.txt");
if (ifs.fail()) {
cerr << "cannot find the file" << endl;
return 1;
}
while(1){
Circle *c = (Circle *) malloc(sizeof(Circle));
Delta *d = (Delta *) malloc(sizeof(Delta));
for (int i = 0; i < 5; i++) {
getline(ifs, str);
if(str == "0 0") break;
int j;
for(j = 0; j <(int) str.size(); j++){
if(str[j] == ' '){
str[j] = '\0';
break;
}
}
switch(i){
case 0:
case 1:
case 2:
d->p[i].x = atoi(str.c_str());
d->p[i].y = atoi(&str[j+1]);
break;
case 3:
c->p.x = atoi(str.c_str());
c->p.y = atoi(&str[j+1]);
break;
case 4:
c->radius = atoi(str.c_str());
break;
}
}
if(str == "0 0") break;
if(distance(d->p[0], c->p) <= c->radius&& distance(d->p[1], c->p) <= c->radius&& distance(d->p[2], c->p) <= c->radius){
cout << 'b' << endl;
}
else if(dist_line(d->p[0], d->p[1], c->p) >= c->radius&& dist_line(d->p[0], d->p[2], c->p) >= c->radius&& dist_line(d->p[1], d->p[2], c->p) >= c->radius){
if (dist_line(d->p[0], d->p[1], d->p[2]) <= distance(d->p[0], c->p) && dist_line(d->p[1], d->p[2], d->p[0]) <= distance(d->p[1], c->p) && dist_line(d->p[2], d->p[0], d->p[1]) <= distance(d->p[2], c->p))
cout << 'd' << endl;
else
cout << 'a' << endl;
}
else if(dist_line(d->p[0], d->p[1], c->p) <= c->radius|| dist_line(d->p[0], d->p[2], c->p) <= c->radius|| dist_line(d->p[1], d->p[2], c->p) <= c->radius){
cout << 'c' << endl;
}
else{
}
}
return 0;
} | a.cc:1:10: fatal error: stdafx.h: No such file or directory
1 | #include "stdafx.h"
| ^~~~~~~~~~
compilation terminated.
|
s707961490 | p00153 | 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; }
};
class Segment {
public:
Point p1, p2;
Segment() : p1(Point()), p2(Point()) {};
Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_) {};
Segment(long double p1x, long double p1y, long double p2x, long double p2y) : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)) {};
friend bool operator==(const Segment& s1, const Segment& s2) { return (s1.p1 == s2.p1 && s1.p2 == s2.p2) || (s1.p1 == s2.p2 && s1.p2 == s2.p1); }
friend bool operator!=(const Segment& s1, const Segment& s2) { return !(s1 == s2); }
};
class Circle {
public:
Point p; long double r;
Circle() : p(Point()), r(0.0L) {};
Circle(Point p_) : p(p_), r(0.0L) {};
Circle(Point p_, long double r_) : p(p_), r(r_) {};
Circle(long double x_, long double y_) : p(Point(x_, y_)), r(0.0L) {};
Circle(long double x_, long double y_, long double r_) : p(Point(x_, y_)), r(r_) {};
friend bool operator==(const Circle& c1, const Circle& c2) { return c1.p == c2.p && c1.r == c2.r; }
friend bool operator!=(const Circle& c1, const Circle& c2) { return !(c1 == c2); }
};
// ------ 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 arg(const Point& a) { return atan2l(a.py, a.px); }
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; }
Point pol(long double r, long double d) { return Point(cosl(d) * r, sinl(d) * r); }
Point prj(const Segment& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
Point prj(const Line& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
Point rfl(const Segment& a, const Point& b) { return b + (prj(a, b) - b) * 2.0L; }
Point rfl(const Line& a, const Point& b) { return b + (prj(a, b) - b) * 2.0L; }
int ccw(Point p0, Point p1, Point p2) {
Point a = p1 - p0, b = p2 - p0;
if (crs(a, b) > 1e-10) return 1;
if (crs(a, b) < -1e-10) return -1;
if (dot(a, b) < -1e-10) return 2;
if (norm(a) < norm(b)) return -2;
return 0;
}
long double dst(const Point& a, const Point& b) {
return sqrtl((a.px - b.px) * (a.px - b.px) + (a.py - b.py) * (a.py - b.py));
}
long double dst(const Line& a, const Point& b) {
return abs(crs(a.p2 - a.p1, b - a.p1) / abs(a.p2 - a.p1));
}
long double dst(const Segment& a, const Point& b) {
if (dot(a.p2 - a.p1, b - a.p1) < 0.0) return abs(b - a.p1);
if (dot(a.p1 - a.p2, b - a.p2) < 0.0) return abs(b - a.p2);
return abs(crs(a.p2 - a.p1, b - a.p1) / abs(a.p2 - a.p1));
}
long double dst(const Segment& a, const Segment& b) {
if (its(a, b)) return 0;
return min( { dst(a, b.p1), dst(a, b.p2), dst(b, a.p1), dst(b, a.p2) });
}
int contain(vector<Point> v, Point p) {
bool in = false;
for (int i = 0; i < v.size(); ++i) {
Point a = v[i] - p, b = v[(i + 1) % v.size()] - p;
if (a.py > b.py) swap(a, b);
if (a.py <= 0 && 0 < b.py)
if (crs(a, b) < 0) in = !in;
if (crs(a, b) == 0 && dot(a, b) <= 0) return 1;
}
return in ? 2 : 0;
}
// ------ Main ------ //
Point p1, p2, p3; Segment l1, l2, l3; Circle c;
int main() {
while(cin >> p1.px >> p1.py >> p2.px >> p2.py >> p3.px >> p3.py >> c.p.px >> c.p.py >> c.r) {
l1 = Segment(p1, p2);
l2 = Segment(p2, p3);
l3 = Segment(p3, p1);
if(dst(p1, c.p) <= c.r && dst(p2, c.p) <= c.r && dst(p3, c.p) <= c.r) printf("b\n");
else if(dst(l1, c.p) >= c.r && dst(l2, c.p) >= c.r && dst(l3, c.p) >= c.r) printf(contain({p1, p2, p3}, c.p) ? "a\n" : "d\n");
else printf("c\n");
}
} | a.cc:56:17: error: 'Line' does not name a type
56 | Point prj(const Line& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
| ^~~~
a.cc: In function 'Point prj(const int&, const Point&)':
a.cc:56:53: error: request for member 'p1' in 'a', which is of non-class type 'const int'
56 | Point prj(const Line& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
| ^~
a.cc:56:61: error: request for member 'p2' in 'a', which is of non-class type 'const int'
56 | Point prj(const Line& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
| ^~
a.cc:56:68: error: request for member 'p1' in 'a', which is of non-class type 'const int'
56 | Point prj(const Line& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
| ^~
a.cc:56:84: error: request for member 'p1' in 'a', which is of non-class type 'const int'
56 | Point prj(const Line& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
| ^~
a.cc:56:90: error: request for member 'p2' in 'a', which is of non-class type 'const int'
56 | Point prj(const Line& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
| ^~
a.cc:56:97: error: request for member 'p1' in 'a', which is of non-class type 'const int'
56 | Point prj(const Line& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
| ^~
a.cc:56:110: error: request for member 'p2' in 'a', which is of non-class type 'const int'
56 | Point prj(const Line& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
| ^~
a.cc:56:117: error: request for member 'p1' in 'a', which is of non-class type 'const int'
56 | Point prj(const Line& a, const Point& b) { return a.p1 + (a.p2 - a.p1) * dot(b - a.p1, a.p2 - a.p1) / norm(a.p2 - a.p1); }
| ^~
a.cc: At global scope:
a.cc:58:17: error: 'Line' does not name a type
58 | Point rfl(const Line& a, const Point& b) { return b + (prj(a, b) - b) * 2.0L; }
| ^~~~
a.cc:70:23: error: 'Line' does not name a type
70 | long double dst(const Line& a, const Point& b) {
| ^~~~
a.cc: In function 'long double dst(const int&, const Point&)':
a.cc:71:26: error: request for member 'p2' in 'a', which is of non-class type 'const int'
71 | return abs(crs(a.p2 - a.p1, b - a.p1) / abs(a.p2 - a.p1));
| ^~
a.cc:71:33: error: request for member 'p1' in 'a', which is of non-class type 'const int'
71 | return abs(crs(a.p2 - a.p1, b - a.p1) / abs(a.p2 - a.p1));
| ^~
a.cc:71:43: error: request for member 'p1' in 'a', which is of non-class type 'const int'
71 | return abs(crs(a.p2 - a.p1, b - a.p1) / abs(a.p2 - a.p1));
| ^~
a.cc:71:55: error: request for member 'p2' in 'a', which is of non-class type 'const int'
71 | return abs(crs(a.p2 - a.p1, b - a.p1) / abs(a.p2 - a.p1));
| ^~
a.cc:71:62: error: request for member 'p1' in 'a', which is of non-class type 'const int'
71 | return abs(crs(a.p2 - a.p1, b - a.p1) / abs(a.p2 - a.p1));
| ^~
a.cc: In function 'long double dst(const Segment&, const Segment&)':
a.cc:79:13: error: 'its' was not declared in this scope
79 | if (its(a, b)) return 0;
| ^~~
|
s502327807 | p00153 | 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; }
};
class Segment {
public:
Point p1, p2;
Segment() : p1(Point()), p2(Point()) {};
Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_) {};
Segment(long double p1x, long double p1y, long double p2x, long double p2y) : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)) {};
friend bool operator==(const Segment& s1, const Segment& s2) { return (s1.p1 == s2.p1 && s1.p2 == s2.p2) || (s1.p1 == s2.p2 && s1.p2 == s2.p1); }
friend bool operator!=(const Segment& s1, const Segment& s2) { return !(s1 == s2); }
};
class Circle {
public:
Point p; long double r;
Circle() : p(Point()), r(0.0L) {};
Circle(Point p_) : p(p_), r(0.0L) {};
Circle(Point p_, long double r_) : p(p_), r(r_) {};
Circle(long double x_, long double y_) : p(Point(x_, y_)), r(0.0L) {};
Circle(long double x_, long double y_, long double r_) : p(Point(x_, y_)), r(r_) {};
friend bool operator==(const Circle& c1, const Circle& c2) { return c1.p == c2.p && c1.r == c2.r; }
friend bool operator!=(const Circle& c1, const Circle& c2) { return !(c1 == c2); }
};
// ------ 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 arg(const Point& a) { return atan2l(a.py, a.px); }
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; }
Point pol(long double r, long double d) { return Point(cosl(d) * r, sinl(d) * r); }
int ccw(Point p0, Point p1, Point p2) {
Point a = p1 - p0, b = p2 - p0;
if (crs(a, b) > 1e-10) return 1;
if (crs(a, b) < -1e-10) return -1;
if (dot(a, b) < -1e-10) return 2;
if (norm(a) < norm(b)) return -2;
return 0;
}
long double dst(const Point& a, const Point& b) {
return sqrtl((a.px - b.px) * (a.px - b.px) + (a.py - b.py) * (a.py - b.py));
}
long double dst(const Segment& a, const Point& b) {
if (dot(a.p2 - a.p1, b - a.p1) < 0.0) return abs(b - a.p1);
if (dot(a.p1 - a.p2, b - a.p2) < 0.0) return abs(b - a.p2);
return abs(crs(a.p2 - a.p1, b - a.p1) / abs(a.p2 - a.p1));
}
long double dst(const Segment& a, const Segment& b) {
if (its(a, b)) return 0;
return min( { dst(a, b.p1), dst(a, b.p2), dst(b, a.p1), dst(b, a.p2) });
}
int contain(vector<Point> v, Point p) {
bool in = false;
for (int i = 0; i < v.size(); ++i) {
Point a = v[i] - p, b = v[(i + 1) % v.size()] - p;
if (a.py > b.py) swap(a, b);
if (a.py <= 0 && 0 < b.py)
if (crs(a, b) < 0) in = !in;
if (crs(a, b) == 0 && dot(a, b) <= 0) return 1;
}
return in ? 2 : 0;
}
// ------ Main ------ //
Point p1, p2, p3; Segment l1, l2, l3; Circle c;
int main() {
while(cin >> p1.px >> p1.py >> p2.px >> p2.py >> p3.px >> p3.py >> c.p.px >> c.p.py >> c.r) {
l1 = Segment(p1, p2);
l2 = Segment(p2, p3);
l3 = Segment(p3, p1);
if(dst(p1, c.p) <= c.r && dst(p2, c.p) <= c.r && dst(p3, c.p) <= c.r) printf("b\n");
else if(dst(l1, c.p) >= c.r && dst(l2, c.p) >= c.r && dst(l3, c.p) >= c.r) printf(contain({p1, p2, p3}, c.p) ? "a\n" : "d\n");
else printf("c\n");
}
} | a.cc: In function 'long double dst(const Segment&, const Segment&)':
a.cc:72:13: error: 'its' was not declared in this scope
72 | if (its(a, b)) return 0;
| ^~~
|
s962625221 | p00153 | C++ | /*include*/
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#include<complex>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
const double PI=acos(-1);
const double EPS=1e-10;
const double inf=1e8;
using namespace std;
#define shosu(x) fixed<<setprecision(x)
typedef complex<double> P;
typedef vector<P> G;
typedef vector<int> vi;
typedef vector<vi> vvi;
struct L : public vector<P> {
L(const P &a, const P &b) {
push_back(a); push_back(b);
}
};
struct C{
P c;double r;
C(const P &c,double r):c(c),r(r){}
};
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
namespace std {
bool operator < (const P& a, const P& b) {
return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
//return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
}
bool operator == (const P& a, const P& b) {
return a.real()==b.real()&&a.imag()==b.imag();
}
}
P pin(){
double x,y;
char d;
cin>>x>>y;
P p(x,y);
return p;
}
void PIN(P* a,int n){
rep(i,n)a[i]=pin();
}
double dot(P a,P b){
return real(conj(a)*b);
}
double cross(P a,P b){
return imag(conj(a)*b);
}
int ccw(P a, P b, P c) {
b -= a; c -= a;
if (cross(b, c) > 0) return +1; // counter clockwise
if (cross(b, c) < 0) return -1; // clockwise
if (dot(b, c) < 0) return +2; // c--a--b on line
if (norm(b) < norm(c)) return -2; // a--b--c on line
return 0;
}
P projection(L a,P p){
double t=dot(p-a[0],a[0]-a[1])/norm(a[0]-a[1]);
return a[0]+t*(a[0]-a[1]);
}
P reflection(L a,P p){
return p+2.0*(projection(a,p)-p);
}
bool intersectLL(const L &l, const L &m) {
return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
abs(cross(l[1]-l[0], m[0]-l[0])) < EPS; // same line
}
bool intersectLS(const L &l, const L &s) {
return cross(l[1]-l[0], s[0]-l[0])* // s[0] is left of l
cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
double distanceLP(const L &l, const P &p) {
return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
if (intersectLS(l, s)) return 0;
return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
const P r = projection(s, p);
if (intersectSP(s, r)) return abs(r - p);
return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
if (intersectSS(s, t)) return 0;
return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
/*bool intersectCS(C c,const L &l){
return (distanceLP(l,c.c) < c.r+EPS &&
(c.r < abs(c.c-l[0]) + EPS || c.r < abs(c.c-l[1]) + EPS));
}*/
int intersectCS(C c,L &l){
if(norm(projection(l,c.c)-c.c)-c.r*c.r>EPS)return 0;
const double d1=abs(c.c-l[0]),d2=abs(c.c-l[1]);
if(d1<c.r+EPS&&d2<c.r+EPS)return 0;
if(d1<c.r-EPS&&d2>c.r+EPS||d1>c.r+EPS&&d2<c.r-EPS)return 1;
const P h=projection(l,c.c);
if(dot(l[0]-h,l[1]-h)<0)return 2;
return 0;
}
P crosspointSS(L a,L b){
double t1=abs(cross(a[1]-a[0],b[0]-a[0]));
double t2=abs(cross(a[1]-a[0],b[1]-a[0]));
return b[0]+(b[1]-b[0])*t1/(t1+t2);
}
L crosspointCL(C c,L l){
P pr=projection(l,c.c);
P e=(l[1]-l[0])/abs(l[1]-l[0]);
double t=sqrt(c.r*c.r-norm(pr-c.c));
P a=pr+t*e;
P b=pr-t*e;
if(b<a)swap(a,b);
return L(a,b);
}
L crosspointCS(C c,L l){
if(intersectCS(c,l)==2)return crosspointCL(c,l);
L ret=crosspointCL(c,l);
if(dot(l[0]-ret[0],l[1]-ret[0])<0)ret[1]=ret[0];
else ret[0]=ret[1];
return ret;
}
L crosspointCC(C a,C b){
P tmp=b.c-a.c;
double d=abs(tmp);
double q=acos((a.r*a.r+d*d-b.r*b.r)/(2*a.r*d));
double t=arg(tmp);//atan(tmp.imag()/tmp.real());
P p1=a.c+polar(a.r,t+q);
P p2=a.c+polar(a.r,t-q);
if(p2<p1)swap(p1,p2);
return L(p1,p2);
}
P crosspointLL(const L &l, const L &m) {
double A = cross(l[1] - l[0], m[1] - m[0]);
double B = cross(l[1] - l[0], l[1] - m[0]);
if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
return m[0] + B / A * (m[1] - m[0]);
}
double area(const G &g){
double S =0;
for(int i =0;i <g.size();i++){
S +=(cross(g[i],g[(i+1)%g.size()]));
}
return abs(S/2.0);
}
bool isconvex(const G &g){
int n=g.size();
rep(i,n)if(ccw(g[(i+n-1)%n],g[i%n],g[(i+1)%n])==-1)return false;
return true;
}
int inconvex(const G& g, const P& p) {
bool in = false;
int n=g.size();
rep(i,n){
P a=g[i%n]-p;
P b=g[(i+1)%n]-p;
if(imag(a)>imag(b))swap(a, b);
if(imag(a)<=0&&0<imag(b))if(cross(a,b)<0)in=!in;
if(cross(a,b)==0&&dot(a,b)<=0)return 1;//ON
}
return in?2:0;//IN : OUT;
}
G convex_hull(G &ps) {
int n=ps.size(),k=0;
sort(ps.begin(), ps.end());
G ch(2*n);
for(int i=0;i<n;ch[k++]=ps[i++])//lower-hull
while(k>=2&&ccw(ch[k-2],ch[k-1],ps[i])==-1)--k;//<=0 -> ==-1
for(int i=n-2,t=k+1;i>=0;ch[k++]=ps[i--])//upper-hull
while(k>=t&&ccw(ch[k-2],ch[k-1],ps[i])==-1)--k;//
ch.resize(k-1);
return ch;
}
double convex_diameter(const G &pt) {
const int n = pt.size();
int is = 0, js = 0;
for (int i = 1; i < n; ++i) {
if (imag(pt[i]) > imag(pt[is])) is = i;
if (imag(pt[i]) < imag(pt[js])) js = i;
}
double maxd = norm(pt[is]-pt[js]);
int i, maxi, j, maxj;
i = maxi = is;
j = maxj = js;
do {
if (cross(diff(pt,i), diff(pt,j)) >= 0) j = (j+1) % n;
else i = (i+1) % n;
if (norm(pt[i]-pt[j]) > maxd) {
maxd = norm(pt[i]-pt[j]);
maxi = i; maxj = j;
}
} while (i != is || j != js);
return sqrt(maxd); /* farthest pair is (maxi, maxj). */
}//convex_diameter(g)
G convex_cut(const G& g, const L& l) {
G Q;
for (int i = 0; i < g.size(); ++i) {
P a= curr(g, i), b= next(g, i);
if (ccw(l[0], l[1], a) != -1) Q.push_back(a);
if (ccw(l[0], l[1], a)*ccw(l[0], l[1], b) < 0)
Q.push_back(crosspointLL(L(a,b), l));
}
return Q;
}
P turn(P p,double t){
return p*exp(P(.0,t*PI/180.0));
}
P turn2(P p,double t){
return p*exp(P(.0,t));
}
vector<L> tangentCC(C a,C b){
if(a.r<b.r)swap(a,b);
double d=abs(a.c-b.c);
vector<L>l;
if(d<EPS)return l;
if(a.r+b.r<d-EPS){//hanareteiru
double t=acos((a.r+b.r)/d);
t=t*180/PI;
l.pb(L(a.c+turn(a.r/d*(b.c-a.c),t),b.c+turn(b.r/d*(a.c-b.c),t)));
l.pb(L(a.c+turn(a.r/d*(b.c-a.c),-t),b.c+turn(b.r/d*(a.c-b.c),-t)));
}else if(a.r+b.r<d+EPS){//kuttuiteiru soto
P p=a.c+a.r/d*(b.c-a.c);
l.pb(L(p,p+turn(b.c-a.c,90)));
}
if(abs(a.r-b.r)<d-EPS){//majiwatteiru
double t1=acos((a.r-b.r)/d);
t1=t1*180/PI;
double t2=180-t1;
l.pb(L(a.c+turn(a.r/d*(b.c-a.c),t1),b.c+turn(b.r/d*(a.c-b.c),-t2)));
l.pb(L(a.c+turn(a.r/d*(b.c-a.c),-t1),b.c+turn(b.r/d*(a.c-b.c),t2)));
}else if(abs(a.r-b.r)<d+EPS){//kuttuiteiru uti
P p=a.c+a.r/d*(b.c-a.c);
l.pb(L(p,p+turn(b.c-a.c,90)));
}
return l;
}
void printL(const L &out){
printf("%.9f %.9f %.9f %.9f\n",out[0].real(),out[0].imag(),out[1].real(),out[1].imag());
}
C CIN(){
P p=pin();
double r;
cin>>r;
return C(p,r);
}
bool para(L a,L b){
return (abs(cross(a[1]-a[0],b[1]-b[0]))<EPS);
}
double min(double a,double b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
int main(){
int a,b;
while(cin>>a>>b,a+b){
G g(3);
g[0]=P(a,b);
rep(i,2)g[i+1]=pin();
P p=pin();double r;cin>>r;
C c(p,r);
bool h=true;
if(inconvex(g,c.c)!=2)h=false;
rep(i,3)if(distanceSP(L(g[i],g[(i+1)%3]),c.c)<c.r)h=false;
if(h){
cout<<'a'<<endl;
continue;
}
h=true;
rep(i,3)if(abs(g[i]-c.c)>c.r)h=false;
if(h){
cout<<'b'<<endl;
continue;
}
rep(i,3)if(intersectCS(c,L(g[i],g[(i+1)%3])))h=true;
if(h)cout<<'c'<<endl;
else cout<<'d'<<endl;
}
} | a.cc: In function 'int main()':
a.cc:305:42: error: cannot bind non-const lvalue reference of type 'L&' to an rvalue of type 'L'
305 | rep(i,3)if(intersectCS(c,L(g[i],g[(i+1)%3])))h=true;
| ^~~~~~~~~~~~~~~~~~
a.cc:125:24: note: initializing argument 2 of 'int intersectCS(C, L&)'
125 | int intersectCS(C c,L &l){
| ~~~^
|
s531658151 | p00153 | C++ |
B comp(const P& l, const P& r){ return (l.X == r.X) ? l.Y < r.Y : l.X < r.X; }
typedef pair<P, P> L; //line
typedef pair<P, P> LS; //line segment
typedef pair<P, D> C; //circle
typedef vector<P> Poly;
const D EPS = 1e-8;
//Decompotision Macro
#define DCl(a,b,l) P (a),(b);tie(a,b)=l;
#define DCc(a,b,c) P (a);D (b);tie(a,b)=c;
//A dot B
IL D dot(P a, P b) { return a.X*b.X + a.Y*b.Y; }
//A cross B
IL D cross(P a, P b) { return a.X*b.Y - a.Y*b.X; }
IL D ccw(P a,P b,P c){
return cross(b - a, c - a);
}
IL int sgn(P a,P b, P c){
if(cross(b-a,c-a) > EPS)return 1;
if(cross(b-a,c-a) < -EPS)return -1;
if(dot(b-a,c-a) < -EPS)return 2; // b-a-c
if(dot(a-b,c-b) < -EPS)return -2; // a-b-c
return 0;
}
IL D signed_distance_P_L(P p, L l) {
DCl(a,b,l);
return ccw(a,b,p)/ abs(b - a);
}
IL D distance_P_L(P p, L l) {
return abs(signed_distance_P_L(p,l));
}
IL D distance_P_LS(P p, LS ls) {
DCl(a,b,ls);
if (dot(b - a, p - a) < EPS) return abs(p - a);
if (dot(a - b, p - b) < EPS) return abs(p - b);
return abs(cross(b - a, p - a)) / abs(b - a);
}
IL B is_L_L(L p, L q) {
DCl(a,b,p);
DCl(c,d,q);
return
abs(cross(a - b, c - d)) > EPS ||
abs(cross(a - b ,d - b)) < EPS;
}
IL B is_L_LS(L l, LS ls) {
DCl(a,b,l);
DCl(c,d,ls);
return ccw(a,b,c)*ccw(a,b,d)<EPS;
}
IL B is_LS_LS(LS p, LS q) {
DCl(a,b,p);
DCl(c,d,q);
return sgn(a,b,c)*sgn(a,b,d) <= 0
&& sgn(c,d,a)*sgn(c,d,b) <= 0;
}
IL D distance_LS_LS(LS p,LS q){
if(is_LS_LS(p,q))return 0;
return min({
distance_P_LS(p.fi,q),
distance_P_LS(p.se,q),
distance_P_LS(q.fi,p),
distance_P_LS(q.se,p)
});
}
//caution: have to use isintersected_L_L before this function
IL P cross_point_L_L(L p, L q) {
DCl(a,b,p);
D d1 = signed_distance_P_L(a, q);
D d2 = signed_distance_P_L(b, q);
return (a * d2 - b * d1) / (d2 - d1);
}
IL B is_C_C(C p, C q) {
DCc(cp,rp,p);
DCc(cq,rq,q);
D d = abs(cp - cq);
return abs(rp - rq) - d <EPS &&
rp + rq - d > -EPS;
}
IL LS cross_C_C(C p, C q) {
DCc(cp,rp,p);
DCc(cq,rq,q);
D d = abs(cp - cq);
D rc = (d*d + rp*rp - rq*rq) / (2 * d);
D rs = sqrt(rp*rp - rc*rc);
P diff = (cq - cp) / d;
return {cp + P(rc, rs)*diff, cp + P(rc, -rs)*diff};
}
IL Poly convex_hull(Poly p) {
int n = p.size();
Poly res(2 * n);
int k = 0, t;
sort(ALL(p),comp);
REP(i,n) {
while (k > 1 && ccw(res[k-2],res[k-1],p[i]) < EPS)k--;
res[k++] = p[i];
}
t = k;
REP(j,n-1){
int i= n - 2 - j;
while (k > t && ccw(res[k - 2],res[k - 1], p[i]) < EPS)k--;
res[k++] = p[i];
}
res.resize(k - 1);
return res;
}
IL B convex_in(Poly& l,P& p) {
int a = 0, b = l.size(), c;
D A, C;
P g = (l[a] + l[b - 1] + l[b / 2]) / 3.0;
while (b - a > 1) {
c = (a + b) / 2;
A = cross(l[a] - g, p - l[a]);
C = cross(l[c] - g, p - l[c]);
if (cross(l[a] - g, l[c] - g) >= 0) {
if (A > -EPS&&C < -EPS)b = c;
else a = c;
}
else {
if (C < -EPS || A > -EPS)b = c;
else a = c;
}
}
return(cross(l[b%l.size()] - l[a], p - l[b%l.size()]) > -EPS);
}
//not necessary?
IL D convex_area(Poly& l) {
double res = 0;
int n = l.size();
FOR(i,2,n)
res += (abs(cross(l[i - 1] - l[0], l[i] - l[i - 1]))) / 2.0;
return res;
}
IL D area(Poly& l){
double res=0;
int n=l.size();
REP(i,n)res+=cross(l[i],l[(i+1)%n]);
return abs(res)/2.0;
}
inline vector<L> tangent_line(C c, P p) {
vector<L> res;
DCc(cp,r,c);
P v = p - cp;
D dist = abs(v);
if (dist - r > -EPS) {
double _cos = r / dist;
double _sin = sqrt(1.0 - _cos*_cos);
v = v * (r / dist);
{
P e = P(_cos * v.X - _sin * v.Y, _sin*v.X + _cos*v.Y);
res.push_back({p, cp + e});
}
if(dist-r > EPS){
P e = P( _cos*v.X + _sin*v.Y ,-_sin*v.X + _cos*v.Y );
res.push_back({p, cp + e});
}
}
return res;
}
IL vector<L> inner_common_tangent_line(C p, C q) {
vector<L> res;
DCc(Mp,Rp,p);
DCc(Mq,Rq,q);
D dist = abs(Mp - Mq);
if (dist - (Rp + Rq) > -EPS) {
P mid = (Mq*Rp + Mp*Rq) / (Rp + Rq);
res = tangent_line(p, mid);
}
return res;
}
inline vector<L> outer_common_tangent_line(C p, C q) {
vector<L> res;
DCc(Mp,Rp,p);
DCc(Mq,Rq,q);
P v = Mp - Mq;
D dist = abs(v);
if (dist - abs(Rp - Rq) >- EPS) {
if (abs(Rp - Rq) < EPS) {
P e = v*P( 0, 1 );
e = e / dist;
res.pb(L(Mp + e, Mq + e));
res.pb(L(Mp - e, Mq - e));
}
else {
P mid = Mp + (Mq - Mp) * Rp / (Rp - Rq);
res = tangent_line(p, mid);
}
}
return res;
}
vector<Poly> decomposition(Poly p){
int n = p.size();
vector<Poly> res;
while(n>=3){
[&](){
FOR(i, 0, n){
P a = p[i];
P b = p[(i+1)%n];
P c = p[(i+2)%n];
if (ccw(a,b,c)<0)continue;
if([&](){
FOR(j,3,n){
P d=p[(i+j)%n];
if(ccw(a,b,d)>-EPS&&ccw(b,c,d)>-EPS&&ccw(c,a,d)>-EPS)
return true;
}
return false;
}()
)continue;
Poly nxt;
REP(j,n)if((i+j)%n!=(i+1)%n)nxt.push_back(p[(i+j)%n]);
swap(p,nxt);
res.push_back({a,b,c});
n--;
return;
}
}();
}
return res;
}
int in_triangle(P p,Poly q){
REP(i,3)if(abs(p-q[i])<EPS)return 3;//on point
REP(i,3){
int s=sgn(q[i],q[(i+1)%3],p);
if(s!=1){
if(s==0)return 2;//on line
else return 0; // not in
}
}
return 1; // inside triangle
}
int in_C(P q,C c){
DCc(p,r,c);
if(abs(r-abs(p-q))<EPS)return 2; //on
return r-abs(p-q)>-EPS ? 1:0;
}
int is_triangle_C(Poly t,C c){
DCc(p,r,c);
int cnt=0;
REP(i,3)
cnt+=(in_C(t[i],c)>0);
if(cnt==3)return 3; // t in c
if(cnt==0){
double d=distance_P_LS(p,LS(t[2],t[0]));
REP(i,2)
d=min(d,distance_P_LS(p,LS(t[i],t[i+1])));
if(r-d>-EPS)return 1; //intersect | a.cc:2:5: error: 'B' does not name a type
2 | B comp(const P& l, const P& r){ return (l.X == r.X) ? l.Y < r.Y : l.X < r.X; }
| ^
a.cc:3:13: error: 'pair' does not name a type
3 | typedef pair<P, P> L; //line
| ^~~~
a.cc:4:13: error: 'pair' does not name a type
4 | typedef pair<P, P> LS; //line segment
| ^~~~
a.cc:5:13: error: 'pair' does not name a type
5 | typedef pair<P, D> C; //circle
| ^~~~
a.cc:6:13: error: 'vector' does not name a type
6 | typedef vector<P> Poly;
| ^~~~~~
a.cc:7:11: error: 'D' does not name a type
7 | const D EPS = 1e-8;
| ^
a.cc:13:5: error: 'IL' does not name a type
13 | IL D dot(P a, P b) { return a.X*b.X + a.Y*b.Y; }
| ^~
a.cc:15:5: error: 'IL' does not name a type
15 | IL D cross(P a, P b) { return a.X*b.Y - a.Y*b.X; }
| ^~
a.cc:16:5: error: 'IL' does not name a type
16 | IL D ccw(P a,P b,P c){
| ^~
a.cc:20:5: error: 'IL' does not name a type
20 | IL int sgn(P a,P b, P c){
| ^~
a.cc:27:5: error: 'IL' does not name a type
27 | IL D signed_distance_P_L(P p, L l) {
| ^~
a.cc:32:5: error: 'IL' does not name a type
32 | IL D distance_P_L(P p, L l) {
| ^~
a.cc:36:5: error: 'IL' does not name a type
36 | IL D distance_P_LS(P p, LS ls) {
| ^~
a.cc:44:5: error: 'IL' does not name a type
44 | IL B is_L_L(L p, L q) {
| ^~
a.cc:51:5: error: 'IL' does not name a type
51 | IL B is_L_LS(L l, LS ls) {
| ^~
a.cc:56:5: error: 'IL' does not name a type
56 | IL B is_LS_LS(LS p, LS q) {
| ^~
a.cc:63:5: error: 'IL' does not name a type
63 | IL D distance_LS_LS(LS p,LS q){
| ^~
a.cc:74:5: error: 'IL' does not name a type
74 | IL P cross_point_L_L(L p, L q) {
| ^~
a.cc:81:5: error: 'IL' does not name a type
81 | IL B is_C_C(C p, C q) {
| ^~
a.cc:88:5: error: 'IL' does not name a type
88 | IL LS cross_C_C(C p, C q) {
| ^~
a.cc:97:5: error: 'IL' does not name a type
97 | IL Poly convex_hull(Poly p) {
| ^~
a.cc:115:5: error: 'IL' does not name a type
115 | IL B convex_in(Poly& l,P& p) {
| ^~
a.cc:136:5: error: 'IL' does not name a type
136 | IL D convex_area(Poly& l) {
| ^~
a.cc:143:5: error: 'IL' does not name a type
143 | IL D area(Poly& l){
| ^~
a.cc:149:12: error: 'vector' does not name a type
149 | inline vector<L> tangent_line(C c, P p) {
| ^~~~~~
a.cc:169:5: error: 'IL' does not name a type
169 | IL vector<L> inner_common_tangent_line(C p, C q) {
| ^~
a.cc:180:12: error: 'vector' does not name a type
180 | inline vector<L> outer_common_tangent_line(C p, C q) {
| ^~~~~~
a.cc:201:6: error: 'vector' does not name a type
201 | vector<Poly> decomposition(Poly p){
| ^~~~~~
a.cc:231:21: error: 'P' was not declared in this scope
231 | int in_triangle(P p,Poly q){
| ^
a.cc:231:25: error: 'Poly' was not declared in this scope
231 | int in_triangle(P p,Poly q){
| ^~~~
a.cc:231:31: error: expression list treated as compound expression in initializer [-fpermissive]
231 | int in_triangle(P p,Poly q){
| ^
a.cc:242:14: error: 'P' was not declared in this scope
242 | int in_C(P q,C c){
| ^
a.cc:242:18: error: 'C' was not declared in this scope
242 | int in_C(P q,C c){
| ^
a.cc:242:21: error: expression list treated as compound expression in initializer [-fpermissive]
242 | int in_C(P q,C c){
| ^
a.cc:247:23: error: 'Poly' was not declared in this scope
247 | int is_triangle_C(Poly t,C c){
| ^~~~
a.cc:247:30: error: 'C' was not declared in this scope
247 | int is_triangle_C(Poly t,C c){
| ^
a.cc:247:33: error: expression list treated as compound expression in initializer [-fpermissive]
247 | int is_triangle_C(Poly t,C c){
| ^
|
s529655374 | p00153 | C++ | #include<complex>
#include<vector>
#include<algorithm>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
bool operator < (const P& a, const P& b) {
return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
}
double cross(const P& a, const P& b) {
return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
return real(conj(a)*b);
}
struct L : public vector<P> {
L(const P &a, const P &b) {
push_back(a); push_back(b);
}
};
typedef vector<P> G;
struct C {
P p; double r;
C(const P &p, double r) : p(p), r(r) { }
};
int ccw(P a, P b, P c) {
b -= a; c -= a;
if (cross(b, c) > 0) return +1; // counter clockwise
if (cross(b, c) < 0) return -1; // clockwise
if (dot(b, c) < 0) return +2; // c--a--b on line
if (norm(b) < norm(c)) return -2; // a--b--c on line
return 0;
}
bool intersectLL(const L &l, const L &m) {
return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
abs(cross(l[1]-l[0], m[0]-l[0])) < EPS; // same line
}
bool intersectLS(const L &l, const L &s) {
return cross(l[1]-l[0], s[0]-l[0])* // s[0] is left of l
cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P projection(const L &l, const P &p) {
double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
return l[0] + t*(l[0]-l[1]);
}
P reflection(const L &l, const P &p) {
return p + P(2,0) * (projection(l, p) - p);
}
double distanceLP(const L &l, const P &p) {
return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
if (intersectLS(l, s)) return 0;
return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
const P r = projection(s, p);
if (intersectSP(s, r)) return abs(r - p);
return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
if (intersectSS(s, t)) return 0;
return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
#define curr(P, i) Pt[i]
#define next(P, i) Pt[(i+1)%Pt.size()]
enum { OUT, ON, IN };
int contains(const G& Pt, const P& p) {
bool in = false;
for (int i = 0; i < Pt.size(); ++i) {
P a = curr(P,i) - p, b = next(P,i) - p;
if (imag(a) > imag(b)) swap(a, b);
if (imag(a) <= 0 && 0 < imag(b))
if (cross(a, b) < 0) in = !in;
if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
}
return in ? IN : OUT;
}
int main(){
double x1,y1,x2,y2,x3,y3,cx,cy,r;
while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>cx>>cy>>r,x1||y1){
P pA(x1,y1),pB(x2,y2),pC(x3,y3),pO(cx,cy);
L c(pA,pB),a(pB,pC),b(pC,pA);
C Circle(pO,r);
G ABC; ABC.push_back(pA),ABC.push_back(pB),ABC.push_back(pC);
if(r*r+EPS>max(max(norm(pA-pO),norm(pB-pO)),norm(pC-pO))){
cout<<"b"; goto NEXT;
}
if(!ccw(pA,pB,pC))swap(ABC[0],ABC[2]);
bool ct=contains(ABC,pO);
if(ct&&min(min(distanceSP(a,pO),distanceSP(b,pO)),distanceSP(c,pO))>r-EPS){
cout<<"a"; goto NEXT;
}
if(distanceSP(a,pO)<r+EPS||distanceSP(b,pO)<r+EPS||distanceSP(c,pO)<r+EPS){
cout<<"c"; goto NEXT;
}
cout<<"d";
NEXT:
cout<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:109:15: error: 'cin' was not declared in this scope
109 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>cx>>cy>>r,x1||y1){
| ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
3 | #include<algorithm>
+++ |+#include <iostream>
4 | using namespace std;
a.cc:116:25: error: 'cout' was not declared in this scope
116 | cout<<"b"; goto NEXT;
| ^~~~
a.cc:116:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:122:25: error: 'cout' was not declared in this scope
122 | cout<<"a"; goto NEXT;
| ^~~~
a.cc:122:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:126:25: error: 'cout' was not declared in this scope
126 | cout<<"c"; goto NEXT;
| ^~~~
a.cc:126:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:129:17: error: 'cout' was not declared in this scope
129 | cout<<"d";
| ^~~~
a.cc:129:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:131:17: error: jump to label 'NEXT'
131 | NEXT:
| ^~~~
a.cc:116:41: note: from here
116 | cout<<"b"; goto NEXT;
| ^~~~
a.cc:120:22: note: crosses initialization of 'bool ct'
120 | bool ct=contains(ABC,pO);
| ^~
|
s756081622 | p00153 | C++ | #include<iostream>
#include<cfloat>
#include<cmath>
using namespace std;
#define EPS (1e-8)
#define equals(a, b) (fabs((a) - (b)) < EPS )
#define dle(a, b) (equals(a, b) || a < b )
static const double PI = acos(-1);
class Point{
public:
double x, y;
Point ( double x = 0, double y = 0): x(x), y(y){}
Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
Point operator * ( double a ){ return Point(x*a, y*a); }
double abs() { return sqrt(norm());}
double norm() { return x*x + y*y; }
bool operator < ( const Point &p ) const {
return x != p.x ? x < p.x : y < p.y;
}
bool operator == ( const Point &p ) const {
return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
}
};
typedef Point Vector;
class Segment{
public:
Point p1, p2;
Segment(Point s = Point(), Point t = Point()): p1(s), p2(t){}
};
typedef Segment Line;
static const int CIRCLE_NON = 0;
static const int CIRCLE_OUT = 1;
static const int CIRCLE_IN = 2;
static const int CIRCLE_CROSS = 3;
class Circle{
public:
Point c;
double r;
Circle(Point c = Point(), double r = 0.0): c(c), r(r){}
};
double norm( Vector a ){ return a.x*a.x + a.y*a.y; }
double abs( Vector a ){ return sqrt(norm(a)); }
Point polar( double a, double r ){ return Point(cos(r)*a, sin(r)*a);}
double getDistance( Vector a, Vector b ){ return abs(a - b); }
double dot( Vector a, Vector b ){ return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ){ return a.x*b.y - a.y*b.x; }
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
int ccw( Point p0, Point p1, Point p2 ){
Vector a = p1 - p0;
Vector b = p2 - p0;
if ( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
if ( cross(a, b) < -EPS ) return CLOCKWISE;
if ( dot(a, b) < -EPS ) return ONLINE_BACK;
if ( norm(a) < norm(b) ) return ONLINE_FRONT;
return ON_SEGMENT;
}
double arg(Vector p){
return atan2(p.y, p.x);
}
double getDistanceLP(Line s, Point p){
return abs(cross(s.p2 - s.p1, p - s.p1)/abs(s.p2 - s.p1));
}
bool isIntersect( Circle c1, Line l ){
double d = getDistanceLP(l, c1.c);
return ( equals(d, c1.r) || d < c1.r );
}
pair<Point, Point> getCrossPoints(Circle c1, Line l ){
assert( isIntersect( c1, l ) );
double d = getDistanceLP(l, c1.c);
Point v = l.p2 - l.p1;
if ( ccw(l.p1, l.p2, c1.c) == COUNTER_CLOCKWISE ){
v = polar(abs(v), arg(v)-acos(-1)/2);
} else {
v = polar(abs(v), arg(v)+acos(-1)/2);
}
double th = acos(d/c1.r);
Point v1 = polar(c1.r, arg(v) + th );
Point v2 = polar(c1.r, arg(v) - th );
return make_pair(c1.c+v1, c1.c+v2);
}
bool circleIsInTriangle(Circle c, Point t[3] ){
int ccw1 = ccw(t[0], t[1], c.c);
int ccw2 = ccw(t[1], t[2], c.c);
int ccw3 = ccw(t[2], t[0], c.c);
if ( !(ccw1 == ccw2 && ccw2 == ccw3 ) ) return false;
for ( int i = 0; i < 3; i++ ){
Line l = Line(t[i], t[(i+1)%3]);
if ( c.r > getDistanceLP(l, c.c) ) return false;
}
return true;
}
bool triangleIsInCircle(Circle c, Point t[3] ){
for ( int i = 0; i < 3; i++ ){
if ( c.r < getDistance(t[i], c.c) ) return false;
}
return true;
}
bool isIntersect(Circle c, Point t[3]){
for ( int i = 0; i < 3; i++ ){
Line l = Line(t[i], t[(i+1)%3]);
if ( !isIntersect(c, l) ) continue;
pair<Point, Point> pp = getCrossPoints(c, l);
if ( ccw(l.p1, l.p2, pp.first) == ON_SEGMENT ) return true;
if ( ccw(l.p1, l.p2, pp.second) == ON_SEGMENT ) return true;
}
return false;
}
int main(){
double x, y, r;
Circle c;
Point T[3];
while(1){
cin >> x >> y;
if ( x == 0 && y == 0 ) break;
T[0] = Point(x, y);
cin >> x >> y;
T[1] = Point(x, y);
cin >> x >> y;
T[2] = Point(x, y);
cin >> x >> y >> r;
c = Circle(Point(x, y), r);
if ( circleIsInTriangle(c, T) ) cout << "a" << endl;
else if ( triangleIsInCircle(c, T) ) cout << "b" << endl;
else if ( isIntersect(c, T) ) cout << "c" << endl;
else cout << "d" << endl;
}
return 0;
} | a.cc: In function 'std::pair<Point, Point> getCrossPoints(Circle, Line)':
a.cc:94:5: error: 'assert' was not declared in this scope
94 | assert( isIntersect( c1, l ) );
| ^~~~~~
a.cc:4:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
3 | #include<cmath>
+++ |+#include <cassert>
4 |
|
s626055379 | p00153 | C++ | #include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#define EPS 1e-8
using namespace std;
typedef complex<double> P;
typedef vector<P> G;
double cross(const P &a, const P &b){
return imag(conj(a)*b);
}
double dot(const P &a, const P &b){
return real(conj(a) * b);
}
struct L : public vector<P> {
L(const P &a, const P &b){
push_back(a);
push_back(b);
}
L(){}
};
struct C{
P p;
double r;
C(const P &p, double r) : p(p), r(r) { }
C(){}
};
bool intersectSP(const L &s, const P &p) {
return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P projection(const L &l, const P &p) {
double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
return l[0] + t*(l[0]-l[1]);
}
double distanceSP(const L &s, const P &p) {
const P r = projection(s, p);
if (intersectSP(s, r)) return abs(r - p);
return min(abs(s[0] - p), abs(s[1] - p));
}
#define curr(G, i) G[i]
#define next(G, i) G[(i+1)%G.size()]
enum { OUT, ON, IN };
int contains(const G &g, const P &p) {
bool in = false;
for (int i = 0; i < g.size(); ++i) {
P a = curr(g,i) - p, b = next(g,i) - p;
if (imag(a) > imag(b)) swap(a, b);
if (imag(a) <= 0 && 0 < imag(b))
if (cross(a, b) < 0) in = !in;
if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
}
return in ? IN : OUT;
}
int main(){
int tmpx, tmpy,r;
while(cin >> tmpx >> tmpy){
if((tmpx | tmpy) == 0) break;
G v(3);
L *e = new L[3];
C c;
v[0] = P(tmpx, tmpy);
cin >> tmpx >> tmpy;
v[1] = P(tmpx, tmpy);
cin >> tmpx >> tmpy;
v[2] = P(tmpx, tmpy);
e[0] = L(v[0],v[1]);
e[1] = L(v[0],v[2]);
e[2] = L(v[1],v[2]);
cin >> tmpx >> tmpy >> r;
c = C(P(tmpx,tmpy), r);
//a:T contains C
bool isA = true;
for(int i=0;i<3;i++){
//for all edges
if(distanceSP(e[i], c.p) < r){
isA = false;
}
}
if(isA && contains(v, c.p) == IN){
cout << "a" << endl;
continue;
}
//b:C contains T
bool isB = true;
for(int i=0;i<3;i++){
//for all vertex
if(abs(v[i] - c.p) > r){
isB = false;
}
}
if(isB){
cout << "b" << endl;
continue;
}
bool isC = false;
for(int i=0;i<3;i++){
if(distanceSP(e[i]. c.p) <= r){
isC = true;
}
}
if(isC){
cout << "c" << endl;
}else{
cout << "d" << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:109:33: error: 'struct L' has no member named 'c'
109 | if(distanceSP(e[i]. c.p) <= r){
| ^
|
s820732887 | p00153 | C++ | #include <cstdio>
#include <iostream>
#include <complex>
using namespace std;
#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
const double EPS=1e-9;
const double INFTY=1e12;
typedef complex<double> Point;
struct Line{
Point pos,dir;
Line(){}
Line(Point p,Point d):pos(p),dir(d){}
};
int Signum(double x)
{
return abs(x)<EPS?0:x>0?1:-1;
}
double Dot(Point a,Point b)
{
return real(conj(a)*b);
}
double Cross(Point a,Point b)
{
return imag(conj(a)*b);
}
int CCW(Point a,Point b,Point c)
{
Point d1=b-a,d2=c-a;
int sign=Signum(Cross(d1,d2));
if(sign)
return sign; // 1:ccw,-1:cw
if(Dot(d1,d2)<-EPS)
return -2; // c-a-b
if(norm(d1)<norm(d2)-EPS)
return 2; // a-b-c
return 0; // a-c-b
}
// ツ点ツづ陳シツ静シツづ個仰猟猟」
double DistancePL(Point p,Line l)
{
return abs(Cross(p-l.pos,l.dir))/abs(l.dir);
}
// ツ点ツづ静シツ閉ェツづ個仰猟猟」
double DistancePS(Point p,Line s)
{
Point a=p-s.pos,b=s.dir;
Point c=b*Dot(a,b)/norm(b);
double pos=abs(c)/abs(b);
if(-EPS<pos && pos<1+EPS)
return abs(a-c);
else
return min(abs(a),abs(b-a));
}
void solve(Point p[],Point c,int r)
{
{ // triangle in circle
double dist=0;
for(int i=0;i<3;i++)
dist=max(dist,norm(p[i]-c));
if(dist<=r*r){
puts("b");
return;
}
}
{ // circle in triangle
bool res=true;
int ccw=0;
for(int i=0;i<3;i++){
int temp=CCW(p[i],p[(i+1)%3],c);
if(abs(temp)==2)
continue;
res&=temp*ccw>=0;
ccw=temp;
}
if(res){
double dist=INFTY;
for(int i=0;i<3;i++)
dist=min(dist,DistancePL(c,Line(p[i],p[(i+1)%3]-p[i])));
if(Signum(dist-r)>=0){
puts("a");
return;
}
}
}
{ // intersect
double dist=INFTY;
for(int i=0;i<3;i++)
dist=min(dist,DistancePS(c,Line(p[i],p[(i+1)%3]-p[i])));
if(Signum(dist-r)<=0){
puts("c");
return;
}
}
puts("d");
}
int main()
{
for(;;){
Point p[3],c;
double r;
for(int i=0;i<3;i++)
cin>>real(p[i])>>imag(p[i]);
cin>>real(c)>>imag(c)>>r;
if(norm(p[0])==0)
break;
//for(int i=0;i<3;i++)
// printf("(%.3f,%.3f) ",real(p[i]),imag(p[i]));
//printf("(%.3f,%.3f,%.3f)\n",real(c),imag(c),r);
solve(p,c,r);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:117:28: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double')
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~^~~~~~~~~~~~
| | |
| | double
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:2:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:117:34: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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/ |
s296605833 | p00153 | C++ | #include <cstdio>
#include <iostream>
#include <complex>
using namespace std;
#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
const double EPS=1e-9;
const double INFTY=1e12;
typedef complex<double> Point;
struct Line{
Point pos,dir;
Line(){}
Line(Point p,Point d):pos(p),dir(d){}
};
int Signum(double x)
{
return abs(x)<EPS?0:x>0?1:-1;
}
double Dot(Point a,Point b)
{
return real(conj(a)*b);
}
double Cross(Point a,Point b)
{
return imag(conj(a)*b);
}
int CCW(Point a,Point b,Point c)
{
Point d1=b-a,d2=c-a;
int sign=Signum(Cross(d1,d2));
if(sign)
return sign; // 1:ccw,-1:cw
if(Dot(d1,d2)<-EPS)
return -2; // c-a-b
if(norm(d1)<norm(d2)-EPS)
return 2; // a-b-c
return 0; // a-c-b
}
// ツ点ツづ陳シツ静シツづ個仰猟猟」
double DistancePL(Point p,Line l)
{
return abs(Cross(p-l.pos,l.dir))/abs(l.dir);
}
// ツ点ツづ静シツ閉ェツづ個仰猟猟」
double DistancePS(Point p,Line s)
{
Point a=p-s.pos,b=s.dir;
Point c=b*Dot(a,b)/norm(b);
double pos=abs(c)/abs(b);
if(-EPS<pos && pos<1+EPS)
return abs(a-c);
else
return min(abs(a),abs(b-a));
}
void solve(Point p[],Point c,double r)
{
{ // triangle in circle
double dist=0;
for(int i=0;i<3;i++)
dist=max(dist,norm(p[i]-c));
if(dist<=r*r){
puts("b");
return;
}
}
{ // circle in triangle
bool res=true;
int ccw=0;
for(int i=0;i<3;i++){
int temp=CCW(p[i],p[(i+1)%3],c);
if(abs(temp)==2)
continue;
res&=temp*ccw>=0;
ccw=temp;
}
if(res){
double dist=INFTY;
for(int i=0;i<3;i++)
dist=min(dist,DistancePL(c,Line(p[i],p[(i+1)%3]-p[i])));
if(Signum(dist-r)>=0){
puts("a");
return;
}
}
}
{ // intersect
double dist=INFTY;
for(int i=0;i<3;i++)
dist=min(dist,DistancePS(c,Line(p[i],p[(i+1)%3]-p[i])));
if(Signum(dist-r)<=0){
puts("c");
return;
}
}
puts("d");
}
int main()
{
for(;;){
Point p[3],c;
double r;
for(int i=0;i<3;i++)
cin>>real(p[i])>>imag(p[i]);
cin>>real(c)>>imag(c)>>r;
if(norm(p[0])==0)
break;
//for(int i=0;i<3;i++)
// printf("(%.3f,%.3f) ",real(p[i]),imag(p[i]));
//printf("(%.3f,%.3f,%.3f)\n",real(c),imag(c),r);
solve(p,c,r);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:117:28: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double')
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~^~~~~~~~~~~~
| | |
| | double
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:2:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:117:34: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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:117:34: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double'
117 | cin>>real(p[i])>>imag(p[i]);
| ~~~~^~~~~~
/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/ |
s375800451 | p00153 | C++ | #include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
double EPS = 1e-10;
double add(double a, double b){
if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
return a+b;
}
struct point{
double x, y;
point(){}
point(double x,double y) : x(x) , y(y){}
point operator + (point p){
return point(add(x,p.x), add(y,p.y));
}
point operator - (point p){
return point(add(x,-p.x), add(y,-p.y));
}
point operator * (double d){
return point(x*d,y*d);
}
point operator / (double d){
return point(x/d,y/d);
}
};
struct segment{ point a,b; };
struct circle{ point p; double r; };
double dot(point a, point b) { return (a.x * b.x + a.y * b.y); }
double cross(point a, point b) { return (a.x * b.y - a.y * b.x); }
int ccw(point p0, point p1, point p2){
point a = p1 - p0;
point b = p2 - p0;
if(cross(a,b)>EPS)return +1;
if(cross(a,b)<EPS)return -1;
if(dot(a,b)<-EPS)return +2;
if(a.x*a.x+a.y*a.y<b.x*b.x+b.y*b.y)return -2;
return 0;
}
double vec_abs(point a){
return sqrt(a.x*a.x+a.y*a.y);
}
double distance_ls_p(point a, point b, point c) {
if ( dot(b-a, c-a) < EPS ) return vec_abs(c-a);
if ( dot(a-b, c-b) < EPS ) return vec_abs(c-b);
return abs(cross(b-a, c-a)) / vec_abs(b-a);
}
double dist(point a,point b){
return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
int is_intersected_ls(point a1, point a2, point b1, point b2) {
return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}
int crossCS(point a, point b, circle c){
double res=distance_ls_p(a,b,c.p);
double ac=dist(a,c.p);
double bc=dist(b,c.p);
if(res>c.r || (ac<c.r && bc<c.r))return 0;
else if(c.r-res<EPS ||(ac<c.r && bc>=c.r)||(ac>=c.r && bc<c.r))return 1;
else return 2;
}
int inside(point t,point* p,int N){
int i,count=0,j=0;
segment lt,lp;
p[N]=p[0];
p[N+1]=p[1];
lt.a=lt.b=t;
lt.b.x=INT_MAX;
for(i=1;i<=N;i++){
lp.a=lp.b=p[i];
if(!is_intersected_ls(lp.a,lp.b,lt.a,lt.b)){
if(i==j+1){
lp.b=p[j];
if(is_intersected_ls(lp.a,lp.b,lt.a,lt.b))count++;
}
else if(ccw(lt.a,lt.b,p[i])*ccw(lt.a,lt.b,p[j])<0)count++;
j=i;
}
}
return count & 1;
}
int crossCP(point* ps, circle C, int sz){
double ans=0;
for(int i=0;i<sz;i++){
double tmp=dist(ps[i],C.p);
if(tmp>ans)ans=tmp;
}
if(C.r>=ans)return 2;
int res1=inside(C.p,ps,sz);
double res2=100000000;
ps[3]=ps[0];
for(int i=0;i<sz;i++)
res2=min(res2,distance_ls_p(ps[i],ps[i+1],C.p));
if(res1 && C.r<=res2)return 1;
else if(!res1 && C.r<res2)return 4;
else return 3;
}
int main(void){
point p[6];
vector<segment> t;
circle C;
string ans="zabcd";
while(true){
for(int i=0;i<3;i++){
cin >> p[i].x >> p[i].y;
if(p[i].x==0 && p[i].y==0)return 0;
}
cin >> C.p.x >> C.p.y >> C.r;
int res=crossCP(p,C,3);
cout << ans[res] << endl;
}
return 0;
} | a.cc: In function 'int inside(point, point*, int)':
a.cc:93:10: error: 'INT_MAX' was not declared in this scope
93 | lt.b.x=INT_MAX;
| ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
4 | #include<vector>
+++ |+#include <climits>
5 | #include<string>
|
s739245524 | p00153 | C++ | #include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<cfloat>
using namespace std;
double EPS = 1e-10;
const double PI = acos(-1);
double add(double a, double b){
if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
return a+b;
}
struct point{
double x, y;
point(){}
point(double x,double y) : x(x) , y(y){}
point operator + (point p){
return point(add(x,p.x), add(y,p.y));
}
point operator - (point p){
return point(add(x,-p.x), add(y,-p.y));
}
point operator * (double d){
return point(x*d,y*d);
}
point operator / (double d){
return point(x/d,y/d);
}
bool operator == ( const point &p ) const {
return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
}
};
struct circle{ point p; double r; };
double dot(point a, point b) { return (a.x * b.x + a.y * b.y); }
double cross(point a, point b) { return (a.x * b.y - a.y * b.x); }
double vec_abs(point a){
return sqrt(a.x*a.x+a.y*a.y);
}
double distance_ls_p(point a, point b, point c) {
if ( dot(b-a, c-a) < EPS ) return vec_abs(c-a);
if ( dot(a-b, c-b) < EPS ) return vec_abs(c-b);
return abs(cross(b-a, c-a)) / vec_abs(b-a);
}
double dist(point a,point b){
return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
int is_point_on_line(point a, point b, point c) {
return cross(b-a, c-a)==0.0 &&
(dot(b-a, c-a) > -EPS) &&
(dot(a-b, c-b) > -EPS);
}
point intersection_l(point a1, point a2, point b1, point b2) {
return a1 + (a2 - a1) * (cross(b2 - b1,b1 - a1) / cross(b2 - b1,a2 - a1));
}
int is_intersected_ls(point a1, point a2, point b1, point b2) {
if(cross(a1-a2,b1-b2)==0){
return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2)
|| is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
}
else {
point r=intersection_l(a1,a2,b1,b2);
return is_point_on_line(a1,a2,r) && is_point_on_line(b1,b2,r);
}
}
int crossCS(point a, point b, circle c){
double res=distance_ls_p(a,b,c.p);
double ac=dist(a,c.p);
double bc=dist(b,c.p);
if(res>c.r || (ac<c.r && bc<c.r))return 0;
else if(c.r-res<EPS ||(ac<c.r && bc>=c.r)||(ac>=c.r && bc<c.r))return 1;
else return 2;
}
int inside(point p, vector<point> ps, int n){
segment t;
t.a=t.b=p;
t.b.x=100001;
ps.push_back(ps[0]);
double ymx=-DBL_MAX,ymn=DBL_MAX;
for(int i=0;i<n;i++){
ymx=max(ymx,ps[i].y);
ymn=min(ymn,ps[i].y);
}
if(t.a.y<=ymn||t.a.y>=ymx)return 0;
for(int i=0;i<n;i++){
if(is_point_on_line(ps[i],ps[i+1],p))return 1;
}
int cnt1=0;
for(int i=0;i<n;i++)
if(is_point_on_line(t.a,t.b,ps[i]))cnt1++;
int cnt=0;
for(int i=0;i<n;i++)
if(is_intersected_ls(ps[i],ps[i+1],t.a,t.b))cnt++;
return (cnt-cnt1)%2;
}
int crossCP(vector<point> t, circle C){
double ans=0;
int tsz=t.size();
for(int i=0;i<tsz;i++){
double tmp=dist(t[i],C.p);
if(tmp>ans)ans=tmp;
}
if(C.r>=ans)return 2;
int res1=inside(C.p,t,tsz);
double res2=DBL_MAX;
t.push_back(t[0]);
for(int i=0;i<tsz;i++)
res2=min(res2,distance_ls_p(t[i],t[i+1],C.p));
if(res1 && C.r<=res2)return 1;
else if(!res1 && C.r<res2)return 4;
else return 3;
}
int main(void){
point p;
vector<point> t;
circle C;
string ans="zabcd";
while(true){
t.clear();
for(int i=0;i<3;i++){
cin >> p.x >> p.y;
if(p.x==0 && p.y==0)return 0;
t.push_back(p);
}
cin >> C.p.x >> C.p.y >> C.r;
int res=crossCP(t,C);
cout << ans[res] << endl;
}
return 0;
} | a.cc: In function 'int inside(point, std::vector<point>, int)':
a.cc:99:3: error: 'segment' was not declared in this scope
99 | segment t;
| ^~~~~~~
a.cc:100:3: error: 't' was not declared in this scope
100 | t.a=t.b=p;
| ^
|
s702424605 | p00153 | C++ | #include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<cfloat>
using namespace std;
double EPS = 1e-10;
const double PI = acos(-1);
double add(double a, double b){
if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
return a+b;
}
struct point{
double x, y;
point(){}
point(double x,double y) : x(x) , y(y){}
point operator + (point p){
return point(add(x,p.x), add(y,p.y));
}
point operator - (point p){
return point(add(x,-p.x), add(y,-p.y));
}
point operator * (double d){
return point(x*d,y*d);
}
point operator / (double d){
return point(x/d,y/d);
}
bool operator == ( const point &p ) const {
return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
}
};
struct circle{ point p; double r; };
double dot(point a, point b) { return (a.x * b.x + a.y * b.y); }
double cross(point a, point b) { return (a.x * b.y - a.y * b.x); }
double vec_abs(point a){
return sqrt(a.x*a.x+a.y*a.y);
}
double distance_ls_p(point a, point b, point c) {
if ( dot(b-a, c-a) < EPS ) return vec_abs(c-a);
if ( dot(a-b, c-b) < EPS ) return vec_abs(c-b);
return abs(cross(b-a, c-a)) / vec_abs(b-a);
}
double dist(point a,point b){
return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
int is_point_on_line(point a, point b, point c) {
return cross(b-a, c-a)==0.0 &&
(dot(b-a, c-a) > -EPS) &&
(dot(a-b, c-b) > -EPS);
}
int is_intersected_ls(point a1, point a2, point b1, point b2) {
if(cross(a1-a2,b1-b2)==0){
return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2)
|| is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
}
else {
return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}
}
int crossCS(point a, point b, circle c){
double res=distance_ls_p(a,b,c.p);
double ac=dist(a,c.p);
double bc=dist(b,c.p);
if(res>c.r || (ac else if(c.r-res=c.r)||(ac>=c.r && bc else return 2;
}
int inside(point p, vector ps, int n){
point a,b;
a=b=p;
b.x=DBL_MAX;
ps.push_back(ps[0]);
double ymx=-DBL_MAX,ymn=DBL_MAX;
for(int i=0;i ymx=max(ymx,ps[i].y);
ymn=min(ymn,ps[i].y);
}
if(a.y<=ymn||a.y>=ymx)return 0;
for(int i=0;i if(is_point_on_line(ps[i],ps[i+1],p))return 1;
}
int cnt1=0;
for(int i=0;i if(is_point_on_line(a,b,ps[i]))cnt1++;
int cnt=0;
for(int i=0;i if(is_intersected_ls(ps[i],ps[i+1],a,b))cnt++;
return (cnt-cnt1)%2;
}
int crossCP(vector t, circle C){
double ans=0;
int tsz=t.size();
for(int i=0;i double tmp=dist(t[i],C.p);
if(tmp>ans)ans=tmp;
}
if(C.r>=ans)return 2;
int res1=inside(C.p,t,tsz);
double res2=DBL_MAX;
t.push_back(t[0]);
for(int i=0;i res2=min(res2,distance_ls_p(t[i],t[i+1],C.p));
if(res1 && C.r<=res2)return 1;
else if(!res1 && C.r else return 3;
}
int main(void){
point p;
vector t;
circle C;
string ans="zabcd";
while(true){
t.clear();
for(int i=0;i<3;i++){
cin >> p.x >> p.y;
if(p.x==0 && p.y==0)return 0;
t.push_back(p);
}
cin >> C.p.x >> C.p.y >> C.r;
int res=crossCP(t,C);
cout << ans[res] << endl;
}
return 0;
} | a.cc: In function 'int crossCS(point, point, circle)':
a.cc:90:18: error: expected ')' before 'else'
90 | if(res>c.r || (ac else if(c.r-res=c.r)||(ac>=c.r && bc else return 2;
| ~ ^~~~~
| )
a.cc:90:69: error: expected ')' before ';' token
90 | if(res>c.r || (ac else if(c.r-res=c.r)||(ac>=c.r && bc else return 2;
| ~ ^
| )
a.cc:91:1: warning: no return statement in function returning non-void [-Wreturn-type]
91 | }
| ^
a.cc: At global scope:
a.cc:93:21: error: missing template argument list after 'std::vector'; template placeholder not permitted in parameter
93 | int inside(point p, vector ps, int n){
| ^~~~~~
| <>
In file included from /usr/include/c++/14/vector:66,
from a.cc:4:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'template<class _Tp, class _Alloc> class std::vector' declared here
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
a.cc: In function 'int inside(...)':
a.cc:97:1: error: 'ps' was not declared in this scope; did you mean 'p'?
97 | ps.push_back(ps[0]);
| ^~
| p
a.cc:99:14: error: expected ';' before 'ymx'
99 | for(int i=0;i ymx=max(ymx,ps[i].y);
| ^~~~
| ;
a.cc:99:35: error: expected ')' before ';' token
99 | for(int i=0;i ymx=max(ymx,ps[i].y);
| ~ ^
| )
a.cc:100:16: error: 'i' was not declared in this scope
100 | ymn=min(ymn,ps[i].y);
| ^
a.cc:101:1: warning: no return statement in function returning non-void [-Wreturn-type]
101 | }
| ^
a.cc: At global scope:
a.cc:102:1: error: expected unqualified-id before 'if'
102 | if(a.y<=ymn||a.y>=ymx)return 0;
| ^~
a.cc:104:1: error: expected unqualified-id before 'for'
104 | for(int i=0;i if(is_point_on_line(ps[i],ps[i+1],p))return 1;
| ^~~
a.cc:104:13: error: 'i' does not name a type
104 | for(int i=0;i if(is_point_on_line(ps[i],ps[i+1],p))return 1;
| ^
a.cc:105:1: error: expected declaration before '}' token
105 | }
| ^
a.cc:108:1: error: expected unqualified-id before 'for'
108 | for(int i=0;i if(is_point_on_line(a,b,ps[i]))cnt1++;
| ^~~
a.cc:108:13: error: 'i' does not name a type
108 | for(int i=0;i if(is_point_on_line(a,b,ps[i]))cnt1++;
| ^
a.cc:111:1: error: expected unqualified-id before 'for'
111 | for(int i=0;i if(is_intersected_ls(ps[i],ps[i+1],a,b))cnt++;
| ^~~
a.cc:111:13: error: 'i' does not name a type
111 | for(int i=0;i if(is_intersected_ls(ps[i],ps[i+1],a,b))cnt++;
| ^
a.cc:113:1: error: expected unqualified-id before 'return'
113 | return (cnt-cnt1)%2;
| ^~~~~~
a.cc:114:1: error: expected declaration before '}' token
114 | }
| ^
a.cc:116:13: error: missing template argument list after 'std::vector'; template placeholder not permitted in parameter
116 | int crossCP(vector t, circle C){
| ^~~~~~
| <>
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'template<class _Tp, class _Alloc> class std::vector' declared here
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
a.cc: In function 'int crossCP(...)':
a.cc:119:9: error: 't' was not declared in this scope
119 | int tsz=t.size();
| ^
a.cc:121:14: error: expected ';' before 'double'
121 | for(int i=0;i double tmp=dist(t[i],C.p);
| ^~~~~~~
| ;
a.cc:121:15: error: expected primary-expression before 'double'
121 | for(int i=0;i double tmp=dist(t[i],C.p);
| ^~~~~~
a.cc:121:14: error: expected ')' before 'double'
121 | for(int i=0;i double tmp=dist(t[i],C.p);
| ~ ^~~~~~~
| )
a.cc:122:4: error: 'tmp' was not declared in this scope; did you mean 'tm'?
122 | if(tmp>ans)ans=tmp;
| ^~~
| tm
a.cc:123:1: warning: no return statement in function returning non-void [-Wreturn-type]
123 | }
| ^
a.cc: At global scope:
a.cc:125:1: error: expected unqualified-id before 'if'
125 | if(C.r>=ans)return 2;
| ^~
a.cc:127:17: error: 'C' was not declared in this scope
127 | int res1=inside(C.p,t,tsz);
| ^
a.cc:127:21: error: 't' was not declared in this scope; did you mean 'tm'?
127 | int res1=inside(C.p,t,tsz);
| ^
| tm
a.cc:127:23: error: 'tsz' was not declared in this scope
127 | int res1=inside(C.p,t,tsz);
| ^~~
a.cc:130:1: error: 't' does not name a type; did you mean 'tm'?
130 | t.push_back(t[0]);
| ^
| tm
a.cc:132:1: error: expected unqualified-id before 'for'
132 | for(int i=0;i res2=min(res2,distance_ls_p(t[i],t[i+1],C.p));
| ^~~
a.cc:132:13: error: 'i' does not name a type
132 | for(int i=0;i res2=min(res2,distance_ls_p(t[i],t[i+1],C.p));
| ^
a.cc:134:1: error: expected unqualified-id before 'if'
134 | if(res1 && C.r<=res2)return 1;
| ^~
a.cc:135:1: error: expected unqualified-id before 'else'
135 | else if(!res1 && C.r else return 3;
| ^~~~
a.cc:136:1: error: expected declaration before '}' token
136 | }
| ^
a.cc: In function 'int main()':
a.cc:140:8: error: class template argument deduction failed:
140 | vector t;
| ^
a.cc:140:8: error: no matching function for call to 'vector()'
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> vector(_InputIterator, _InputIterator, const _Alloc&)-> std::vector<_Tp, _Alloc>'
707 | vector(_InputIterator __first, _InputIterator __last,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::initializer_list<_Tp>, const _Alloc&)-> std::vector<_Tp, _Alloc>'
678 | vector(initializer_list<value_type> __l,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::false_type)-> std::vector<_Tp, _Alloc>'
640 | vector(vector&& __rv, const allocator_type& __m, false_type)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::true_type)-> std::vector<_Tp, _Alloc>'
635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&)-> std::vector<_Tp, _Alloc>'
620 | vector(vector&&) noexcept = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&)-> std::vector<_Tp, _Alloc>'
601 | vector(const vector& __x)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Tp&, const _Alloc&)-> std::vector<_Tp, _Alloc>'
569 | vector(size_type __n, const value_type& __value,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Alloc&)-> std::vector<_Tp, _Alloc>'
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const _Alloc&)-> std::vector<_Tp, _Alloc>'
542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'template<class _Tp, class _Alloc> vector()-> std::vector<_Tp, _Alloc>'
531 | vector() = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note: template argument deduction/substitution failed:
a.cc:140:8: note: couldn't deduce template parameter '_Tp'
140 | vector t;
| ^
/usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>)-> std::vector<_Tp, _ |
s891065816 | p00153 | C++ | #include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<cfloat>
using namespace std;
double EPS = 1e-10;
const double PI = acos(-1);
double add(double a, double b){
if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
return a+b;
}
struct point{
double x, y;
point(){}
point(double x,double y) : x(x) , y(y){}
point operator + (point p){
return point(add(x,p.x), add(y,p.y));
}
point operator - (point p){
return point(add(x,-p.x), add(y,-p.y));
}
point operator * (double d){
return point(x*d,y*d);
}
point operator / (double d){
return point(x/d,y/d);
}
bool operator == ( const point &p ) const {
return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
}
};
struct circle{ point p; double r; };
double dot(point a, point b) { return (a.x * b.x + a.y * b.y); }
double cross(point a, point b) { return (a.x * b.y - a.y * b.x); }
double vec_abs(point a){
return sqrt(a.x*a.x+a.y*a.y);
}
double distance_ls_p(point a, point b, point c) {
if ( dot(b-a, c-a) < EPS ) return vec_abs(c-a);
if ( dot(a-b, c-b) < EPS ) return vec_abs(c-b);
return abs(cross(b-a, c-a)) / vec_abs(b-a);
}
double dist(point a,point b){
return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
int is_point_on_line(point a, point b, point c) {
return cross(b-a, c-a)==0.0 &&
(dot(b-a, c-a) > -EPS) &&
(dot(a-b, c-b) > -EPS);
}
int is_intersected_ls(point a1, point a2, point b1, point b2) {
if(cross(a1-a2,b1-b2)==0){
return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2)
|| is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
}
else {
return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}
}
int crossCS(point a, point b, circle c){
double res=distance_ls_p(a,b,c.p);
double ac=dist(a,c.p);
double bc=dist(b,c.p);
if(res>c.r || (ac<c.r && bc<c.r))return 0;
else if(c.r-res<EPS ||(ac<c.r && bc>=c.r)||(ac>=c.r && bc<c.r))return 1;
else return 2;
}
int inside(point p, vector<point> ps, int n){
point a,b;
a=b=p;
b.x=DBL_MAX;
ps.push_back(ps[0]);
double ymx=-DBL_MAX,ymn=DBL_MAX;
for(int i=0;i ymx=max(ymx,ps[i].y);
ymn=min(ymn,ps[i].y);
}
if(a.y<=ymn||a.y>=ymx)return 0;
for(int i=0;i<n;i++){
if(is_point_on_line(ps[i],ps[i+1],p))return 1;
}
int cnt1=0;
for(int i=0;i<n;i++)
if(is_point_on_line(a,b,ps[i]))cnt1++;
int cnt=0;
for(int i=0;i<n;i++)
if(is_intersected_ls(ps[i],ps[i+1],a,b))cnt++;
return (cnt-cnt1)%2;
}
int crossCP(vector<point> t, circle C){
double ans=0;
int tsz=t.size();
for(int i=0;i<tsz;i++){
double tmp=dist(t[i],C.p);
if(tmp>ans)ans=tmp;
}
if(C.r>=ans)return 2;
int res1=inside(C.p,t,tsz);
double res2=DBL_MAX;
t.push_back(t[0]);
for(int i=0;i<tsz;i++)
res2=min(res2,distance_ls_p(t[i],t[i+1],C.p));
if(res1 && C.r<=res2)return 1;
else if(!res1 && C.r else return 3;
}
int main(void){
point p;
vector t;
circle C;
string ans="zabcd";
while(true){
t.clear();
for(int i=0;i<3;i++){
cin >> p.x >> p.y;
if(p.x==0 && p.y==0)return 0;
t.push_back(p);
}
cin >> C.p.x >> C.p.y >> C.r;
int res=crossCP(t,C);
cout << ans[res] << endl;
}
return 0;
} | a.cc: In function 'int inside(point, std::vector<point>, int)':
a.cc:101:14: error: expected ';' before 'ymx'
101 | for(int i=0;i ymx=max(ymx,ps[i].y);
| ^~~~
| ;
a.cc:101:35: error: expected ')' before ';' token
101 | for(int i=0;i ymx=max(ymx,ps[i].y);
| ~ ^
| )
a.cc:102:16: error: 'i' was not declared in this scope
102 | ymn=min(ymn,ps[i].y);
| ^
a.cc:103:1: warning: no return statement in function returning non-void [-Wreturn-type]
103 | }
| ^
a.cc: At global scope:
a.cc:104:1: error: expected unqualified-id before 'if'
104 | if(a.y<=ymn||a.y>=ymx)return 0;
| ^~
a.cc:106:1: error: expected unqualified-id before 'for'
106 | for(int i=0;i<n;i++){
| ^~~
a.cc:106:13: error: 'i' does not name a type
106 | for(int i=0;i<n;i++){
| ^
a.cc:106:17: error: 'i' does not name a type
106 | for(int i=0;i<n;i++){
| ^
a.cc:111:1: error: expected unqualified-id before 'for'
111 | for(int i=0;i<n;i++)
| ^~~
a.cc:111:13: error: 'i' does not name a type
111 | for(int i=0;i<n;i++)
| ^
a.cc:111:17: error: 'i' does not name a type
111 | for(int i=0;i<n;i++)
| ^
a.cc:115:1: error: expected unqualified-id before 'for'
115 | for(int i=0;i<n;i++)
| ^~~
a.cc:115:13: error: 'i' does not name a type
115 | for(int i=0;i<n;i++)
| ^
a.cc:115:17: error: 'i' does not name a type
115 | for(int i=0;i<n;i++)
| ^
a.cc:118:1: error: expected unqualified-id before 'return'
118 | return (cnt-cnt1)%2;
| ^~~~~~
a.cc:119:1: error: expected declaration before '}' token
119 | }
| ^
a.cc: In function 'int crossCP(std::vector<point>, circle)':
a.cc:142:21: error: expected ';' before 'else'
142 | else if(!res1 && C.r else return 3;
| ^~~~~
| ;
a.cc:143:1: error: expected primary-expression before '}' token
143 | }
| ^
a.cc:142:36: error: expected ')' before '}' token
142 | else if(!res1 && C.r else return 3;
| ~ ^
| )
143 | }
| ~
a.cc:143:1: error: expected primary-expression before '}' token
143 | }
| ^
a.cc: In function 'int main()':
a.cc:147:8: error: class template argument deduction failed:
147 | vector t;
| ^
a.cc:147:8: error: no matching function for call to 'vector()'
In file included from /usr/include/c++/14/vector:66,
from a.cc:4:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> vector(_InputIterator, _InputIterator, const _Alloc&)-> std::vector<_Tp, _Alloc>'
707 | vector(_InputIterator __first, _InputIterator __last,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::initializer_list<_Tp>, const _Alloc&)-> std::vector<_Tp, _Alloc>'
678 | vector(initializer_list<value_type> __l,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::false_type)-> std::vector<_Tp, _Alloc>'
640 | vector(vector&& __rv, const allocator_type& __m, false_type)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::true_type)-> std::vector<_Tp, _Alloc>'
635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&)-> std::vector<_Tp, _Alloc>'
620 | vector(vector&&) noexcept = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&)-> std::vector<_Tp, _Alloc>'
601 | vector(const vector& __x)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Tp&, const _Alloc&)-> std::vector<_Tp, _Alloc>'
569 | vector(size_type __n, const value_type& __value,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Alloc&)-> std::vector<_Tp, _Alloc>'
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const _Alloc&)-> std::vector<_Tp, _Alloc>'
542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'template<class _Tp, class _Alloc> vector()-> std::vector<_Tp, _Alloc>'
531 | vector() = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note: template argument deduction/substitution failed:
a.cc:147:8: note: couldn't deduce template parameter '_Tp'
147 | vector t;
| ^
/usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>)-> std::vector<_Tp, _Alloc>'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Allocator, class, class> std::vector(_InputIterator, _InputIterator, _Allocator)-> vector<_ValT, _Allocator>'
2033 | vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate expects 2 arguments, 0 provided
a.cc: In function 'int crossCP(std::vector<point>, circle)':
a.cc:143:1: warning: control reaches end of non-void function [-Wreturn-type]
143 | }
| ^
|
s290916596 | p00153 | C++ | #include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<cfloat>
using namespace std;
double EPS = 1e-10;
const double PI = acos(-1);
double add(double a, double b){
if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
return a+b;
}
struct point{
double x, y;
point(){}
point(double x,double y) : x(x) , y(y){}
point operator + (point p){
return point(add(x,p.x), add(y,p.y));
}
point operator - (point p){
return point(add(x,-p.x), add(y,-p.y));
}
point operator * (double d){
return point(x*d,y*d);
}
point operator / (double d){
return point(x/d,y/d);
}
bool operator == ( const point &p ) const {
return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
}
};
struct circle{ point p; double r; };
double dot(point a, point b) { return (a.x * b.x + a.y * b.y); }
double cross(point a, point b) { return (a.x * b.y - a.y * b.x); }
double vec_abs(point a){
return sqrt(a.x*a.x+a.y*a.y);
}
double distance_ls_p(point a, point b, point c) {
if ( dot(b-a, c-a) < EPS ) return vec_abs(c-a);
if ( dot(a-b, c-b) < EPS ) return vec_abs(c-b);
return abs(cross(b-a, c-a)) / vec_abs(b-a);
}
double dist(point a,point b){
return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
int is_point_on_line(point a, point b, point c) {
return cross(b-a, c-a)==0.0 &&
(dot(b-a, c-a) > -EPS) &&
(dot(a-b, c-b) > -EPS);
}
int is_intersected_ls(point a1, point a2, point b1, point b2) {
if(cross(a1-a2,b1-b2)==0){
return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2)
|| is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
}
else {
return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}
}
int crossCS(point a, point b, circle c){
double res=distance_ls_p(a,b,c.p);
double ac=dist(a,c.p);
double bc=dist(b,c.p);
if(res>c.r || (ac<c.r && bc<c.r))return 0;
else if(c.r-res<EPS ||(ac<c.r && bc>=c.r)||(ac>=c.r && bc<c.r))return 1;
else return 2;
}
int inside(point p, vector<point> ps, int n){
point a,b;
a=b=p;
b.x=DBL_MAX;
ps.push_back(ps[0]);
double ymx=-DBL_MAX,ymn=DBL_MAX;
for(int i=0;i ymx=max(ymx,ps[i].y);
ymn=min(ymn,ps[i].y);
}
if(a.y<=ymn||a.y>=ymx)return 0;
for(int i=0;i<n;i++){
if(is_point_on_line(ps[i],ps[i+1],p))return 1;
}
int cnt1=0;
for(int i=0;i<n;i++)
if(is_point_on_line(a,b,ps[i]))cnt1++;
int cnt=0;
for(int i=0;i<n;i++)
if(is_intersected_ls(ps[i],ps[i+1],a,b))cnt++;
return (cnt-cnt1)%2;
}
int crossCP(vector<point> t, circle C){
double ans=0;
int tsz=t.size();
for(int i=0;i<tsz;i++){
double tmp=dist(t[i],C.p);
if(tmp>ans)ans=tmp;
}
if(C.r>=ans)return 2;
int res1=inside(C.p,t,tsz);
double res2=DBL_MAX;
t.push_back(t[0]);
for(int i=0;i<tsz;i++)
res2=min(res2,distance_ls_p(t[i],t[i+1],C.p));
if(res1 && C.r<=res2)return 1;
else if(!res1 && C.r else return 3;
}
int main(void){
point p;
vector t;
circle C;
string ans="zabcd";
while(true){
t.clear();
for(int i=0;i<3;i++){
cin >> p.x >> p.y;
if(p.x==0 && p.y==0)return 0;
t.push_back(p);
}
cin >> C.p.x >> C.p.y >> C.r;
int res=crossCP(t,C);
cout << ans[res] << endl;
}
return 0;
} | a.cc: In function 'int inside(point, std::vector<point>, int)':
a.cc:101:14: error: expected ';' before 'ymx'
101 | for(int i=0;i ymx=max(ymx,ps[i].y);
| ^~~~
| ;
a.cc:101:35: error: expected ')' before ';' token
101 | for(int i=0;i ymx=max(ymx,ps[i].y);
| ~ ^
| )
a.cc:102:16: error: 'i' was not declared in this scope
102 | ymn=min(ymn,ps[i].y);
| ^
a.cc:103:1: warning: no return statement in function returning non-void [-Wreturn-type]
103 | }
| ^
a.cc: At global scope:
a.cc:104:1: error: expected unqualified-id before 'if'
104 | if(a.y<=ymn||a.y>=ymx)return 0;
| ^~
a.cc:106:1: error: expected unqualified-id before 'for'
106 | for(int i=0;i<n;i++){
| ^~~
a.cc:106:13: error: 'i' does not name a type
106 | for(int i=0;i<n;i++){
| ^
a.cc:106:17: error: 'i' does not name a type
106 | for(int i=0;i<n;i++){
| ^
a.cc:111:1: error: expected unqualified-id before 'for'
111 | for(int i=0;i<n;i++)
| ^~~
a.cc:111:13: error: 'i' does not name a type
111 | for(int i=0;i<n;i++)
| ^
a.cc:111:17: error: 'i' does not name a type
111 | for(int i=0;i<n;i++)
| ^
a.cc:115:1: error: expected unqualified-id before 'for'
115 | for(int i=0;i<n;i++)
| ^~~
a.cc:115:13: error: 'i' does not name a type
115 | for(int i=0;i<n;i++)
| ^
a.cc:115:17: error: 'i' does not name a type
115 | for(int i=0;i<n;i++)
| ^
a.cc:118:1: error: expected unqualified-id before 'return'
118 | return (cnt-cnt1)%2;
| ^~~~~~
a.cc:119:1: error: expected declaration before '}' token
119 | }
| ^
a.cc: In function 'int crossCP(std::vector<point>, circle)':
a.cc:142:21: error: expected ';' before 'else'
142 | else if(!res1 && C.r else return 3;
| ^~~~~
| ;
a.cc:143:1: error: expected primary-expression before '}' token
143 | }
| ^
a.cc:142:36: error: expected ')' before '}' token
142 | else if(!res1 && C.r else return 3;
| ~ ^
| )
143 | }
| ~
a.cc:143:1: error: expected primary-expression before '}' token
143 | }
| ^
a.cc: In function 'int main()':
a.cc:147:8: error: class template argument deduction failed:
147 | vector t;
| ^
a.cc:147:8: error: no matching function for call to 'vector()'
In file included from /usr/include/c++/14/vector:66,
from a.cc:4:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> vector(_InputIterator, _InputIterator, const _Alloc&)-> std::vector<_Tp, _Alloc>'
707 | vector(_InputIterator __first, _InputIterator __last,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::initializer_list<_Tp>, const _Alloc&)-> std::vector<_Tp, _Alloc>'
678 | vector(initializer_list<value_type> __l,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::false_type)-> std::vector<_Tp, _Alloc>'
640 | vector(vector&& __rv, const allocator_type& __m, false_type)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::true_type)-> std::vector<_Tp, _Alloc>'
635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&)-> std::vector<_Tp, _Alloc>'
620 | vector(vector&&) noexcept = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&)-> std::vector<_Tp, _Alloc>'
601 | vector(const vector& __x)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Tp&, const _Alloc&)-> std::vector<_Tp, _Alloc>'
569 | vector(size_type __n, const value_type& __value,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Alloc&)-> std::vector<_Tp, _Alloc>'
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const _Alloc&)-> std::vector<_Tp, _Alloc>'
542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'template<class _Tp, class _Alloc> vector()-> std::vector<_Tp, _Alloc>'
531 | vector() = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note: template argument deduction/substitution failed:
a.cc:147:8: note: couldn't deduce template parameter '_Tp'
147 | vector t;
| ^
/usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>)-> std::vector<_Tp, _Alloc>'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Allocator, class, class> std::vector(_InputIterator, _InputIterator, _Allocator)-> vector<_ValT, _Allocator>'
2033 | vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate expects 2 arguments, 0 provided
a.cc: In function 'int crossCP(std::vector<point>, circle)':
a.cc:143:1: warning: control reaches end of non-void function [-Wreturn-type]
143 | }
| ^
|
s391899534 | p00153 | C++ | #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <bitset>
#include <string>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
// geometry library
const double EPS = 1.0e-8;
const double INF = 1.0e12;
typedef complex<double> P;
namespace std {
bool operator<(const P& p, const P& q) {
return p.real() != q.real() ? p.real() < q.real() : p.imag() < q.imag();
}
}
double cross(const P& p, const P& q) {
return imag(conj(p) * q);
}
double dot(const P& p, const P& q) {
return real(conj(p) * q);
}
struct L : public vector<P> {
public:
L(const P& p, const P& q) {
this->push_back(p);
this->push_back(q);
}
};
struct C {
public:
P p;
double r;
C() : p(0.0, 0.0), r(0.0) {}
C(const P& _p, double _r) : p(_p), r(_r) {}
};
// code for problem
int x, y, r;
P tr[3];
C cc;
// compute distance between 2 points
double distP2P(P& p, P& q) {
P d = p - q;
return sqrt(norm(d));
}
// compute shortest distance to line
double distP2L(P& p, L& l) {
double a = l[1].real() - l[0].real();
double b = l[0].imag() - l[1].imag();
double c = - a * l[0].real() - b * l[0].imag();
double de = abs(a * p.real() + b * p.imag() + c);
double nm = sqrt(a * a + b * b);
return de / nm;
}
// compute shortest distance to line segment
double distP2LS(P& p, L& l) {
double d1 = dot(p - l[0], l[1] - l[0]);
double d2 = dot(p - l[1], l[0] - l[1]);
if(d1 < 0 || d2 < 0) {
return min(distP2P(p, l[0]), distP2P(p, l[1]));
}
double a = l[1].real() - l[0].real();
double b = l[0].imag() - l[1].imag();
double c = - a * l[0].real() - b * l[0].imag();
double de = abs(a * p.real() + b * p.imag() + c);
double nm = sqrt(a * a + b * b);
return de / nm;
}
bool isPinT(P& p, P t[3]) {
P e0 = t[0] - p;
P e1 = t[1] - p;
P e2 = t[2] - p;
double d0 = cross(e0, e1);
double d1 = cross(e1, e2);
double d2 = cross(e2, e0);
if(d0 * d1 >= 0 && d1 * d2 >= 0 && d2 * d0 >= 0) return true;
return false;
}
void solve() {
// triangle is in circle ?
vector<double> d(6);
d[0] = distP2P(tr[0], cc.p);
d[1] = distP2P(tr[1], cc.p);
d[2] = distP2P(tr[2], cc.p);
printf("%f %f %f\n", d[0], d[1], d[2]);
if(d[0] <= cc.r && d[1] <= cc.r && d[2] <= cc.r) {
printf("b\n");
return;
}
// circle is in triangle ?
bool in = isPinT(cc.p, tr);
d[3] = distP2LS(cc.p, L(tr[0], tr[1]));
d[4] = distP2LS(cc.p, L(tr[1], tr[2]));
d[5] = distP2LS(cc.p, L(tr[2], tr[0]));
if(in && d[3] >= cc.r && d[4] >= cc.r && d[5] >= cc.r) {
printf("a\n");
return;
}
// intersects each other ?
sort(d.begin(), d.end());
if(d[0] <= cc.r) {
printf("c\n");
return;
}
// not intersect
printf("d\n");
}
int main() {
while( 1 ) {
scanf("%d%d", &x, &y);
if(x == 0 && y == 0) break;
tr[0] = P(x, y);
scanf("%d%d", &x, &y);
tr[1] = P(x, y);
scanf("%d%d", &x, &y);
tr[2] = P(x, y);
scanf("%d%d%d", &x, &y, &r);
cc = C(P(x, y), r);
solve();
}
} | a.cc: In function 'void solve()':
a.cc:126:31: error: cannot bind non-const lvalue reference of type 'L&' to an rvalue of type 'L'
126 | d[3] = distP2LS(cc.p, L(tr[0], tr[1]));
| ^~~~~~~~~~~~~~~
a.cc:86:26: note: initializing argument 2 of 'double distP2LS(P&, L&)'
86 | double distP2LS(P& p, L& l) {
| ~~~^
a.cc:127:31: error: cannot bind non-const lvalue reference of type 'L&' to an rvalue of type 'L'
127 | d[4] = distP2LS(cc.p, L(tr[1], tr[2]));
| ^~~~~~~~~~~~~~~
a.cc:86:26: note: initializing argument 2 of 'double distP2LS(P&, L&)'
86 | double distP2LS(P& p, L& l) {
| ~~~^
a.cc:128:31: error: cannot bind non-const lvalue reference of type 'L&' to an rvalue of type 'L'
128 | d[5] = distP2LS(cc.p, L(tr[2], tr[0]));
| ^~~~~~~~~~~~~~~
a.cc:86:26: note: initializing argument 2 of 'double distP2LS(P&, L&)'
86 | double distP2LS(P& p, L& l) {
| ~~~^
|
s039303835 | p00153 | C++ | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
typedef complex<double> P;
struct L : public vector<P> {L(const P &a, const P &b) {push_back(a); push_back(b);} };
int chk(P a,P b,double r){
double t = abs(a-b) - r;
if( fabs(t) < EPS ) return 0;
return t < 0 ? -1 : 1;
}
double cross(P a,P b){
return imag(a*conj(b));
}
double dot(const P& a, const P& b) {return real(conj(a)*b);}
P projection(const L &l, const P &p) {double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);return l[0] + t*(l[0]-l[1]);}
bool intersectSP(const L &s, const P &p) {return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS;}
double distanceSP(const L &s, const P &p) {
const P r = projection(s, p);
if (intersectSP(s, r)) return abs(r - p);
return min(abs(s[0] - p), abs(s[1] - p));
}
int main(){
P a,b,c,d;
double r;
while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
cin >> b.real() >> b.imag();
cin >> c.real() >> c.imag();
cin >> d.real() >> d.imag();
cin >> r;
int in = 0;
int mk = cross(a-d,b-d) <= 0 ;
if( mk == (cross(b-d,c-d) <= 0) && mk == (cross(c-d,a-d) <= 0)){
in = 1;
}
if( chk(a,d,r) <= 0 && chk(b,d,r) <= 0 && chk(c,d,r) <= 0 ){
cout << "b" << endl;
}else if( chk(a,d,r) >= 0 && chk(b,d,r) >= 0 && chk(c,d,r) >= 0){
if( distanceSP(L(a,b),d) < r - EPS || distanceSP(L(b,c),d) < r - EPS || distanceSP(L(a,c),d) < r - EPS ){
cout << "c" << endl;
}else if( in ){
cout << "a" << endl;
}else if( distanceSP(L(a,b),d) > r + EPS || distanceSP(L(b,c),d) > r + EPS || distanceSP(L(a,c),d) > r + EPS )
cout << "d" << endl;
}
cout << "c" << endl;
}else{
cout << "c" << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:67:19: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double')
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~ ^~ ~~~~~~~~
| | |
| | double
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:10:
/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:67:28: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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:67:28: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double'
67 | while(cin >> a.real() >> a.imag() , a.real() != 0 || a.imag() != 0 ){
| ~~~~~~^~
/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_i |
s616055528 | p00154 | Java |
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Map.Entry;
public class Sample {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
int n = scanner.nextInt();
if (n == 0)
break;
Map<Integer, Integer> memo = new HashMap<Integer, Integer>();
memo.put(0, 1);
for (int i = 0; i < n; i++) {
int a = scanner.nextInt();
int b = scanner.nextInt();
Map<Integer, Integer> tmp = new HashMap<Integer, Integer>();
tmp.putAll(memo);
for (Entry<Integer, Integer> entry : memo.entrySet()) {
for (int j = 1; j <= b; j++) {
int c = entry.getKey() + a * j;
if (c > 1000) {
continue;
}
int d = entry.getValue();
if (tmp.containsKey(c)) {
tmp.put(c, d + tmp.get(c));
} else {
tmp.put(c, d);
}
}
}
memo = tmp;
}
int s = scanner.nextInt();
while (s-- > 0) {
int m = scanner.nextInt();
if (!memo.containsKey(m)) {
System.out.println(0);
} else {
System.out.println(memo.get(m));
}
}
}
}
} | Main.java:7: error: class Sample is public, should be declared in a file named Sample.java
public class Sample {
^
1 error
|
s437183179 | p00154 | Java | public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
int n = scanner.nextInt();
if (n == 0)
break;
Map<Integer, Integer> memo = new HashMap<Integer, Integer>();
memo.put(0, 1);
for (int i = 0; i < n; i++) {
int a = scanner.nextInt();
int b = scanner.nextInt();
Map<Integer, Integer> tmp = new HashMap<Integer, Integer>();
tmp.putAll(memo);
for (Entry<Integer, Integer> entry : memo.entrySet()) {
for (int j = 1; j <= b; j++) {
int c = entry.getKey() + a * j;
if (c > 1000) {
continue;
}
int d = entry.getValue();
if (tmp.containsKey(c)) {
tmp.put(c, d + tmp.get(c));
} else {
tmp.put(c, d);
}
}
}
memo = tmp;
}
int s = scanner.nextInt();
while (s-- > 0) {
int m = scanner.nextInt();
if (!memo.containsKey(m)) {
System.out.println(0);
} else {
System.out.println(memo.get(m));
}
}
}
}
} | Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args) {
^
(use --enable-preview to enable unnamed classes)
Main.java:43: error: class, interface, enum, or record expected
}
^
2 errors
|
s035894716 | p00154 | Java | import java.util.*;
public class AOJ_0154{
class Card{
int a;
int b;
Card(int a, int b){
this.a = a;
this.b = b;
}
}
void run(){
Scanner sc = new Scanner(System.in);
while(true){
int[] card_num = new int[101];
int m = sc.nextInt();
if(m==0){
break;
}
Card[] cards = new Card[m];
for(int i = 0; i < m; i++){
cards[i] = new Card(sc.nextInt(), sc.nextInt());
}
int ub = 7*100*10;
int[] dp = new int[ub];
dp[0] = 1;
for(int i = 0; i < m; i++){
for(int ii = 7 * 100 * 10 - cards[i].a -1; ii >= 0; ii--){
for(int iii = 1; iii <= cards[i].b; iii++){
if(ii + cards[i].a*iii < ub-1){
dp[ii + cards[i].a*iii] += dp[ii];
}
}
}
}
/*
System.out.println(Arrays.toString(dp));
for(int i = 0; i < 100; i++){
System.out.println(i + " : " + dp[i]);
}
*/
int g = sc.nextInt();
for(int i = 0; i < g; i++){
System.out.println(dp[sc.nextInt()]);
}
}
}
public static void main(String[] args){
new AOJ_0154().run();
}
} | Main.java:3: error: class AOJ_0154 is public, should be declared in a file named AOJ_0154.java
public class AOJ_0154{
^
1 error
|
s941533785 | p00154 | Java | import java.util.*;
public class AOJ_0154_2{
void run(){
Scanner sc = new Scanner(System.in);
while(true){
int m = sc.nextInt();
if(m==0){
break;
}
int[] value = new int[m];
int[] num = new int[m];
for(int i = 0; i < m; i++){
value[i] = sc.nextInt();
num[i] = sc.nextInt();
}
int[] dp = new int[1001];
dp[0] = 1;
for(int i = 0; i < m; i++){
for(int ii = 1000 - value[i]; ii >= 0; ii--){
for(int iii = 1; iii <= num[i]; iii++){
if(ii + value[i]*iii <= 1000){
dp[ii + value[i]*iii] += dp[ii];
}
}
}
}
/*
System.out.println(Arrays.toString(dp));
for(int i = 0; i < 100; i++){
System.out.println(i + " : " + dp[i]);
}
*/
int g = sc.nextInt();
for(int i = 0; i < g; i++){
System.out.println(dp[sc.nextInt()]);
}
}
}
public static void main(String[] args){
new AOJ_0154_2().run();
}
} | Main.java:3: error: class AOJ_0154_2 is public, should be declared in a file named AOJ_0154_2.java
public class AOJ_0154_2{
^
1 error
|
s635424170 | p00154 | Java | import java.util.*;
public class AOJ_0154_2{
void run(){
Scanner sc = new Scanner(System.in);
while(true){
int m = sc.nextInt();
if(m==0){
break;
}
int[] value = new int[m];
int[] num = new int[m];
for(int i = 0; i < m; i++){
value[i] = sc.nextInt();
num[i] = sc.nextInt();
}
int[] dp = new int[1001];
dp[0] = 1;
for(int i = 0; i < m; i++){
for(int ii = 1000 - value[i]; ii >= 0; ii--){
for(int v = value[i]; v <= value[i] * num[i]; v += value[i]){
if(ii + v <= 1000){
dp[ii + v] += dp[ii];
}
}
}
}
/*
System.out.println(Arrays.toString(dp));
for(int i = 0; i < 100; i++){
System.out.println(i + " : " + dp[i]);
}
*/
int g = sc.nextInt();
for(int i = 0; i < g; i++){
System.out.println(dp[sc.nextInt()]);
}
}
}
public static void main(String[] args){
new AOJ_0154_2().run();
}
} | Main.java:3: error: class AOJ_0154_2 is public, should be declared in a file named AOJ_0154_2.java
public class AOJ_0154_2{
^
1 error
|
s054702031 | p00154 | C++ | #include <iostream>
#include <cmath>
#include <string>
using namespace std;
const int MAX_M = 7, MAX_B = 10, MAX_N = 1000;
int m,g,n;
int a[MAX_M], b[MAX_M];
int dp[MAX_M + 1][MAX_N + 1];
int main()
{
while(cin >> m && m) {
for(int i = 0; i < m; i++)
cin >> a[i] >> b[i];
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for(int i = 0; i < m; i++) {
for(int j = 0; j <= MAX_N; j++) {
for(int k = 0; k <= b[i]; k++) {
if(j + a[i] * k > 1000) continue;
dp[i+1][j+a[i]*k] += dp[i][j];
}
}
}
cin >> g;
for(int k = 0; k < g; k++) {
cin >> n;
cout << dp[m][n] << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:18:9: error: 'memset' was not declared in this scope
18 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <cmath>
+++ |+#include <cstring>
3 | #include <string>
|
s729132330 | p00154 | C++ | #include<iostream>
using namespace std;
long long int dp[1001];
int a[8],b[8];
int main(void){
int n,g;
while(1){
memset(dp,0,sizeof(dp));
scanf("%d",&n);
if(n==0)break;
for(int i=0;i<n;i++){
scanf("%d%d",&a[i],&b[i]);
}
dp[0]=1;
for(int i=0;i<n;i++){
for(int j=1000;j>=0;j--){
for(int k=1;k<=b[i];k++){
if(a[i]*k<=j){
dp[j]+=dp[j-a[i]*k];
}
}
}
}
scanf("%d",&g);
for(int i=0;i<g;i++){
int a;
scanf("%d",&a);
printf("%d\n",dp[a]);
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:9:17: error: 'memset' was not declared in this scope
9 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include<iostream>
+++ |+#include <cstring>
2 | using namespace std;
|
s576206929 | p00154 | C++ | #include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
int as[7];
int bs[7];
int m;
int sums[100 * 10 + 1];
void solve(int n, int sum) {
if (sum > 1000)
return;
if (n == m) {
sums[sum]++;
return;
}
for (int i = 0; i <= bs[n]; i++) {
solve(n + 1, sum + (i * as[n]));
}
}
int main() {
while (cin >> m, m) {
memset(sums, 0, sizeof(sums));
for (int i = 0; i < m; i++) {
cin >> as[i];
cin >> bs[i];
}
solve(0, 0);
int g;
cin >> g;
for (int i = 0; i < g; i++) {
int ni;
cin >> ni;
cout << sums[ni] << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:17: error: 'memset' was not declared in this scope
24 | memset(sums, 0, sizeof(sums));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <set>
+++ |+#include <cstring>
4 | #include <vector>
|
s877333365 | p00155 | C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX_HEAP_SIZE 500001 /* 最大ヒープ領域(ヒープ配列を1オリジンで持つため500000+1) */
#define MAX_BUILDING_NUM 101 /* 最大ビル数(1オリジン) */
#define INFINITE_VAL 100000000
#define FIX 1
#define NOT_FIX 0
#define MAX_MOVING_DISTANCE 50
#define CONNECT 1
#define NOT_CONNECT 0
int n;
int m;
int HeapSize;
int StartNode;
int GoalNode;
int HeapArray[MAX_HEAP_SIZE];
int PathBuffer[MAX_BUILDING_NUM];
struct Coordinate {
int x;
int y;
}cordinate[MAX_BUILDING_NUM];
struct Node {
int ConnectNode[MAX_BUILDING_NUM];
double ConnectCost[MAX_BUILDING_NUM];
int NodeFromThis;
int FixNodeFlag;
double CostToThis;
}node[MAX_BUILDING_NUM];
void inputBuildingData(void)
{
int i;
int BuildingNum;
int x;
int y;
scanf_s("%d", &n);
if (n != 0) {
for (i = 1; i <= n; i++) {
scanf_s("%d", &BuildingNum);
scanf_s("%d%d", &cordinate[BuildingNum].x, &cordinate[BuildingNum].y);
}
scanf_s("%d", &m);
}
}
void inputDataSet(void)
{
scanf_s("%d%d", &StartNode, &GoalNode);
}
void initVer(void)
{
int i;
int j;
HeapSize = 0;
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
node[i].ConnectNode[j] = NOT_CONNECT;
node[i].ConnectNode[j] = INFINITE_VAL;
}
node[i].NodeFromThis = 0;
node[i].CostToThis = INFINITE_VAL;
node[i].FixNodeFlag = NOT_FIX;
PathBuffer[i] = 0;
}
}
void makeUndirectedGraph(void)
{
int i;
int j;
double NodeDistance;
double MoveDistance;
int NodeDistance_x;
int NodeDistance_y;
MoveDistance = sqrt(MAX_MOVING_DISTANCE * MAX_MOVING_DISTANCE);
for (i = 1; i <= n; i++) {
for (j = i+1; j <= n; j++) {
NodeDistance_x = abs(cordinate[i].x - cordinate[j].x);
NodeDistance_y = abs(cordinate[i].y - cordinate[j].y);
NodeDistance = sqrt(NodeDistance_x * NodeDistance_x + NodeDistance_y * NodeDistance_y);
if (NodeDistance <= MoveDistance) {
node[i].ConnectNode[j] = CONNECT;
node[i].ConnectCost[j] = NodeDistance;
node[j].ConnectNode[i] = CONNECT;
node[j].ConnectCost[i] = NodeDistance;
}
}
}
}
#if 0
/****************************************************************************/
/* 関数名 | maxHeapify */
/* 関数仕様 | Nodeを根とする部分木をmax-ヒープ木にする */
/****************************************************************************/
void
maxHeapify(int Node)
{
int LeftNode;
int RightNode;
int SmallestNode;
int TmpHeapVal;
/* ヒープ配列は、Nodeの要素数をnとすると、Nodeの子の要素数は左が2n、右が2n×1 */
LeftNode = 2 * Node;
RightNode = LeftNode + 1;
/* NodeとNodeの子の中で、最大値の要素数を求める */
if ((LeftNode <= HeapSize)
&& (node[LeftNode].CostToThis < node[Node].CostToThis))
{
SmallestNode = LeftNode;
}
else {
SmallestNode = Node;
}
if ((RightNode <= HeapSize)
&& (node[RightNode].CostToThis < node[Node].CostToThis))
{
SmallestNode = RightNode;
}
/* Nodeに対しNodeの子の方が大きい場合、NodeとNodeの子の値を入れ替える */
if (SmallestNode != Node)
{
TmpHeapVal = HeapArray[Node];
HeapArray[Node] = HeapArray[SmallestNode];
HeapArray[SmallestNode] = TmpHeapVal;
/* NodeとNodeの子の値を入れ替えたヒープ配列に対し、Nodeの子にmaxHeapifyを適用する */
maxHeapify(SmallestNode);
}
}
#endif
/****************************************************************************/
/* 関数名 | maxHeapify */
/* 関数仕様 | Nodeを根とする部分木をmax-ヒープ木にする */
/****************************************************************************/
void
maxHeapify(int Node)
{
int LeftNode;
int RightNode;
int SmallestNode;
int TmpHeapVal;
/* ヒープ配列は、Nodeの要素数をnとすると、Nodeの子の要素数は左が2n、右が2n×1 */
LeftNode = 2 * Node;
RightNode = LeftNode + 1;
/* NodeとNodeの子の中で、最大値の要素数を求める */
if ((LeftNode <= HeapSize)
&& (node[LeftNode].CostToThis < node[Node].CostToThis))
{
SmallestNode = LeftNode;
}
else {
SmallestNode = Node;
}
if ((RightNode <= HeapSize)
&& (node[RightNode].CostToThis < node[SmallestNode].CostToThis))
{
SmallestNode = RightNode;
}
/* Nodeに対しNodeの子の方が大きい場合、NodeとNodeの子の値を入れ替える */
if (SmallestNode != Node)
{
TmpHeapVal = HeapArray[Node];
HeapArray[Node] = HeapArray[SmallestNode];
HeapArray[SmallestNode] = TmpHeapVal;
/* NodeとNodeの子の値を入れ替えたヒープ配列に対し、Nodeの子にmaxHeapifyを適用する */
maxHeapify(SmallestNode);
}
}
void pushVal(int insertval) {
int tmpNode;
int TmpHeapVal;
HeapSize++;
tmpNode = HeapSize;
HeapArray[HeapSize] = insertval;
while (tmpNode > 1 && node[tmpNode / 2].CostToThis > node[tmpNode].CostToThis) {
TmpHeapVal = HeapArray[tmpNode];
HeapArray[tmpNode] = HeapArray[tmpNode / 2];
HeapArray[tmpNode / 2] = TmpHeapVal;
tmpNode = tmpNode / 2;
}
}
int popVal(void) {
int ret;
if (HeapSize >= 1) {
ret = HeapArray[1];
HeapArray[1] = HeapArray[HeapSize];
HeapSize--;
maxHeapify(1);
}
return ret;
}
void findShortestPath(void)
{
int i;
int TmpNode;
node[StartNode].CostToThis = 0;
node[StartNode].NodeFromThis = StartNode;
pushVal(StartNode);
while (HeapSize != 0) {
TmpNode = popVal();
if (node[TmpNode].FixNodeFlag == NOT_FIX) {
for (i = 1; i < MAX_BUILDING_NUM; i++) {
if (node[TmpNode].ConnectNode[i] == CONNECT){
pushVal(i);
if (node[i].CostToThis > node[TmpNode].CostToThis + node[TmpNode].ConnectCost[i]) {
node[i].CostToThis = node[TmpNode].CostToThis + node[TmpNode].ConnectCost[i];
node[i].NodeFromThis = TmpNode;
}
}
}
node[TmpNode].FixNodeFlag = FIX;
}
}
}
void outputVal(void)
{
int i;
int nodenum;
nodenum = 1;
i = GoalNode;
PathBuffer[nodenum] = i;
nodenum++;
do{
i = node[i].NodeFromThis;
PathBuffer[nodenum] = i;
nodenum++;
} while (i != 0 && i != StartNode);
if (i == StartNode) {
for (i = nodenum-1; i > 0; i--) {
printf("%d ", PathBuffer[i]);
}
}
else {
printf("NA");
}
printf("\n");
}
int main(void)
{
int i;
do{
/* 入力部 */
inputBuildingData();
if(n != 0){
initVer();
for (i = 1; i <= m; i++) {
inputDataSet();
/* 制御部 */
makeUndirectedGraph();
findShortestPath();
/* 出力部 */
outputVal();
}
}
} while (n != 0);
while (1);
}
| main.c: In function 'inputBuildingData':
main.c:42:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
42 | scanf_s("%d", &n);
| ^~~~~~~
| scanf
|
s050367333 | p00155 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>
using namespace std;
typedef pair<double,int> P;
const double INF = 1000000000;
struct edge { int to; double cost; };
vector<edge> G[1001];
void solve(int s, int g) {
double d[1001]; fill(d, d+1001, INF);
int prv[1001]; fill(prv, prv+1001, -1);
priority_queue<P, vector<P>, greater<P>> q;
d[s] = 0;
q.push(make_pair(0, s));
while ( ! q.empty()) {
int v = q.top().second;
q.pop();
for (int i=0; i<(int)G[v].size(); ++i) {
edge &e = G[v][i];
if (e.cost != INF && d[v] + e.cost < d[e.to]) {
d[e.to] = d[v] + e.cost;
q.push(make_pair(d[e.to], e.to));
prv[e.to] = v;
}
}
}
int k = g;
if (prv[k] < 0) {
cout << "NA" << endl;
} else {
vector<int> ret;
while (0 <= k) {
ret.push_back(k);
k = prv[k];
}
for (int i=ret.size()-1; i>=0; --i) {
cout << ret[i] << (i != 0 ? " " : "");
}
cout << endl;
}
}
int main() {
int n, m, s, g;
int b[1000], x[1000], y[1000];
while (cin >> n, n) {
for (int i=0; i<n; ++i) {
cin >> b[i] >> x[i] >> y[i];
}
for (int i=0; i<1001; ++i) {
G[i].clear();
}
for (int i=0; i<n; ++i) {
for (int j=i+1; j<n; ++j) {
int cost = (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
if (2500 < cost) {
G[b[i]].push_back((edge){b[j], INF});
G[b[j]].push_back((edge){b[i], INF});
} else {
G[b[i]].push_back((edge){b[j], sqrt(cost)});
G[b[j]].push_back((edge){b[i], sqrt(cost)});
}
}
}
cin >> m;
for (int i=0; i<m; ++i) {
cin >> s >> g;
solve(s, g);
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:66:52: error: 'sqrt' was not declared in this scope
66 | G[b[i]].push_back((edge){b[j], sqrt(cost)});
| ^~~~
|
s977590425 | p00155 | C++ | #include<bits/stdc++.h>
using namespace std;
const int EPS = 1e-6;
struct Building{
double x,y;
}
struct Edge{
int to;
double dist;
Edge(){}
Edge(int to_c, double dist_c){
to = to_c; dist = dist_c;
}
};
struct Data{
int n, cost;
Data(){}
Data(int n_c, int cost_c){
n = n_c; cost = cost_c;
}
bool operator
}
double GetDistnace(Building b1, Building b2){
int dx = b1.x - b2.x, dy = b1.y - b2.y;
return sqrt(dx*dx + dy*dy);
}
vector<Edge> e[1000];
int main(){
Building b[1000] = {};
int N, M;
cin >> N;
for(int i = 0; i < N; i++){
int indx;
cin >> indx; indx--;
cin >> b[indx].x >> b[indx].y;
}
for(int i = 0; i < N; i++){
if(b[i].x == 0) continue;
for(int j = 0; j < N; j++){
if(i == j || b[j].x == 0) continue;
double dist = GetDistance(b[i], b[j]);
if(dist <= 50) e[i].push( Edge(j, dist) );
}
}
cin >> M;
for(int i = 0; i < M; i++){
int s,g;
cin >> s >> g; s--; g--;
priority_queue<Data> pq;
Data fpq;
pq.push( Data(s, 0) );
double memo[1000];
fill_n(memo, 1000, 100000);
while( !pq.empty() ){
fpq = pq.top();
if(fpq.n == g) break;
if(memo[fpq.n] <= 10000) continue;
for(int j = 0; j < e[fpq.n].size(); j++){
pq.push( Data( e[fpq.n][j].to, fpq.cost + e[fpq.n][j].dist ) );
}
}
vector<int> ans;
for(int j = g; j != s;){
for(int k = 0; k < 1000; k++){
if( abs( memo[k] + e[j][k].dist - memo[j] ) < EPS ){
j = k; break;
}
}
}
}
return 0;
} | a.cc:8:2: error: expected ';' after struct definition
8 | }
| ^
| ;
a.cc:26:1: error: expected type-specifier before '}' token
26 | }
| ^
a.cc:26:2: error: expected ';' after struct definition
26 | }
| ^
| ;
a.cc: In function 'int main()':
a.cc:48:39: error: 'GetDistance' was not declared in this scope; did you mean 'GetDistnace'?
48 | double dist = GetDistance(b[i], b[j]);
| ^~~~~~~~~~~
| GetDistnace
a.cc:49:45: error: 'class std::vector<Edge>' has no member named 'push'
49 | if(dist <= 50) e[i].push( Edge(j, dist) );
| ^~~~
In file included from /usr/include/c++/14/string:49,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Data]':
/usr/include/c++/14/bits/predefined_ops.h:196:23: required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<Data*, std::vector<Data, std::allocator<Data> > >; _Value = Data; _Compare = std::less<Data>]'
196 | { return bool(_M_comp(*__it, __val)); }
| ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Data*, vector<Data, allocator<Data> > >; _Distance = long int; _Tp = Data; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<Data> >]'
140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:216:23: required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<Data*, vector<Data, allocator<Data> > >; _Compare = less<Data>]'
216 | std::__push_heap(__first, _DistanceType((__last - __first) - 1),
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
217 | _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:747:16: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = Data; _Sequence = std::vector<Data, std::allocator<Data> >; _Compare = std::less<Data>; value_type = Data]'
747 | std::push_heap(c.begin(), c.end(), comp);
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:10: required from here
60 | pq.push( Data(s, 0) );
| ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const Data' and 'const Data')
405 | { return __x < __y; }
| ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Data' is not derived from 'const std::pair<_T1, _T2>'
405 | { return __x < __y; }
| ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Data' is not derived from 'const std::reverse_iterator<_Iterator>'
405 | { return __x < __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Data' is not derived from 'const std::reverse_iterator<_Iterator>'
405 | { return __x < __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Data' is not derived from 'const std::move_iterator<_IteratorL>'
405 | { return __x < __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const Data' is not derived from 'const std::move_iterator<_IteratorL>'
405 | { return __x < __y; }
| ~~~~^~~~~
|
s633626025 | p00155 | C++ | #include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
const double EPS = 1e-4;
struct Building{
int x, y;
};
struct Edge{
int to;
double cost;
Edge(){}
Edge(const int &_to, const double &_cost){
to = _to; cost = _cost;
}
};
struct Data{
int n;
double cost;
Data(){}
Data(const int &_n, const double &_cost){
n = _n; cost = _cost;
}
bool operator < (const Data &a) const{
return cost > a.cost;
}
};
double GetDistance(const Building &b1, const Building &b2){
double dx = b1.x - b2.x, dy = b1.y - b2.y;
return sqrt(dx*dx + dy*dy);
}
int main(){
int N, M, B, S, G;
while(cin >> N, N){
Building v[1000];
vector<Edge> e[1000];
for(int i = 0; i < N; i++){
cin >> B; B--;
cin >> v[B].x >> v[B].y;
}
for(int i = 0; i < N; i++){
for(int j = i+1; j < N; j++){
double dist = GetDistance(v[i], v[j]);
if(dist <= 50){
e[i].push_back( Edge(j, dist) );
e[j].push_back( Edge(i, dist) );
}
}
}
cin >> M;
for(int j = 0; j < M; j++){
cin >> S >> G; S--; G--;
priority_queue<Data> pq;
Data pq_top;
pq.push( Data(S, 0) );
double memo[1000];
fill_n(memo, N, -1);
bool na = true;
while( !pq.empty() ){
pq_top = pq.top(); pq.pop();
if(memo[pq_top.n] > -0.5) continue;
memo[pq_top.n] = pq_top.cost;
if(pq_top.n == G){
na = false; break;
}
for(int i = 0; i < e[pq_top.n].size(); i++){
pq.push( Data( e[pq_top.n][i].to, pq_top.cost + e[pq_top.n][i].cost ) );
}
}
if(na){
puts("NA"); break;
}
stack<int> ans;
while(true){
ans.push(G);
if(G == S) break;
for(int i = 0; i < e[G].size(); i++){
if( abs(memo[G] - memo[ e[G][i].to ] - e[G][i].cost) < EPS){
G = e[G][i].to; break;
}
}
}
printf("%d", ans.top()+1 ); ans.pop();
while( !ans.empty() ){
printf(" %d", ans.top()+1 ); ans.pop();
}puts("");
}
}
return 0;
} | a.cc: In function 'double GetDistance(const Building&, const Building&)':
a.cc:38:16: error: 'sqrt' was not declared in this scope
38 | return sqrt(dx*dx + dy*dy);
| ^~~~
|
s242036981 | p00155 | C++ | #include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
const double EPS = 1e-4;
struct Building{
int x, y;
};
struct Edge{
int to;
double cost;
Edge(){}
Edge(const int &_to, const double &_cost){
to = _to; cost = _cost;
}
};
struct Data{
int n;
double cost;
Data(){}
Data(const int &_n, const double &_cost){
n = _n; cost = _cost;
}
bool operator < (const Data &a) const{
return cost > a.cost;
}
};
double GetDistance(Building &b1, Building &b2){
double dx = b1.x - b2.x, dy = b1.y - b2.y;
return sqrt(dx*dx + dy*dy);
}
int main(){
int N, M, B, S, G;
while(cin >> N, N){
Building v[1000];
vector<Edge> e[1000];
for(int i = 0; i < N; i++){
cin >> B; B--;
cin >> v[B].x >> v[B].y;
}
for(int i = 0; i < N; i++){
for(int j = i+1; j < N; j++){
double dist = GetDistance(v[i], v[j]);
if(dist <= 50){
e[i].push_back( Edge(j, dist) );
e[j].push_back( Edge(i, dist) );
}
}
}
cin >> M;
for(int j = 0; j < M; j++){
cin >> S >> G; S--; G--;
priority_queue<Data> pq;
Data pq_top;
pq.push( Data(S, 0) );
double memo[1000];
fill_n(memo, N, -1);
bool na = true;
while( !pq.empty() ){
pq_top = pq.top(); pq.pop();
if(memo[pq_top.n] > -0.5) continue;
memo[pq_top.n] = pq_top.cost;
if(pq_top.n == G){
na = false; break;
}
for(int i = 0; i < e[pq_top.n].size(); i++){
pq.push( Data( e[pq_top.n][i].to, pq_top.cost + e[pq_top.n][i].cost ) );
}
}
if(na){
puts("NA"); break;
}
stack<int> ans;
while(true){
ans.push(G);
if(G == S) break;
for(int i = 0; i < e[G].size(); i++){
if( abs(memo[G] - memo[ e[G][i].to ] - e[G][i].cost) < EPS){
G = e[G][i].to; break;
}
}
}
printf("%d", ans.top()+1 ); ans.pop();
while( !ans.empty() ){
printf(" %d", ans.top()+1 ); ans.pop();
}puts("");
}
}
return 0;
} | a.cc: In function 'double GetDistance(Building&, Building&)':
a.cc:38:16: error: 'sqrt' was not declared in this scope
38 | return sqrt(dx*dx + dy*dy);
| ^~~~
|
s769637511 | p00155 | C++ | #include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<functional>
using namespace std;
typedef pair<double, int> P;
priority_queue<P, vector<P>, greater<P>> Q;
#define MAX_N 1005
int x[MAX_N], y[MAX_N]; double dist[MAX_N];
vector<int>path[MAX_N]; vector<P>X[MAX_N];
void dijkstra(int a, int b) {
memset(dist, 1e+9, sizeof(dist));
for (int i = ; i < MAX_N; i++) { path[i].clear(); }
Q.push(make_pair(0.0, a)); dist[a] = 0; path[a].push_back(a);
while (!Q.empty()) {
pair<double, int>pa = Q.top(); Q.pop();
double a1 = pa.first; int a2 = pa.second;
for (int i = 0; i < X[a2].size(); i++) {
int to = X[a2][i].second; double dis = X[a2][i].first;
if (dist[to] > a1 + dis) {
dist[to] = a1 + dis; path[to].clear();
path[to] = path[a2]; path[to].push_back(to);
Q.push(make_pair(dist[to], to));
}
}
}
if (path[b].size() == 0) { cout << "NA" << endl; }
else {
for (int i = 0; i < path[b].size(); i++) { if (i) { cout << ' '; } cout << path[b][i]; }
cout << endl;
}
}
int main() {
int N, Q, s, g;
while (true) {
cin >> N; if (N == 0) { break; }
for (int i = 0; i < N; i++) { cin >> x[i] >> y[i]; }
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
double dist2 = (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]);
if (dist2 <= 50.0) {
X[i].push_back(make_pair(dist2, j));
}
}
}
cin >> Q; for (int i = 0; i < Q; i++) { cin >> s >> g; dijkstra(s, g); }
}
return 0;
} | a.cc: In function 'void dijkstra(int, int)':
a.cc:14:22: error: expected primary-expression before ';' token
14 | for (int i = ; i < MAX_N; i++) { path[i].clear(); }
| ^
|
s997722827 | p00155 | C++ | #include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<functional>
using namespace std;
typedef pair<double, int> P;
priority_queue<P, vector<P>, greater<P>> Q;
#define MAX_N 1005
int x[MAX_N], y[MAX_N]; double dist[MAX_N];
vector<int>path[MAX_N]; vector<P>X[MAX_N];
void dijkstra(int a, int b) {
memset(dist, 1e+9, sizeof(dist));
for (int i = ; i < MAX_N; i++) { path[i].clear(); }
Q.push(make_pair(0.0, a)); dist[a] = 0; path[a].push_back(a);
while (!Q.empty()) {
pair<double, int>pa = Q.top(); Q.pop();
double a1 = pa.first; int a2 = pa.second;
for (int i = 0; i < X[a2].size(); i++) {
int to = X[a2][i].second; double dis = X[a2][i].first;
if (dist[to] > a1 + dis) {
dist[to] = a1 + dis; path[to].clear();
path[to] = path[a2]; path[to].push_back(to);
Q.push(make_pair(dist[to], to));
}
}
}
if (path[b].size() == 0) { cout << "NA" << endl; }
else {
for (int i = 0; i < path[b].size(); i++) { if (i) { cout << ' '; } cout << path[b][i]; }
cout << endl;
}
}
int main() {
int N, Q, s, g;
while (true) {
cin >> N; if (N == 0) { break; }
for (int i = 0; i < N; i++) { cin >> x[i] >> y[i]; }
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
double dist2 = (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]);
if (dist2 <= 50.0) {
X[i].push_back(make_pair(dist2, j));
}
}
}
cin >> Q; for (int i = 0; i < Q; i++) { cin >> s >> g; dijkstra(s, g); }
}
return 0;
} | a.cc: In function 'void dijkstra(int, int)':
a.cc:14:22: error: expected primary-expression before ';' token
14 | for (int i = ; i < MAX_N; i++) { path[i].clear(); }
| ^
|
s910634520 | p00155 | C++ | #include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
//const double D_INF = 1e18;
const double PI = acos(-1);
int dx[] ={-1,0,1,0};
int dy[] ={0,-1,0,1};
struct Edge
{
int t, c;
Edge(){};
Edge(int t, int c) : t(t), c(c){};
};
int n;
int b[1010], x[1010], y[1010];
vector<Edge> edge[1010];
pair<int, int> d[1010];
bool used[1010];
vi ans;
void dijkstra(int s){
rep(i, 1010){
d[i] = mp(INF, -1);
used[i] = false;
}
d[s].fi = 0;
priority_queue<pii, vector<pii>, greater<pii> > q;
pii p;
q.push(mp(0, s));
int from, to, cost;
while(!q.empty()){
p = q.top(); q.pop();
from = p.se;
//cost = p.fi;
if(d[from]<p.fi) continue;
cost = d[from].fi;
used[from] = true;
edge e = edge[from];
for(int i = 0; i < e.size(); i++){
to = e[i].t;
//if(used[to]) continue;
if(d[to].fi > cost+e[i].c){
d[to].fi = cost+e[i].c;
d[to].se = from;
q.push(mp(d[to].fi, to));
}
}
}
}
int main(){
int m, dx, dy;
while(cin>>n && n){
//cout<<n<<endl;
rep(i, 1010){
b[i]=x[i]=y[i] = -1;
d[i] = mp(INF, -1);
used[i] = false;
edge[i].clear();
}
rep(i, n) cin>>b[i]>>x[i]>>y[i];
for(int i = 0; i < 1010; i++){
if(b[i] == -1 || x[i] == -1 || y[i]== -1) continue;
for(int j = i + 1; j < 1010; j++){
if(b[j] == -1 || x[j] == -1 || y[j] == -1) continue;
dx = x[i]-x[j];
dy = y[i]-y[j];
if(dx*dx+dy*dy>2500)continue;
edge[b[i]].push_back(Edge(b[j], dx*dx+dy*dy));
edge[b[j]].push_back(Edge(b[i], dx*dx+dy*dy));
}
}
//cout<<edge[1][0].t<<" "<<edge[1][0].c<<endl;
//cout<<edge[2][0].t<<" "<<edge[2][0].c<<endl;
cin>>m;
rep(i, m){
int s, g;
cin>>s>>g;
//cout<<s<<" "<<g<<endl;
dijkstra(s);
if(d[g].fi==INF) {
cout<<"NA"<<endl;
continue;
}
ans.clear();
//bool usedG[1010]={};
while(1){
ans.pb(g);
if(g == s /*|| g == -1*/) break;
//usedG[g] = true;
g = d[g].se;
//if(usedG[g]) break;
//cout<<" "<<g<<endl;
}
//while(ans.size()> 0 && ans.back()==-1) ans.pop_back();
reverse(all(ans));
rep(j, ans.size()){
if(j != 0) cout<<" ";
cout<<ans[j];
}
cout<<endl;
}
}
} | a.cc: In function 'void dijkstra(int)':
a.cc:78:27: error: no match for 'operator<' (operand types are 'std::pair<int, int>' and 'int')
78 | if(d[from]<p.fi) continue;
| ~~~~~~~^
| |
| std::pair<int, int>
In file included from /usr/include/c++/14/string:48,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: 'std::pair<int, int>' is not derived from 'const std::reverse_iterator<_Iterator>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: 'std::pair<int, int>' is not derived from 'const std::reverse_iterator<_Iterator>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: 'std::pair<int, int>' is not derived from 'const std::move_iterator<_IteratorL>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: 'std::pair<int, int>' is not derived from 'const std::move_iterator<_IteratorL>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: mismatched types 'const std::pair<_T1, _T2>' and 'int'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: 'std::pair<int, int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: 'std::pair<int, int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: 'std::pair<int, int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: 'std::pair<int, int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3901 | operator<(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: mismatched types 'const _CharT*' and 'std::pair<int, int>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2600:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2600 | operator<(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2600:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: 'std::pair<int, int>' is not derived from 'const std::tuple<_UTypes ...>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
In file included from /usr/include/c++/14/vector:66,
from a.cc:6:
/usr/include/c++/14/bits/stl_vector.h:2089:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)'
2089 | operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:2089:5: note: template argument deduction/substitution failed:
a.cc:26:12: note: 'std::pair<int, int>' is not derived from 'const std::vector<_Tp, _Alloc>'
26 | #define fi first
| ^~~~~
a.cc:78:30: note: in expansion of macro 'fi'
78 | if(d[from]<p.fi) continue;
| ^~
In file included from /usr/include/c++/14/deque:66,
from /usr/include/c++/14/stack:62,
from a.cc:8:
/usr/include/c++/14/bits/stl_deque.h:2334:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const deque<_Tp, _Alloc>&, const d |
s891629964 | p00155 | C++ | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
struct Point : IComparable
{
internal int to;
internal double dist;
public Point(int to, double dist)
{
this.to = to;
this.dist = dist;
}
public int CompareTo(object obj)
{
Point other = (Point)obj;
if (other.dist - dist > 0) return 1; // rev
if (other.dist == dist) return 0;
return -1;
}
}
struct State
{
internal double dist;
internal string path;
}
class Problem
{
readonly int INF = 1 << 20;
readonly int n;
Dictionary<int, List<Point>> adj;
State[][] memo;
bool[] flg;
public Problem(int n)
{
this.n = n;
adj = new Dictionary<int, List<Point>>();
memo = new State[n + 1][];
flg = new bool[n + 1];
}
public void MakeMap()
{
var points = new Dictionary<int, KeyValuePair<int, int>>();
for (int i = 0; i < n; i++)
{
string[] input = Console.ReadLine().Split(' ');
int id = int.Parse(input[0]);
int x = int.Parse(input[1]);
int y = int.Parse(input[2]);
points.Add(id, new KeyValuePair<int, int>(x, y));
adj.Add(id, new List<Point>());
}
for (int i = 1; i <= n; i++)
{
for (int j = i + 1; j <= n; j++)
{
int dx = points[i].Key - points[j].Key;
int dy = points[i].Value - points[j].Value;
double dist = Math.Sqrt(dx * dx + dy * dy);
if (dist > 50) continue;
adj[i].Add(new Point(j, dist));
adj[j].Add(new Point(i, dist));
}
}
}
public string GetPath(int s, int t)
{
if (!flg[s])
{
Dijkstra(s);
flg[s] = true;
}
return memo[s][t].path == "" ? "NA" : memo[s][t].path;
}
private void Dijkstra(int s)
{
bool[] visited = new bool[n + 1];
State temp;
temp.dist = INF;
temp.path = "";
var d = Enumerable.Repeat(temp, n + 1).ToArray();
d[s].dist = 0;
d[s].path = s.ToString();
PriorityQueue<Point> PQ = new PriorityQueue<Point>();
PQ.Enqueue(new Point(s, 0));
while (PQ.Count > 0)
{
Point f = PQ.Dequeue();
int u = f.to;
visited[u] = true;
if (d[u].dist < f.dist) continue;
for (int i = 0; i < adj[u].Count; i++)
{
int v = adj[u][i].to;
if (visited[v]) continue;
double sumDist = d[u].dist + adj[u][i].dist;
if (d[v].dist > sumDist)
{
d[v].dist = sumDist;
d[v].path = d[u].path + " " + v;
PQ.Enqueue(new Point(v, d[v].dist));
}
}
}
memo[s] = (State[])d.Clone();
}
}
class Program
{
static void Main(string[] args)
{
StringBuilder sb = new StringBuilder();
while (true)
{
int n = int.Parse(Console.ReadLine());
if (n == 0) break;
Problem pb = new Problem(n);
pb.MakeMap();
int m = int.Parse(Console.ReadLine());
while (m-- > 0)
{
string[] input = Console.ReadLine().Split(' ');
int s = int.Parse(input[0]);
int t = int.Parse(input[1]);
sb.AppendLine(pb.GetPath(s, t));
}
}
Console.Write(sb);
}
}
class PriorityQueue<T> where T : IComparable
{
List<T> heap;
int size;
public PriorityQueue()
{
heap = new List<T>();
}
public int Count { get { return size; } }
public void Enqueue(T x)
{
heap.Add(x);
int i = size++;
while (i > 0)
{
int p = (i - 1) / 2;
if (Compare(heap[p], x) <= 0) break;
heap[i] = heap[p];
i = p;
}
heap[i] = x;
}
public T Dequeue()
{
T ret = heap[0];
T x = heap[--size];
int i = 0;
while (i * 2 + 1 < size)
{
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < size && Compare(heap[b], heap[a]) < 0)
a = b;
if (Compare(heap[a], x) >= 0)
break;
heap[i] = heap[a];
i = a;
}
heap[i] = x;
heap.RemoveAt(size);
return ret;
}
private int Compare(T x, T y)
{
return y.CompareTo(x);
}
}
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
2 | using System.Collections.Generic;
| ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
3 | using System.Linq;
| ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
4 | using System.Text;
| ^~~~~~
a.cc:9:5: error: expected class-name before '{' token
9 | {
| ^
a.cc:10:9: error: 'internal' does not name a type
10 | internal int to;
| ^~~~~~~~
a.cc:11:9: error: 'internal' does not name a type
11 | internal double dist;
| ^~~~~~~~
a.cc:13:15: error: expected ':' before 'Point'
13 | public Point(int to, double dist)
| ^~~~~~
| :
a.cc:19:15: error: expected ':' before 'int'
19 | public int CompareTo(object obj)
| ^~~~
| :
a.cc:19:30: error: 'object' has not been declared
19 | public int CompareTo(object obj)
| ^~~~~~
a.cc:27:6: error: expected ';' after struct definition
27 | }
| ^
| ;
a.cc: In constructor 'ConsoleApplication1::Point::Point(int, double)':
a.cc:15:18: error: request for member 'to' in '(ConsoleApplication1::Point*)this', which is of pointer type 'ConsoleApplication1::Point*' (maybe you meant to use '->' ?)
15 | this.to = to;
| ^~
a.cc:16:18: error: request for member 'dist' in '(ConsoleApplication1::Point*)this', which is of pointer type 'ConsoleApplication1::Point*' (maybe you meant to use '->' ?)
16 | this.dist = dist;
| ^~~~
a.cc: In member function 'int ConsoleApplication1::Point::CompareTo(int)':
a.cc:21:34: error: no matching function for call to 'ConsoleApplication1::Point::Point(int&)'
21 | Point other = (Point)obj;
| ^~~
a.cc:13:16: note: candidate: 'ConsoleApplication1::Point::Point(int, double)'
13 | public Point(int to, double dist)
| ^~~~~
a.cc:13:16: note: candidate expects 2 arguments, 1 provided
a.cc:8:12: note: candidate: 'constexpr ConsoleApplication1::Point::Point(const ConsoleApplication1::Point&)'
8 | struct Point : IComparable
| ^~~~~
a.cc:8:12: note: no known conversion for argument 1 from 'int' to 'const ConsoleApplication1::Point&'
a.cc:8:12: note: candidate: 'constexpr ConsoleApplication1::Point::Point(ConsoleApplication1::Point&&)'
a.cc:8:12: note: no known conversion for argument 1 from 'int' to 'ConsoleApplication1::Point&&'
a.cc:23:23: error: 'struct ConsoleApplication1::Point' has no member named 'dist'
23 | if (other.dist - dist > 0) return 1; // rev
| ^~~~
a.cc:23:30: error: 'dist' was not declared in this scope
23 | if (other.dist - dist > 0) return 1; // rev
| ^~~~
a.cc:24:23: error: 'struct ConsoleApplication1::Point' has no member named 'dist'
24 | if (other.dist == dist) return 0;
| ^~~~
a.cc:24:31: error: 'dist' was not declared in this scope
24 | if (other.dist == dist) return 0;
| ^~~~
a.cc: At global scope:
a.cc:31:9: error: 'internal' does not name a type
31 | internal double dist;
| ^~~~~~~~
a.cc:32:9: error: 'internal' does not name a type
32 | internal string path;
| ^~~~~~~~
a.cc:33:6: error: expected ';' after struct definition
33 | }
| ^
| ;
a.cc:37:9: error: 'readonly' does not name a type
37 | readonly int INF = 1 << 20;
| ^~~~~~~~
a.cc:38:9: error: 'readonly' does not name a type
38 | readonly int n;
| ^~~~~~~~
a.cc:40:9: error: 'Dictionary' does not name a type
40 | Dictionary<int, List<Point>> adj;
| ^~~~~~~~~~
a.cc:41:14: error: expected unqualified-id before '[' token
41 | State[][] memo;
| ^
a.cc:42:13: error: expected unqualified-id before '[' token
42 | bool[] flg;
| ^
a.cc:44:15: error: expected ':' before 'Problem'
44 | public Problem(int n)
| ^~~~~~~~
| :
a.cc:52:15: error: expected ':' before 'void'
52 | public void MakeMap()
| ^~~~~
| :
a.cc:83:15: error: expected ':' before 'string'
83 | public string GetPath(int s, int t)
| ^~~~~~~
| :
a.cc:83:16: error: 'string' does not name a type
83 | public string GetPath(int s, int t)
| ^~~~~~
a.cc:94:16: error: expected ':' before 'void'
94 | private void Dijkstra(int s)
| ^~~~~
| :
a.cc:136:6: error: expected ';' after class definition
136 | }
| ^
| ;
a.cc: In constructor 'ConsoleApplication1::Problem::Problem(int)':
a.cc:46:18: error: request for member 'n' in '(ConsoleApplication1::Problem*)this', which is of pointer type 'ConsoleApplication1::Problem*' (maybe you meant to use '->' ?)
46 | this.n = n;
| ^
a.cc:47:13: error: 'adj' was not declared in this scope
47 | adj = new Dictionary<int, List<Point>>();
| ^~~
a.cc:47:23: error: 'Dictionary' does not name a type
47 | adj = new Dictionary<int, List<Point>>();
| ^~~~~~~~~~
a.cc:47:34: error: expected primary-expression before 'int'
47 | adj = new Dictionary<int, List<Point>>();
| ^~~
a.cc:48:13: error: 'memo' was not declared in this scope
48 | memo = new State[n + 1][];
| ^~~~
a.cc:48:37: error: expected primary-expression before ']' token
48 | memo = new State[n + 1][];
| ^
a.cc:49:13: error: 'flg' was not declared in this scope
49 | flg = new bool[n + 1];
| ^~~
a.cc: In member function 'void ConsoleApplication1::Problem::MakeMap()':
a.cc:54:13: error: 'var' was not declared in this scope
54 | var points = new Dictionary<int, KeyValuePair<int, int>>();
| ^~~
a.cc:56:33: error: 'n' was not declared in this scope
56 | for (int i = 0; i < n; i++)
| ^
a.cc:58:17: error: 'string' was not declared in this scope
58 | string[] input = Console.ReadLine().Split(' ');
| ^~~~~~
a.cc:58:24: error: expected primary-expression before ']' token
58 | string[] input = Console.ReadLine().Split(' ');
| ^
a.cc:59:26: error: expected primary-expression before 'int'
59 | int id = int.Parse(input[0]);
| ^~~
a.cc:60:25: error: expected primary-expression before 'int'
60 | int x = int.Parse(input[1]);
| ^~~
a.cc:61:25: error: expected primary-expression before 'int'
61 | int y = int.Parse(input[2]);
| ^~~
a.cc:63:17: error: 'points' was not declared in this scope; did you mean 'Point'?
63 | points.Add(id, new KeyValuePair<int, int>(x, y));
| ^~~~~~
| Point
a.cc:63:36: error: 'KeyValuePair' does not name a type
63 | points.Add(id, new KeyValuePair<int, int>(x, y));
| ^~~~~~~~~~~~
a.cc:63:49: error: expected primary-expression before 'int'
63 | points.Add(id, new KeyValuePair<int, int>(x, y));
| ^~~
a.cc:63:54: error: expected primary-expression before 'int'
63 | points.Add(id, new KeyValuePair<int, int>(x, y));
| ^~~
a.cc:64:17: error: 'adj' was not declared in this scope
64 | adj.Add(id, new List<Point>());
| ^~~
a.cc:64:33: error: 'List' does not name a type
64 | adj.Add(id, new List<Point>());
| ^~~~
a.cc:64:43: error: expected primary-expression before '>' token
64 | adj.Add(id, new List<Point>());
| ^
a.cc:64:45: error: expected primary-expression before ')' token
64 | adj.Add(id, new List<Point>());
| ^
a.cc:67:34: error: 'n' was not declared in this scope
67 | for (int i = 1; i <= n; i++)
| ^
a.cc:71:30: error: 'points' was not declared in this scope; did you mean 'Point'?
71 | int dx = points[i].Key - points[j].Key;
| ^~~~~~
| Point
a.cc:73:35: error: 'Math' was not declared in this scope
73 | double dist = Math.Sqrt(dx * dx + dy * dy);
| ^~~~
a.cc:77:21: error: 'adj' was not declared in this scope
77 | adj[i].Add(new Point(j, dist));
| ^~~
a.cc: In member function 'void ConsoleApplication1::Problem::Dijkstra(int)':
a.cc:96:17: error: structured binding declaration cannot have type 'bool'
96 | bool[] visited = new bool[n + 1];
| ^~
a.cc:96:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:96:17: error: empty structured binding declaration
a.cc:96:20: error: expected initializer before 'visited'
96 | bool[] visited = new bool[n + 1];
| ^~~~~~~
a.cc:99:18: error: 'struct ConsoleApplicatio |
s319338920 | p00155 | C++ | #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
#define int ll
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
int f(int x,int y){return(x*x+y*y);}
signed main(){
int n;
while(cin>>n,n){
map<int, pii>mp;
rep(i,n){
int hoge; pii foo; cin>>hoge>>foo.first>>foo.second;
mp[hoge]=foo;
}
vector<vector<pii>>edge(n,vector<pii>());
for(auto itr=mp.begin();itr!=mp.end();itr++){
for(auto comp=mp.begin();comp!=mp.end();comp++){
if(itr==comp)continue;
int dis=f(abs(itr->second.first-comp->second.first),abs(itr->second.second-comp->second.second));
if( dis<=2500){
//cout<<itr->first<<" "<<comp->first<<endl;
edge[itr->first-1].push_back(pii(comp->first-1,1));
}
}
}
int k; cin>>k;
rep(_,k){
int s,g; cin>>s>>g;
--s,--g;
priority_queue<pii,vector<pii>,greater<pii>>que;
vector<int>prev(n,INF);
vector<int>d(n,INF);
d[s]=0;
que.push(pii(0,s));
while(!que.empty()){
pii now=que.top(); que.pop();
if(now.second==g)break;
if(d[now.second]<now.first)continue;
rep(i,edge[now.second].size(a)){
pii next=edge[now.second][i];
if(d[next.first]<d[now.second]+next.second)continue;
que.push(pii(d[now.second]+next.second,next.first));
d[next.first]=now.first+next.second;
prev[next.first]=now.second;
}
}
if(edge[s].size()==0 ||edge[g].size()==0||d[g]==INF)cout<<"NA"<<endl;
else {
vi hoge;
for(int v=g;; v=prev[v]){
hoge.push_back(v);
if(v==s)break;
}
reverse(all(hoge));
rep(i,hoge.size())if(i)cout<<" "<<hoge[i]+1; else cout<<hoge[i]+1;
cout<<endl;
}
}
}
} | a.cc: In function 'int main()':
a.cc:77:45: error: 'a' was not declared in this scope
77 | rep(i,edge[now.second].size(a)){
| ^
a.cc:34:32: note: in definition of macro 'rep'
34 | #define rep(i,n) for(int i=0;i<n;i++)
| ^
|
s785733595 | p00155 | C++ |
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int N=1001;
//near equal?
int F(double x,double y){return fabs(x-y)<1e-9;}
//IÉÜÜêévÌCfbNX
int G(const vector<int>&I,int v){return find(I.begin(),I.end(),v)-I.begin()+1;}
int main()
{
int n,m,i,j,b,x,y,s,g,X[N],Y[N];
static double D[N][N],V=1e10,t;
while(scanf("%d",&n),n)
{
vector<int>I; //rÌÔÌW
for(i=0;i<n;++i)scanf("%d%d%d",&b,&x,&y),I.push_back(b),X[I.size()]=x,Y[I.size()]=y;
for(i=1;i<=n;++i)for(j=1;j<=n;++j)D[i][j]=D[j][i]=hypot(X[i]-X[j],Y[i]-Y[j]);
for(scanf("%d",&m);m--;)
{
scanf("%d%d",&s,&g);
typedef pair<double,int>P; //-ÅZ£AtoIndex ©firstÉ-¯ÄéÌYêÈ¢ÅËIftHÌless()ÅåävÈæ¤ÉI
P p;
priority_queue<P>q;
double d[N]; //»ÌrÔÜÅÌÅZ£
fill(d,d+N,V);
//_CNXgÅÅZoHÌZo
q.push(P(0,G(I,s)));
d[G(I,s)]=0;
while(!q.empty())
{
p=q.top();q.pop();
for(i=1;i<=n;++i)
if(t=D[p.second][i],t<=50&&d[p.second]+t<d[i])
d[i]=d[p.second]+t,q.push(P(p.first-t,i));
}
if(d[G(I,g)]==V)puts("NA");
else
{
//S[©çÔÉAÚ±³êÄ¢éÓðgÁÄ¢éàÌð½ÇÁÄ¢
//tÉÇÁµÄ¾ÁÄ¢éÌÅAoÍàtÉ
//©ª©gÉ}ÂȰ¿á¾ßæÆ
vector<int>v(1,G(I,g));
for(i=G(I,g);i-G(I,s);v.push_back(i=j))for(j=1;j<=n;++j)
if(i-j&&F(d[i],D[i][j]+d[j]))break;
for(i=v.size()-1;i>=0;--i)printf("%d%c",I[v[i]-1],i?' ':'\n');
}
}
}
return 0;
} | a.cc: In function 'int G(const std::vector<int>&, int)':
a.cc:12:41: error: 'find' was not declared in this scope
12 | int G(const vector<int>&I,int v){return find(I.begin(),I.end(),v)-I.begin()+1;}
| ^~~~
|
s094018449 | p00155 | C++ | #include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <ctime>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef pair<double, int> state;
double memo[100];
int pre[100];
int name[100];
double x[100];
double y[100];
map<int, int> nums;
double dis(int i, int j){
return sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
}
int main(){
int n, m;
int b;
int s, g;
while(cin >> n &&n){
nums.clear();
rep(i, n){
cin >> b >> x[i] >> y[i];
name[i] = b;
nums[b] = i;
}
cin >> m;
rep(i, m){
memset(pre, -1, sizeof(pre));
fill(memo, memo + 100, 1e10);
cin >> s >> g;
memo[nums[s]] = 0;
priority_queue<state, vector<state>, greater<state> > que;
que.push(state(0, nums[s]));
while(!que.empty()){
state st = que.top();
que.pop();
int v = st.second;
double cost = st.first;
if(name[v] == g){
break;
}
if(cost > memo[v]) continue;
rep(i, n){
double d = dis(v, i);
if(d > 50.0) continue;
if(memo[i] > memo[v] + d){
memo[i] = memo[v] + d;
pre[i] = v;
que.push(state(memo[i], i));
}
}
}
if(pre[nums[g]] == -1 && s != g){
cout << "NA" << endl;
}else{
vector<int> res;
int v = nums[g];
res.push_back(v);
while(pre[v] >= 0){
v = pre[v];
res.push_back(v);
}
rep(i, (int)res.size()){
if(i != 0) cout << " " ;
cout << name[res[res.size() - 1 - i]];
}
cout << endl;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:39:7: error: 'memset' was not declared in this scope
39 | memset(pre, -1, sizeof(pre));
| ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
8 | #include <ctime>
+++ |+#include <cstring>
9 | using namespace std;
|
s949743442 | p00155 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#include <cstring>
#include <climits>
#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
using namespace std;
int n, x[1001], y[1001], m, s[1001], g[1001];
float amt[1001][1001], vtx[1001];
int pre[1001];
queue<int> que;
stack<int> out;
int main()
{
while( cin >> n, n)
{
CLR(amt);
FOR(i, 0, n)
{
int b;
cin >> b >> x[i] >> y[i];
}
cin >> m;
FOR(i, 0, m)
{
cin >> s[i] >> g[i];
s[i]--;
g[i]--;
}
FOR(j, 0, n)
FOR(i, j, n)
{
if( i != j )
{
double dis = sqrt( pow((float)(x[i] - x[j]), 2) + pow((float)(y[i] - y[j]), 2) );
if(dis <= 50.0)
{
amt[j][i] = dis;
amt[i][j] = dis;
}
}
}
FOR(k, 0, m)
{
que.push(s[k]);
FOR(i, 0, n)
{
vtx[i] = INT_MAX;
}
vtx[s[k]] = 0;
while(!que.empty())
{
int now = que.front();
que.pop();
FOR(tg, 0, n)
{
if( amt[now][tg] > 0 && now != tg && vtx[now] + amt[now][tg] < vtx[tg] )
{
vtx[tg] = vtx[now] + amt[now][tg];
pre[tg] = now;
que.push(tg);
}
}
}
if( vtx[g[k]] >= INT_MAX )
{
cout << "NA" <<endl;
}
else
{
int now = g[k];
while( now != s[k] )
{
out.push(pre[now]);
now = pre[now];
}
while( !out.empty() )
{
cout << out.top()+1 << " ";
out.pop();
}
cout << g[k]+1 << endl;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:52:61: error: 'pow' was not declared in this scope
52 | double dis = sqrt( pow((float)(x[i] - x[j]), 2) + pow((float)(y[i] - y[j]), 2) );
| ^~~
a.cc:52:55: error: 'sqrt' was not declared in this scope
52 | double dis = sqrt( pow((float)(x[i] - x[j]), 2) + pow((float)(y[i] - y[j]), 2) );
| ^~~~
|
s638157455 | p00155 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
using namespace std;
int n, x[1001], y[1001], m, s[1001], g[1001], pre[1001];
double amt[1001][1001], vtx[1001];
queue<int> que;
stack<int> out;
int main()
{
while( cin >> n, n)
{
CLR(amt);
FOR(i, 0, n)
{
int b;
cin >> b >> x[i] >> y[i];
}
cin >> m;
FOR(i, 0, m)
{
cin >> s[i] >> g[i];
s[i]--;g[i]--;
}
FOR(j, 0, n)
FOR(i, j, n)
{
if( i != j )
{
double dis = sqrt( pow((double)(x[i] - x[j]), 2) + pow((double)(y[i] - y[j]), 2) );
if(dis <= 50.0)
{
amt[j][i] = dis;
amt[i][j] = dis;
}
}
}
FOR(k, 0, m)
{
que.push(s[k]);
FOR(i, 0, n)
{
vtx[i] = DBL_MAX;
}
vtx[s[k]] = 0;
while(!que.empty())
{
int now = que.front();
que.pop();
FOR(tg, 0, n)
{
if( amt[now][tg] > 0 && now != tg && vtx[now] + amt[now][tg] < vtx[tg] )
{
vtx[tg] = vtx[now] + amt[now][tg];
pre[tg] = now;
que.push(tg);
}
}
}
if( vtx[g[k]] == DBL_MAX )
{
cout << "NA" <<endl;
}
else
{
int now = g[k];
while( now != s[k] )
{
out.push(pre[now]);
now = pre[now];
}
while( !out.empty() )
{
cout << out.top()+1 << " ";
out.pop();
}
cout << g[k]+1 << endl;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:63:42: error: 'DBL_MAX' was not declared in this scope
63 | vtx[i] = DBL_MAX;
| ^~~~~~~
a.cc:10:1: note: 'DBL_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>'
9 | #include <cmath>
+++ |+#include <cfloat>
10 |
a.cc:85:42: error: 'DBL_MAX' was not declared in this scope
85 | if( vtx[g[k]] == DBL_MAX )
| ^~~~~~~
a.cc:85:42: note: 'DBL_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>'
|
s253948065 | p00155 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <cassert>
using namespace std;
const int MAX_V = 1001;
const int INF = INT_MAX;
struct Edge {
int to;
int cost;
};
int V;
vector<Edge> G[MAX_V];
int d[MAX_V];
int prev[MAX_V];
void dijkstra(int s) {
typedef pair<int, int> P;
priority_queue<P, vector<P>, greater<P> > que;
fill(d, d + V, INF);
fill(prev, prev + V, -1);
d[s] = 0;
que.push(P(0, s));
while (!que.empty()) {
P p = que.top(); que.pop();
int v = p.second;
if (d[v] < p.first)
continue;
for (int i = 0; i < (int)G[v].size(); i++) {
Edge e = G[v][i];
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
prev[e.to] = v;
que.push(P(d[e.to], e.to));
}
}
}
}
vector<int> get_path(int t) {
vector<int> path;
for (; t != -1; t = prev[t]) {
path.push_back(t);
}
reverse(path.begin(), path.end());
return path;
}
struct Building {
int x;
int y;
};
int distance2(Building *b1, Building *b2) {
int dx = b1->x - b2->x;
int dy = b1->y - b2->y;
return dx * dx + dy * dy;
}
int name[MAX_V];
int rname[MAX_V];
Building building[MAX_V];
int main() {
while (true) {
int n;
cin >> n;
if (n == 0)
break;
V = n;
for (int i = 0; i < n; i++) {
G[i].clear();
}
for (int i = 0; i < n; i++) {
int b;
cin >> b;
name[i] = b;
rname[b] = i;
cin >> building[i].x >> building[i].y;
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
Building *b1 = building + i;
Building *b2 = building + j;
int d2 = distance2(b1, b2);
if (d2 <= 50 * 50) {
int d1 = sqrt(d2);
Edge e1 = {j, d1};
G[i].push_back(e1);
Edge e2 = {i, d1};
G[j].push_back(e2);
}
}
}
int m;
cin >> m;
for (int i = 0; i < m; i++) {
int s;
int g;
cin >> s >> g;
dijkstra(rname[s]);
if (d[rname[g]] == INF) {
cout << "NA" << endl;
} else {
vector<int> path = get_path(rname[g]);
for (int j = 0; j < (int)path.size(); j++) {
cout << name[path[j]];
if (j < (int)path.size() - 1)
cout << " ";
}
cout << endl;
}
}
}
return 0;
} | a.cc:16:19: error: 'INT_MAX' was not declared in this scope
16 | const int INF = INT_MAX;
| ^~~~~~~
a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
11 | #include <cassert>
+++ |+#include <climits>
12 |
a.cc: In function 'void dijkstra(int)':
a.cc:32:8: error: reference to 'prev' is ambiguous
32 | fill(prev, prev + V, -1);
| ^~~~
In file included from /usr/include/c++/14/string:47,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:26:14: note: 'int prev [1001]'
26 | int prev[MAX_V];
| ^~~~
a.cc:32:14: error: reference to 'prev' is ambiguous
32 | fill(prev, prev + V, -1);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:26:14: note: 'int prev [1001]'
26 | int prev[MAX_V];
| ^~~~
a.cc:45:9: error: reference to 'prev' is ambiguous
45 | prev[e.to] = v;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:26:14: note: 'int prev [1001]'
26 | int prev[MAX_V];
| ^~~~
a.cc: In function 'std::vector<int> get_path(int)':
a.cc:55:23: error: reference to 'prev' is ambiguous
55 | for (; t != -1; t = prev[t]) {
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:26:14: note: 'int prev [1001]'
26 | int prev[MAX_V];
| ^~~~
|
s401285691 | p00155 | C++ | #include <iostrerm>
#include <memory>
using namespace std;
int x[1001], y[1001];
bool v[1001];
int p[1001];
int d[1001];
int edge[1001][1001];
int INF = (1 << 20);
void compute(int i, int j) {
int temp = (x[i] - x[j]) * (x[i] - x[j]) - (y[i] - y[j]) * (y[i] - y[j]);
if (temp <= 2500) edge[i][j] = temp;
}
void dijkstra(int s, int g, int n) {
int mn,hozon,b;
int a[1001];
// init
memset(v, false, sizeof(v));
memset(p, 0, sizeof(p));
memset(d, INF, sizeof(d));
d[s] = 0;
for(;;) {
mn = INF;
//tmp=hozon;
for(int i = 1; i <= n; i++) {
if(mn > d[i] && !v[j]) {
mn = d[i];
hozon = i;
}
}
//via[hozon]=tmp;
if(mn == INF) break;
v[hozon] = true;
for(int j = 1; j <= n; j++) {
if(d[j] > d[hozon] + map[hozon][j]) {
d[j] = map[hozon][j] + d[hozon];
p[j] = hozon;
}
}
}
if(d[g] == INF) {
cout << "NA" << endl;
} else {
b = p[g];
while(1){
if (b == s) break;
a[cnt++] = b;
b = p[b];
}
for(int i = cnt - 1; i >= 1; i--) {
cout << a[i] << " ";
}
cout << a[0];
}
}
int main (void) {
int s, g;
int n;
while(1) {
cin >> n; if (n == 0) break;
for(int i = 1; i <= n; i++) {
cin >> b;
cin >> x[b] >> y[b];
}
for(int i = 1; i <= 1001; i++) {
for(int j = 1; j <= 1001; j++) {
edge[i][j] = INF;
if(i != j) compute(i, j);
}
}
cin >> m;
for(int i = 1; i <= m; i++) {
dijkstra(s, j, n);
}
}
return 0;
} | a.cc:1:10: fatal error: iostrerm: No such file or directory
1 | #include <iostrerm>
| ^~~~~~~~~~
compilation terminated.
|
s129477783 | p00155 | C++ | #include <map>
using namespace std;
multimap<double,int> mp;
struct bir {
double x,y,m;
int to[1001],fr;
};
bir b[1000];
multimap<double,int>::iterator it;
int search(int s,int e) {
int n,i;
double m,k;
b[s].m=0; b[s].fr=-1;
mp.insert(multimap<double,int>::value_type(0,s));
while(!mp.empty()) {
it=mp.begin();
n=(*it).second; m=(*it).first;
mp.erase(it);
for (i=0;b[n].to[i]>=0;i++) {
k=sqrt((b[n].x-b[b[n].to[i]].x)*(b[n].x-b[b[n].to[i]].x)+(b[n].y-b[b[n].to[i]].y)*(b[n].y-b[b[n].to[i]].y));
if (b[b[n].to[i]].m>b[n].m+k) {
mp.insert(multimap<double,int>::value_type(b[n].m+k,b[n].to[i]));
b[b[n].to[i]].fr=n; b[b[n].to[i]].m=b[n].m+k;
}
}
}
if (b[e].m==999999999) return 0;
return 1;
}
int main() {
int bn,g,i,j,k,n,s,e,an[1000],num[1000],rn[1000];
while(cin >> bn) {
if (bn==0) break;
for (i=0;i<bn;i++) { cin >> num[i] >> b[i].x >> b[i].y; rn[num[i]]=i;}
for (i=0;i<bn;i++) {
for (j=0,k=0;j<bn;j++) if (i!=j) if ((b[i].x-b[j].x)*(b[i].x-b[j].x)+(b[i].y-b[j].y)*(b[i].y-b[j].y)<=2500) b[i].to[k++]=j;
b[i].to[k]=-1; b[i].m=999999999;
}
cin >> n;
for (i=0;i<n;i++) {
cin >> s >> e;
s=rn[s]; e=rn[e];
if (search(s,e)==1) {
j=0;
while(e>=0) {an[j++]=num[e]; e=b[e].fr;}
for (;j>0;j--) { cout << an[j-1]; if (j>1) cout << ' ';}
cout << endl;
} else cout << "NA" << endl;
}
}
return 0;
} | a.cc: In function 'int search(int, int)':
a.cc:26:27: error: 'sqrt' was not declared in this scope
26 | k=sqrt((b[n].x-b[b[n].to[i]].x)*(b[n].x-b[b[n].to[i]].x)+(b[n].y-b[b[n].to[i]].y)*(b[n].y-b[b[n].to[i]].y));
| ^~~~
a.cc: In function 'int main()':
a.cc:39:8: error: 'cin' was not declared in this scope
39 | while(cin >> bn) {
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include <map>
+++ |+#include <iostream>
2 |
a.cc:53:43: error: 'cout' was not declared in this scope
53 | for (;j>0;j--) { cout << an[j-1]; if (j>1) cout << ' ';}
| ^~~~
a.cc:53:43: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:54:26: error: 'cout' was not declared in this scope
54 | cout << endl;
| ^~~~
a.cc:54:26: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:54:34: error: 'endl' was not declared in this scope
54 | cout << endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include <map>
+++ |+#include <ostream>
2 |
a.cc:55:25: error: 'cout' was not declared in this scope
55 | } else cout << "NA" << endl;
| ^~~~
a.cc:55:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:55:41: error: 'endl' was not declared in this scope
55 | } else cout << "NA" << endl;
| ^~~~
a.cc:55:41: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
|
s662955058 | p00156 | Java |
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Map.Entry;
public class Sample {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
int n = scanner.nextInt();
if (n == 0)
break;
Map<Integer, Integer> memo = new HashMap<Integer, Integer>();
memo.put(0, 1);
for (int i = 0; i < n; i++) {
int a = scanner.nextInt();
int b = scanner.nextInt();
Map<Integer, Integer> tmp = new HashMap<Integer, Integer>();
tmp.putAll(memo);
for (Entry<Integer, Integer> entry : memo.entrySet()) {
for (int j = 1; j <= b; j++) {
int c = entry.getKey() + a * j;
if (c > 1000) {
continue;
}
int d = entry.getValue();
if (tmp.containsKey(c)) {
tmp.put(c, d + tmp.get(c));
} else {
tmp.put(c, d);
}
}
}
memo = tmp;
}
int s = scanner.nextInt();
while (s-- > 0) {
int m = scanner.nextInt();
if (!memo.containsKey(m)) {
System.out.println(0);
} else {
System.out.println(memo.get(m));
}
}
}
}
} | Main.java:7: error: class Sample is public, should be declared in a file named Sample.java
public class Sample {
^
1 error
|
s670649645 | p00156 | C | tdio.h> // printf(), fprintf(), scanf()
#include <stdlib.h> // exit()
#include <stdbool.h>
#define SZ_FIELD 100
#define QUE_SIZE 10000
typedef struct que_tbl
{
int x;
int y;
} que_t;
int N, M;
char field[SZ_FIELD][SZ_FIELD + 1];
que_t queue[QUE_SIZE];
int que_in;
int que_out;
void
cleanup(int ecode)
{
exit(ecode);
}
int
que_empty()
{
return que_in == que_out;
}
void
que_push(que_t *que)
{
queue[que_in].x = que->x;
queue[que_in].y = que->y;
que_in = (que_in + 1) % QUE_SIZE;
if (que_in == que_out)
{
fprintf(stderr, "Queue overflow. size:%d\n", QUE_SIZE);
cleanup(1);
}
}
void
que_pop()
{
if (que_out == que_in)
{
fprintf(stderr, "Queue underflow\n");
cleanup(1);
}
que_out = (que_out + 1) % QUE_SIZE;
}
void
que_front(que_t *que)
{
que->x = queue[que_out].x;
que->y = queue[que_out].y;
}
void
dfs(int x, int y)
{
field[y][x] = '.';
for (int dy = -1; dy <= 1; ++dy)
{
for (int dx = -1; dx <= 1; ++dx)
{
int nx = x + dx, ny = y + dy;
if (0 <= nx && nx < N && 0 <= ny && ny < M && field[ny][nx] == '#')
dfs(nx, ny);
}
}
}
bool
bfs(int *cx, int *cy)
{
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = { 0,-1, 0, 1};
int mx = 0, my = 0;
que_t que;
que_in = 0;
que_out = 0;
que.x = *cx, que.y = *cy;
que_push(&que);
while (!que_empty())
{
que_front(&que); que_pop();
int x = que.x, y = que.y;
if (x == 0 || x == N - 1 || y == 0 || y == M - 1)
return true;
for (int i = 0; i < 4; ++i)
{
int nx = x + dx[i], ny = y + dy[i];
if (0 <= nx && nx < N && 0 <= ny && ny < M)
{
if (field[ny][nx] == '.')
{
field[ny][nx] = ' ';
que.x = nx, que.y = ny;
que_push(&que);
}
else if (field[ny][nx] == '#')
{
if (nx > mx || ny > my)
mx = nx, my = ny;
}
}
}
}
*cx = mx, *cy = my;
return false;
}
int
solve()
{
int cx, cy;
for (cy = 0; cy < M; ++cy)
{
for (cx = 0; cx < N; ++cx)
{
if (field[cy][cx] == '&')
break;
}
if (cx < N)
break;
}
field[cy][cx] = ' ';
int count = 0;
while (!bfs(&cx, &cy))
{
dfs(cx, cy);
count++;
}
return count;
}
int
main(int argc, char **argv)
{
while (true)
{
scanf("%d%d", &N, &M);
if (N == 0 && M == 0)
break;
for (int i = 0; i < M; ++i)
scanf("%s", &field[i][0]);
printf("%d\n", solve());
}
return 0;
}
| main.c:1:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
1 | tdio.h> // printf(), fprintf(), scanf()
| ^
In file included from main.c:2:
/usr/include/stdlib.h:98:8: error: unknown type name 'size_t'
98 | extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
| ^~~~~~
/usr/include/stdlib.h:57:1: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
56 | #include <bits/floatn.h>
+++ |+#include <stddef.h>
57 |
/usr/include/stdlib.h:531:25: error: unknown type name 'size_t'
531 | size_t __statelen) __THROW __nonnull ((2));
| ^~~~~~
/usr/include/stdlib.h:531:25: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:561:25: error: unknown type name 'size_t'
561 | size_t __statelen,
| ^~~~~~
/usr/include/stdlib.h:561:25: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:661:42: error: unknown type name 'size_t'
661 | extern void arc4random_buf (void *__buf, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:661:42: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:672:22: error: unknown type name 'size_t'
672 | extern void *malloc (size_t __size) __THROW __attribute_malloc__
| ^~~~~~
/usr/include/stdlib.h:672:22: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:675:22: error: unknown type name 'size_t'
675 | extern void *calloc (size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:675:22: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:675:38: error: unknown type name 'size_t'
675 | extern void *calloc (size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:675:38: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:683:36: error: unknown type name 'size_t'
683 | extern void *realloc (void *__ptr, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:683:36: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:695:41: error: unknown type name 'size_t'
695 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:695:41: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:695:57: error: unknown type name 'size_t'
695 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:695:57: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:701:41: error: unknown type name 'size_t'
701 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:701:41: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:701:57: error: unknown type name 'size_t'
701 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:701:57: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
In file included from /usr/include/stdlib.h:706:
/usr/include/alloca.h:32:22: error: unknown type name 'size_t'
32 | extern void *alloca (size_t __size) __THROW;
| ^~~~~~
/usr/include/alloca.h:25:1: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
24 | #include <stddef.h>
+++ |+#include <stddef.h>
25 |
/usr/include/stdlib.h:712:22: error: unknown type name 'size_t'
712 | extern void *valloc (size_t __size) __THROW __attribute_malloc__
| ^~~~~~
/usr/include/stdlib.h:712:22: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:718:45: error: unknown type name 'size_t'
718 | extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:718:45: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:718:65: error: unknown type name 'size_t'
718 | extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:718:65: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:724:29: error: unknown type name 'size_t'
724 | extern void *aligned_alloc (size_t __alignment, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:724:29: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:724:49: error: unknown type name 'size_t'
724 | extern void *aligned_alloc (size_t __alignment, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:724:49: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:961:23: error: unknown type name 'size_t'
961 | size_t __nmemb, size_t __size, __compar_fn_t __compar)
| ^~~~~~
/usr/include/stdlib.h:961:23: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:961:39: error: unknown type name 'size_t'
961 | size_t __nmemb, size_t __size, __compar_fn_t __compar)
| ^~~~~~
/usr/include/stdlib.h:961:39: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:970:34: error: unknown type name 'size_t'
970 | extern void qsort (void *__base, size_t __nmemb, size_t __size,
| ^~~~~~
/usr/include/stdlib.h:970:34: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:970:50: error: unknown type name 'size_t'
970 | extern void qsort (void *__base, size_t __nmemb, size_t __size,
| ^~~~~~
/usr/include/stdlib.h:970:50: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1044:20: error: unknown type name 'size_t'
1044 | size_t __len) __THROW __nonnull ((3, 4, 5));
| ^~~~~~
/usr/include/stdlib.h:1044:20: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1047:20: error: unknown type name 'size_t'
1047 | size_t __len) __THROW __nonnull ((3, 4, 5));
| ^~~~~~
/usr/include/stdlib.h:1047:20: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1051:45: error: unknown type name 'size_t'
1051 | char *__restrict __buf, size_t __len)
| ^~~~~~
/usr/include/stdlib.h:1051:45: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1055:45: error: unknown type name 'size_t'
1055 | char *__restrict __buf, size_t __len)
| ^~~~~~
/usr/include/stdlib.h:1055:45: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1062:36: error: unknown type name 'size_t'
1062 | extern int mblen (const char *__s, size_t __n) __THROW;
| ^~~~~~
/usr/include/stdlib.h:1062:36: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1066:48: error: unknown type name 'size_t'
1066 | const char *__restrict __s, size_t __n) __THROW;
| ^~~~~~
/usr/include/stdlib.h:1066:48: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1073:8: error: unknown type name 'size_t'
1073 | extern size_t mbstowcs (wchar_t *__restrict __pwcs,
| ^~~~~~
/usr/include/stdlib.h:1073:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1074:53: error: unknown type name 'size_t'
1074 | const char *__restrict __s, size_t __n) __THROW
| ^~~~~~
/usr/include/stdlib.h:1074:53: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1077:8: error: unknown type name 'size_t'
1077 | extern size_t wcstombs (char *__restrict __s,
| ^~~~~~
/usr/include/stdlib.h:1077:8: note: 'size_t' is defined in header ' |
s353664946 | p00156 | C | #include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
const int INF = 1 << 30;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
class State
{
public:
int x, y, cost;
bool water;
State(int _x, int _y, int _cost, bool _water)
:x(_x), y(_y), cost(_cost), water(_water) {}
bool operator < (const State& st) const
{
return this->cost > st.cost;
}
};
int main()
{
int n, m;
while (cin >> n >> m) {
if ((n|m) == 0)
break;
int sx, sy;
vector<string> castle(m);
for (int i = 0; i < m; ++i) {
cin >> castle[i];
castle[i].insert(castle[i].begin(), '.');
castle[i].insert(castle[i].end(), '.');
if (castle[i].find_first_of("&") != string::npos) {
sx = castle[i].find_first_of("&");
sy = i;
castle[sy][sx] = '.';
}
}
castle.insert(castle.begin(), string(n+2, '.'));
castle.push_back(string(n+2, '.'));
++sy;
priority_queue<State> que;
que.push(State(sx, sy, 0, false));
vector<vector<int> > dp(m+2, vector<int>(n+2, INF));
while (!que.empty()) {
const State st = que.top();
que.pop();
if (st.x == 0 || st.x == n+1 || st.y == 0 || st.y == m+1) {
cout << st.cost << endl;
break;
}
if (dp[st.y][st.x] < st.cost)
continue;
dp[st.y][st.x] = st.cost;
for (int d = 0; d < 4; ++d) {
int x = st.x + dx[d];
int y = st.y + dy[d];
if (x < 0 || n+2 <= x || y < 0 || m+2 <= y)
continue;
if (st.water) {
if (castle[y][x] == '#' && dp[y][x] > st.cost) {
dp[y][x] = st.cost;
que.push(State(x, y, st.cost, true));
}
if (castle[y][x] == '.' && dp[y][x] > st.cost+1) {
dp[y][x] = st.cost+1;
que.push(State(x, y, st.cost+1, false));
}
} else {
if (castle[y][x] == '#' && dp[y][x] > st.cost) {
dp[y][x] = st.cost;
que.push(State(x, y, st.cost, true));
}
if (castle[y][x] == '.' && dp[y][x] > st.cost) {
dp[y][x] == st.cost;
que.push(State(x, y, st.cost, false));
}
}
}
}
}
return 0;
} | main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s804925782 | p00156 | C++ | def ReadMap(n, m):
Map = [0] * m
for i in range(m):
a = raw_input()
b = list(a)
if a.count('&')>0:
j = a.index('&')
PosCas = [j, i]
b[j] = '.'
Map[i] = b
return Map, PosCas
def fill(SP, c1, c2):
for x, y in SP:
try:
if Map[y][x] != c1:continue
except: continue
if x in [0, n-1] or y in [0, m-1]: return 1
Map[y][x] = c2
SP += [[x+1, y], [x-1, y], [x, y+1], [x, y-1]]
return 0
while 1:
n, m = map(int, raw_input().split())
if n == m == 0: break
Map, PosCas = ReadMap(n, m)
c = 0
while 1:
SP = [PosCas]
if fill(SP, '.', '#'): break
c += 1
if fill(SP, '#', '.'): break
print c | a.cc:1:1: error: 'def' does not name a type
1 | def ReadMap(n, m):
| ^~~
|
s869765366 | p00156 | C++ | #include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
#define MAX_N 1000
int X[MAX_N][MAX_N], dist[MAX_N][MAX_N], W, H, gx, gy; char c;
int main() {
while (true) {
cin >> W >> H; memset(dist, 127, sizeof(dist)); queue<pair<int, int> >Q;
memset(X, 127, sizeof(X));
if (W == 0 && H == 0) { break; }
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) {
cin >> c; if (c == '&') { gx = i; gy = j; }
if (c == '#') { X[i][j] = 1; }
else { X[i][j] = 0; }
if (i == 1 || i == H || j == 1 || j == W) {
Q.push(make_pair(i, j));
dist[i][j] = X[i][j];
}
}
}
}
while (!Q.empty()) {
pair<int, int>pa = Q.front(); Q.pop(); int cx = pa.first, cy = pa.second;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
for (int i = 0; i < 4; i++) {
int ex = cx + dx[i], ey = cy + dy[i];
if (X[ex][ey] <= 1) {
int dis = dist[cx][cy] + X[ex][ey];
if (dist[ex][ey] > dis) {
dist[ex][ey] = dis; Q.push(make_pair(ex, ey));
}
}
}
}
cout << dist[gx][gy] << endl;
}
} | a.cc: In function 'int main()':
a.cc:25:25: error: 'Q' was not declared in this scope
25 | while (!Q.empty()) {
| ^
a.cc: At global scope:
a.cc:41:1: error: expected declaration before '}' token
41 | }
| ^
|
s688962719 | p00156 | C++ | #include <iostream>
#include <queue>
#include <string>
using namespace std;
typedef pair<int, int> P;
const int INF = 10000;
const int MAX = 100;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {-1, 0, 1, 0};
int m,n,sx,sy;
int step[MAX + 2][MAX + 2];
char field[MAX + 2][MAX + 2];
int main()
{
while(cin >> n >> m && m) {
memset(step, INF, sizeof(step));
memset(field, '.', sizeof(field));
for(int i = 1; i <= m; i++) {
for(int j = 1; j <= n; j++) {
cin >> field[i][j];
if(field[i][j] == '&') {
sx = j;
sy = i;
}
}
}
queue<P> que;
que.push(P(sx, sy));
step[sy][sx] = 0;
while(!que.empty()) {
P p = que.front(); que.pop();
int x = p.first, y = p.second;
for(int k = 0; k < 4; k++) {
int nx = x + dx[k], ny = y + dy[k], s = step[y][x];
if(field[ny][nx] == '#') s++;
if(nx >= 0 && nx <= n + 1 && ny >= 0 && ny <= m + 1 && s < step[ny][nx]) {
step[ny][nx] = s;
que.push(P(nx, ny));
}
}
}
int res = INF;
for(int i = 0; i <= m + 1; i++)
for(int j = 0; j <= n + 1; j++)
if(i == 0 || i == m + 1 || j == 0 || j == n + 1)
res = min(res, step[i][j]);
cout << res << endl;
}
} | a.cc: In function 'int main()':
a.cc:19:9: error: 'memset' was not declared in this scope
19 | memset(step, INF, sizeof(step));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <queue>
+++ |+#include <cstring>
3 | #include <string>
|
s008549586 | p00156 | C++ | #include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
#define mp make_pair
typedef pair<int, int> P;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int N, M;
char maze[110][110];
unsigned int minp[110][110];
int main() {
for(;;) {
memset(minp, -1, sizeof minp);
scanf(" %d %d", &N, &M);
if(!N && !M) break;
for(int i = 0; i < M; i++) {
scanf(" %s", maze[i]);
}
#if 1
for(int i = 0; i < M; i++) {
printf("%s\n", maze[i]);
}
#endif
// P = (x, y)
// maze[y][x]
queue<P> que;
{
P put;
for(int x = 0; x < N; x++) {
for(int y = 0; y < M; y++) {
if(maze[y][x] == '&') {
put.first = x;
put.second = y;
minp[y][x] = 0;
maze[y][x] = '.';
}
}
}
que.push(put);
}
;
while(!que.empty()) {
P p = que.front();
que.pop();
// endð ȵ ?
// push
for(int i = 0; i < 4; i++) {
int nx = p.first + dx[i];
int ny = p.second + dy[i];
if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '.' && maze[ny][nx] == '.' && minp[ny][nx] > minp[p.second][p.first]) {
minp[ny][nx] = minp[p.second][p.first];
que.push(mp(nx, ny));
}
if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '#' && maze[ny][nx] == '#' && minp[ny][nx] > minp[p.second][p.first]) {
minp[ny][nx] = minp[p.second][p.first];
que.push(mp(nx, ny));
}
if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '.' && maze[ny][nx] == '#' && minp[ny][nx] > minp[p.second][p.first]) {
minp[ny][nx] = minp[p.second][p.first] + 1;
que.push(mp(nx, ny));
}
if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '#' && maze[ny][nx] == '.' && minp[ny][nx] > minp[p.second][p.first]) {
minp[ny][nx] = minp[p.second][p.first];
que.push(mp(nx, ny));
}
}
}
unsigned int minv = INT_MAX;
for(int i = 0; i < N; i++) {
minv = min(minv, min(minp[0][i], minp[M - 1][i]));
}
for(int i = 0; i < M; i++) {
minv = min(minv, min(minp[i][0], minp[N - 1][i]));
}
printf("%d\n", minv);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:79:37: error: 'INT_MAX' was not declared in this scope
79 | unsigned int minv = INT_MAX;
| ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include <algorithm>
+++ |+#include <climits>
6 | using namespace std;
|
s634181553 | p00156 | C++ | #include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
#define mp make_pair
typedef pair<int, int> P;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int N, M;
char maze[110][110];
unsigned int minp[110][110];
int main() {
for(;;) {
memset(minp, -1, sizeof minp);
scanf(" %d %d", &N, &M);
if(!N && !M) break;
for(int i = 0; i < M; i++) {
scanf(" %s", maze[i]);
}
// P = (x, y)
// maze[y][x]
queue<P> que;
{
P put;
for(int x = 0; x < N; x++) {
for(int y = 0; y < M; y++) {
if(maze[y][x] == '&') {
put.first = x;
put.second = y;
minp[y][x] = 0;
maze[y][x] = '.';
}
}
}
que.push(put);
}
;
while(!que.empty()) {
P p = que.front();
que.pop();
// push
for(int i = 0; i < 4; i++) {
int nx = p.first + dx[i];
int ny = p.second + dy[i];
if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '.' && maze[ny][nx] == '.' && minp[ny][nx] > minp[p.second][p.first]) {
minp[ny][nx] = minp[p.second][p.first];
que.push(mp(nx, ny));
}
if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '#' && maze[ny][nx] == '#' && minp[ny][nx] > minp[p.second][p.first]) {
minp[ny][nx] = minp[p.second][p.first];
que.push(mp(nx, ny));
}
if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '.' && maze[ny][nx] == '#' && minp[ny][nx] > minp[p.second][p.first]) {
minp[ny][nx] = minp[p.second][p.first] + 1;
que.push(mp(nx, ny));
}
if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '#' && maze[ny][nx] == '.' && minp[ny][nx] > minp[p.second][p.first]) {
minp[ny][nx] = minp[p.second][p.first];
que.push(mp(nx, ny));
}
}
}
unsigned int minv = INT_MAX;
for(int i = 0; i < N; i++) {
minv = min(minv, min(minp[0][i], minp[M - 1][i]));
}
for(int i = 0; i < M; i++) {
minv = min(minv, min(minp[i][0], minp[N - 1][i]));
}
printf("%d\n", minv);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:71:37: error: 'INT_MAX' was not declared in this scope
71 | unsigned int minv = INT_MAX;
| ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
4 | #include <algorithm>
+++ |+#include <climits>
5 | using namespace std;
|
s808557210 | p00156 | C++ | #include<iostream>
#include<queue>
using namespace std;
int n,m;
int gx,gy;
int INF=1000000;
char fie[120][120];
int jp[120][120];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
typedef pair<int,int> P;
typedef pair<P,int> PP;
void bfs(){
queue<PP> que;
for(int i=0;i<=m;i++){
for(int j=0;j<=n;j++){
jp[j][i]=INF;
}
}
for(int i=0;i<=n;i++){
que.push(PP(P(i,0),0));
jp[i][0]=0;
que.push(PP(P(i,m+1),0));
jp[i][m+1]=0;
}
for(int i=0;i<=m;i++){
que.push(PP(P(0,i),0));
jp[0][i]=0;
que.push(PP(P(n+1,i),0));
jp[n+1][i]=0;
}
while(que.size()){
PP p=que.front();que.pop();
for(int i=0;i<4;i++){
int kx=p.first.first+dx[i],ky=p.first.second+dy[i],k=p.second;
if(kx>=0 && kx<=n+1 && ky>=0 && ky<=m+1){
if(fie[kx][ky]=='.' && k<jp[kx][ky]){
que.push(PP(P(kx,ky),k));
jp[kx][ky]=k;
}
if(fie[kx][ky]=='&' && k<jp[kx][ky]){
que.push(PP(P(kx,ky),k));
jp[kx][ky]=k;
}
if(fie[kx][ky]=='#' && k+1<jp[kx][ky]){
que.push(PP(P(kx,ky),k+1));
jp[kx][ky]=k+1;
}
}
}
}
}
int main(void){
while(1){
memset(fie,'.',sizeof(fie));
scanf("%d%d",&n,&m);
if(n==0 && m==0)break;
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
cin >> fie[j][i];
if(fie[j][i]=='&')gx=j,gy=i;
}
}
bfs();
printf("%d\n",jp[gx][gy]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:58:17: error: 'memset' was not declared in this scope
58 | memset(fie,'.',sizeof(fie));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<queue>
+++ |+#include <cstring>
3 | using namespace std;
|
s442577424 | p00156 | C++ | #include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
int H, W;
char grid[101][101];
int const dx[4] = {-1,1,0,0};
int const dy[4] = {0,0,-1,1};
int memo[101][101];
inline bool IN(int x, int y) {
return 0<=x && x<W && 0<=y && y<H;
}
int const INF = 1<<29;
int main() {
while(cin >> W >> H && W) {
int sx, sy;
for(int i=0; i<H; i++) {
for(int j=0; j<W; j++) {
cin >> grid[i][j];
if(grid[i][j] == '&') {
sx = j, sy = i;
}
}
}
memset(memo, -1, sizeof(memo));
typedef pair<int, int> Pii;
typedef pair<int, Pii> Piii;
int ans = 1<<29;
priority_queue<Piii> Q;
Q.push(Piii(0, Pii(sx, sy)));
while(!Q.empty()) {
Piii piii = Q.top(); Q.pop();
int const x = piii.second.first;
int const y = piii.second.second;
int const cost = piii.first;
for(int k=0; k<4; k++) {
int nx = x + dx[k], ny = y + dy[k];
if(IN(nx, ny)) {
int ncost = cost + (grid[ny][nx] == '#');
if(memo[ny][nx] == -1
|| memo[ny][nx] > ncost) {
memo[ny][nx] = ncost;
Q.push(Piii(ncost, Pii(nx, ny)));
}
} else {
ans = min(ans, cost);
}
}
}
cout << ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:36:5: error: 'memset' was not declared in this scope
36 | memset(memo, -1, sizeof(memo));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <queue>
+++ |+#include <cstring>
4 |
|
s453307103 | p00157 | C | 6
1 1
4 3
6 5
8 6
10 10
14 14
5
2 2
5 4
6 6
9 8
15 10
4
1 1
4 3
6 5
8 6
3
2 2
5 4
6 6
4
1 1
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0 | main.c:1:1: error: expected identifier or '(' before numeric constant
1 | 6
| ^
|
s537202143 | p00157 | C | #include<stdio.h>
int LIS(void);
int h[201], r[201], m, n;
int main(void)
{
int i, j, t;
while(1)
{
scanf("%d",&n);
if(n==0)break;
for(i=0;i<n;i++)
scanf("%d%d",&h[i] ,&r[i]);
for(i=0;i<n+m;i++)
{
for(j=0;j<n+m;j++)
{
if(h[i]<h[j])
{
t=h[i];
h[i]=h[j];
h[j]=t;
t=r[i];
r[i]=r[j];
r[j]=t;
}
if(h[i]==h[j] && r[i]<r[j])
{
t=h[i];
h[i]=h[j];
h[j]=t;
t=r[i];
r[i]=r[j];
r[j]=t;
}
}
}
printf("%d\n",LIS());
}
return 0;
}
int LIS(void)
{
int i ,j ,k ,L[201] ,max=0;
for(i=0;i<201;i++)
L[i]=1;
for(i=1;i<n+m;i++)
{
j=i-1;
for(k=0;k<i;k++)
{
if(r[k]<r[i] && h[k]<h[i]ツ && L[k]>=L[i])L[i]=L[k]+1;
}
}
for(i=0;i<n+m;i++)
if(max<L[i])max=L[i];
return max;
} | main.c: In function 'LIS':
main.c:117:26: error: expected ')' before '\U000030c4'
117 | if(r[k]<r[i] && h[k]<h[i]ツ && L[k]>=L[i])L[i]=L[k]+1;
| ~ ^~
| )
main.c:117:28: error: stray '\343' in program
117 | if(r[k]<r[i] && h[k]<h[i]<U+30C4><U+3000>&& L[k]>=L[i])L[i]=L[k]+1;
| ^~~~~~~~
|
s037863308 | p00157 | C | #include<stdio.h>
int LIS(void);
int h[201], r[201], m, n;
int main(void)
{
int i, j, t;
while(1)
{
scanf("%d",&n);
if(n==0)break;
for(i=0;i<n;i++)
scanf("%d%d",&h[i] ,&r[i]);
for(i=0;i<n+m;i++)
{
for(j=0;j<n+m;j++)
{
if(h[i]<h[j])
{
t=h[i];
h[i]=h[j];
h[j]=t;
t=r[i];
r[i]=r[j];
r[j]=t;
}
if(h[i]==h[j] && r[i]<r[j])
{
t=h[i];
h[i]=h[j];
h[j]=t;
t=r[i];
r[i]=r[j];
r[j]=t;
}
}
}
printf("%d\n",LIS());
}
return 0;
}
int LIS(void)
{
int i ,j ,k ,L[201] ,max=0;
for(i=0;i<201;i++)
L[i]=1;
for(i=1;i<n+m;i++)
{
j=i-1;
for(k=0;k<i;k++)
{
if(r[k]<r[i] && h[k]<h[i]ツ && L[k]>=L[i])L[i]=L[k]+1;
}
}
for(i=0;i<n+m;i++)
if(max<L[i])max=L[i];
return max;
} | main.c: In function 'LIS':
main.c:102:26: error: expected ')' before '\U000030c4'
102 | if(r[k]<r[i] && h[k]<h[i]ツ && L[k]>=L[i])L[i]=L[k]+1;
| ~ ^~
| )
main.c:102:28: error: stray '\343' in program
102 | if(r[k]<r[i] && h[k]<h[i]<U+30C4><U+3000>&& L[k]>=L[i])L[i]=L[k]+1;
| ^~~~~~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.