submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s622754409 | p00202 | C++ | #include<iostream>
#define N 1000001
using namespace std;
int main(){
int p[N]={0};
for(int i=3;i<N;i+=2) p[i] = 1;
p[2] = 1;
for(int i=3;i<=1000;i+=2){
if(p[i]==1){
for(int j=2*i;j<N;j+=i) p[j] = 0;
}
}
int n,x;
while(cin >> n >> x){
if(n==0&&x==0) break;
int t[x+1];
for(int i=0;i<=x;i++) t[i] = 0;
for(int i=0;i<n;i++){
int k;
cin >> k;
if(k<=x) t[k] = 1;
for(int j=1;j<=x;j++){
if(t[j]==1&&j+k<=x) t[j+k] = 1;
}
}
bool ok = false;
for(int i=x;i>=0;i--){
if(t[i]==1&&p[i]==1){
cout << i << endl;
ok = true;
break;
}
}
if(!ok) cout << "NA" << endl;
}
return 0;
}
Compile Error Logs:
ステータス
Judge: 1/1 C++ CPU: 00:92 sec Memory: 8976 KB Length: 679 B 2014-01-07 17:45
テストケースの判定結果
Case # Verdict CPU Time Memory In Out Case Name
Case #1 : Accepted 00:92 8976 0 0 judge_data
< prev | / | next >
Judge Input # ( | ) Judge Output # ( | )
| a.cc:44:6: error: stray '#' in program
44 | Case # Verdict CPU Time Memory In Out Case Name
| ^
a.cc:45:6: error: stray '#' in program
45 | Case #1 : Accepted 00:92 8976 0 0 judge_data
| ^
a.cc:49:13: error: stray '#' in program
49 | Judge Input # ( | ) Judge Output # ( | )
| ^
a.cc:49:46: error: stray '#' in program
49 | Judge Input # ( | ) Judge Output # ( | )
| ^
a.cc:39:1: error: 'Compile' does not name a type
39 | Compile Error Logs:
| ^~~~~~~
|
s833364587 | p00202 | C++ | #include<iostream>
using namespace std;
#define MAX_N 1000000
int prime[MAX_N+1];
bool is_prime[MAX_N+1];
int main(){
int p = 0;
for(int i=0;i<=MAX_N;i++) is_prime[i] = true;
is_prime[0] = is_prime[1] = false;
for(int i=2;i<=MAX_N;i++){
if(is_prime[i]){
prime[p++] = i;
for(int j=2*i;j<=MAX_N;j+=i) is_prime[j] = false;
}
}
int n,x;
while(cin >> n >> x){
if(n==0&&x==0) break;
int v[n];
bool dp[x+1];
for(int i=0;i<=x;i++)
dp[i] = false;
for(int i=0;i<n;i++)
cin >> v[i];
dp[v[0]] = true;
for(int i=0;i<n;i++){
for(int
| a.cc: In function 'int main()':
a.cc:32:14: error: expected unqualified-id at end of input
32 | for(int
| ^
a.cc:32:14: error: expected ';' at end of input
32 | for(int
| ^
| ;
a.cc:32:14: error: expected primary-expression at end of input
a.cc:32:14: error: expected ';' at end of input
32 | for(int
| ^
| ;
a.cc:32:14: error: expected primary-expression at end of input
a.cc:32:14: error: expected ')' at end of input
32 | for(int
| ~ ^
| )
a.cc:32:14: error: expected statement at end of input
a.cc:32:14: error: expected '}' at end of input
a.cc:31:25: note: to match this '{'
31 | for(int i=0;i<n;i++){
| ^
a.cc:32:14: error: expected '}' at end of input
32 | for(int
| ^
a.cc:20:23: note: to match this '{'
20 | while(cin >> n >> x){
| ^
a.cc:32:14: error: expected '}' at end of input
32 | for(int
| ^
a.cc:8:11: note: to match this '{'
8 | int main(){
| ^
|
s278649940 | p00202 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int main(){
//ツ素ツ青板青カツ青ャ
const int NUM = 1000000;
bool prime[NUM];
prime[0] = false;
prime[1] = false;
for(int i=2;i<NUM;i++)
prime[i] = true;
for(int i=2;i*i<NUM;i++)
for(int k=2;i*k<NUM;k++)
prime[i*k]=false;
while(true){
int n,x;
cin>>n>>x;
if(!n&&!x)break;
int menu[n];
for(int i=0;i<n;i++)cin>>menu[i];
bool money[x+1];
money[0] = true;#include<iostream>
#include<algorithm>
using namespace std;
int main(){
//ツ素ツ青板青カツ青ャ
const int NUM = 1000000;
bool prime[NUM];
prime[0] = false;
prime[1] = false;
for(int i=2;i<NUM;i++)
prime[i] = true;
for(int i=2;i*i<NUM;i++)
for(int k=2;i*k<NUM;k++)
prime[i*k]=false;
while(true){
int n,x;
cin>>n>>x;
if(!n&&!x)break;
int menu[n];
for(int i=0;i<n;i++)cin>>menu[i];
bool money[x+1];
money[0] = true;
for(int i=1;i<x+1;i++){
money[i] = false;
for(int j=0;j<n;j++){
if(i>=menu[j]&&money[i-menu[j]]){
money[i] = true;
break;
}
}
}
int p = -1;
for(int i=x;i>0;i--){
if(money[i]&&prime[i]){
p=i;
break;
}
}
if(p==-1)cout<<"NA"<<endl;
else cout<<p<<endl;
}
return 0;
}
for(int i=1;i<x+1;i++){
money[i] = false;
for(int j=0;j<n;j++){
if(i>=menu[j]&&money[i-menu[j]]){
money[i] = true;
break;
}
}
}
int p = -1;
for(int i=x;i>0;i--){
if(prime[i]&&money[i]){
p=i;
break;
}
}
if(p==-1)cout<<"NA"<<endl;
else cout<<p<<endl;
}
return 0;
} | a.cc:24:21: error: stray '#' in program
24 | money[0] = true;#include<iostream>
| ^
a.cc: In function 'int main()':
a.cc:24:22: error: 'include' was not declared in this scope
24 | money[0] = true;#include<iostream>
| ^~~~~~~
a.cc:24:38: error: expected primary-expression before '>' token
24 | money[0] = true;#include<iostream>
| ^
a.cc:26:1: error: expected primary-expression before 'using'
26 | using namespace std;
| ^~~~~
a.cc:28:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
28 | int main(){
| ^~
a.cc:28:9: note: remove parentheses to default-initialize a variable
28 | int main(){
| ^~
| --
a.cc:28:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:28:11: error: a function-definition is not allowed here before '{' token
28 | int main(){
| ^
|
s883204916 | p00202 | C++ | #include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int main(){
bool sosuu[1000011];
bool dp[1000011];
for(int i=0;i<=1000000;i++){
sosu[i]=0;
}
for(int i=2;i<=500000;i++){
if(sosuu[i]==0){
for(int j=i;j<=1000000;j+=i){
sosuu[j]=1;
}
sosuu[i]=0;
}
}
sosuu[0]=1;
sosuu[1]=1;
while(1){
for(int i=0;i<=1000000;i++){
dp[i]=0;
}
int item[30];
int n,m;
scanf("%d%d",&n,&m);
if(n==0 && m==0){
break;
}
for(int i=0;i<n;i++){
scanf("%d",&item[i]);
}
dp[0]=1;
for(int i=0;i<=m;i++){
for(int j=0;j<n;j++){
if(i<item[j]){
continue;
}
if(dp[i-item[j]]==1){
dp[i]=1;
}
}
}
int num=0;
for(int i=m;i>=0;i--){
if(dp[i]==1&&sosuu[i]==0){
num=i;
break;
}
}
if(num==0){
puts("NA");
}else{
printf("%d\n",num);
}
}
} | a.cc: In function 'int main()':
a.cc:15:25: error: 'sosu' was not declared in this scope; did you mean 'sosuu'?
15 | sosu[i]=0;
| ^~~~
| sosuu
|
s115837972 | p00202 | C++ | #include <stdio.h>
#include <windows.h>
int n,m[30];
bool prime[1000000];
bool c[1000000];
void saiki(int total){
int i;
if(total==0){
return;
}
if(total<0){
return;
}
for( i=0 ; i<n ; i++){
total-=m[i];
if(c[total]==1)continue;
if(total>=0){
c[total]=1;
}
saiki(total);
}
}
int main(void)
{
int i,j;
//f
prime[0]=1;
prime[1]=1;
for(i=3;i<1000000;i++){
if(i%2==0){
prime[i]=1;
}
}
for(i=3;i<1000000;i++){
if(prime[i]==0){
for(j=(i+i);j<1000000;j+=i){
prime[j]=1;
}
}
}
//
while(1){
int x;
int flg=0;
scanf("%d%d",&n,&x);
if(n==0)break;
for(i=0;i<n;i++){
scanf("%d",&m[i]);
}
saiki(x);
//
for(i=0;i<x;i++){
if(c[i]==1 && prime[x-i]==0){
flg=1;
break;
}
}
if(flg==1){
printf("%d\n",x-i);
}
else puts("NA");
for(i=0;i<1000000;i++){
c[i]=0;
}
//
}
return 0;
} | a.cc:2:10: fatal error: windows.h: No such file or directory
2 | #include <windows.h>
| ^~~~~~~~~~~
compilation terminated.
|
s335066340 | p00202 | C++ | #include <stdio.h>
int n,m[30];
/*
bool prime[1000000];
*/
bool c[1000000];
void saiki(int total){
int i;
if(total<=0){
return;
}
for( i=0 ; i<n ; i++){
total-=m[i];
if(c[total]==1)continue;
if(total>=0){
c[total]=1;
}
saiki(total);
}
}
int check(int prime){
int flg=0,i;
if(prime%2==0)return 0;
for(i=3;i<prime;i+=2){
if(prime%i==0){
flg=1;
}
}
if(flg==1)return 0;
return 1;
}
int main(void)
{
int i,j;
//f
/*
prime[0]=1;
prime[1]=1;
for(i=3;i<1000000;i++){
if(i%2==0){
prime[i]=1;
}
}
for(i=3;i<1000000;i++){
if(prime[i]==0){
for(j=(i+i);j<1000000;j+=i){
prime[j]=1;
}
}
}
*/
//
while(1){
for(;;)
int x;
int flg=0;
scanf("%d%d",&n,&x);
if(n==0)break;
for(i=0;i<n;i++){
scanf("%d",&m[i]);
}
saiki(x);
//
for(i=0;i<x;i++){
if(c[i]==1 && check(x-i)){
flg=1;
break;
}
}
if(flg==1){
printf("%d\n",x-i);
}
else puts("NA");
for(i=0;i<1000000;i++){
c[i]=0;
}
//
}
return 0;
} | a.cc: In function 'int main()':
a.cc:62:34: error: 'x' was not declared in this scope
62 | scanf("%d%d",&n,&x);
| ^
|
s702980441 | p00202 | C++ | #include <stdio.h>
int n,m[30];
/*
bool prime[1000000];
*/
bool c[1000000];
void saiki(int total){
int i;
if(total<=0){
return;
}
for( i=0 ; i<n ; i++){
total-=m[i];
if(c[total]==1)continue;
if(total>=0){
c[total]=1;
}
saiki(total);
}
}
int check(int prime){
int flg=0,i;
if(prime%2==0)return 0;
for(i=3;i<prime;i+=2){
if(prime%i==0){
flg=1;
}
}
if(flg==1)return 0;
return 1;
}
int main(void)
{
int i,j;
//f
/*
prime[0]=1;
prime[1]=1;
for(i=3;i<1000000;i++){
if(i%2==0){
prime[i]=1;
}
}
for(i=3;i<1000000;i++){
if(prime[i]==0){
for(j=(i+i);j<1000000;j+=i){
prime[j]=1;
}
}
}
*/
//
while(1){
for(int m;m<100;i++)
int x;
int flg=0;
scanf("%d%d",&n,&x);
if(n==0)break;
for(i=0;i<n;i++){
scanf("%d",&m[i]);
}
saiki(x);
//
for(i=0;i<x;i++){
if(c[i]==1 && check(x-i)){
flg=1;
break;
}
}
if(flg==1){
printf("%d\n",x-i);
}
else puts("NA");
for(i=0;i<1000000;i++){
c[i]=0;
}
//
}
return 0;
} | a.cc: In function 'int main()':
a.cc:62:34: error: 'x' was not declared in this scope
62 | scanf("%d%d",&n,&x);
| ^
|
s684487134 | p00202 | C++ | #include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
const int N = 1000000;
int prime[N+1];
int dish[30];
int n, x;
int max_val;
void setPrime()
{
memset(&prime[0], 0, sizeof(int) * (N+1));
prime[2] = 1;
for(int i=2; i<=N; i++)
{
bool is_prime = true;
int limit = sqrt(i);
for(int k=2; k<=limit; k++)
{
if(i % k == 0)
{
is_prime = false;
break;
}
}
if(is_prime)
{
prime[i] = 1;
}
}
}
void solve(int price, int depth)
{
if(depth == n-1)
{
if(prime[price] == 1 && max_val < price)
{
max_val = price;
}
return;
}
while(price <= x)
{
solve(price, depth+1);
price += dish[depth];
}
}
int main()
{
setPrime();
while( 1 )
{
cin >> n >> x;
if(n==0 && x==0)
{
break;
}
for(int i=0; i<n; i++)
{
cin >> dish[i];
}
max_val = 0;
solve(0, 0);
if(max_val != 0)
{
printf("%d\n", max_val);
}
else
{
printf("NA\n");
}
}
} | a.cc: In function 'void setPrime()':
a.cc:16:9: error: 'memset' was not declared in this scope
16 | memset(&prime[0], 0, sizeof(int) * (N+1));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <math.h>
+++ |+#include <cstring>
4 |
|
s735622867 | p00202 | C++ | #include<iostream>
using namespace std;
bool prime[1000001];
bool dp[1000001];
int menu[31];
void seive(int s){
for(int i=0;i<=s;i++)prime[i]=true;
prime[0]=prime[1]=false;
for(int i=2;i<=s;i++){
if(prime[2]==true){
for(int j=i*2;j<=s;j+=i){
prime[j]=false;
}
}
}
}
int main(void){
seive(1000000);
int n,x;
while(1){
int max=0;
memset(dp,false,sizeof(dp));
scanf("%d%d",&n,&x);
if(n==0 && x==0)break;
for(int i=0;i<n;i++){
scanf("%d",&menu[i]);
}
dp[0]=true;
for(int i=0;i<n;i++){
for(int j=menu[i];j<=x;j++){
if(dp[j-menu[i]]==true)dp[j]=true;
}
}
for(int i=0;i<=x;i++){
if(dp[i]==true && prime[i]==true)max=i;
}
if(max>0)printf("%d\n",max);
else printf("NA\n");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:25:17: error: 'memset' was not declared in this scope
25 | memset(dp,false,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 |
|
s439769978 | p00202 | C++ | #include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
const int MAX = 1000000;
bool isPrime[MAX] = {0};
void sieve(){
bool find[MAX] = {0};
int i;
for(i=2;i*i < MAX;i++){
if(find[i]) continue;
isPrime[i] = true;
for(int j=i;j<MAX;j++){
if(j%i == 0){
find[j] = true;
isPrime[j] = false;
}
}
}
for(;i<MAX;i++){
if(!find[i]) isPrime[i] = true;;
}
}
int main(){
sieve();
while(true){
int n,x;
cin >> n >> x;
if(n==0 && x==0) return 0;
vector<int> R(n);
for(int i=0;i<n;i++){
cin >> R[i];
}
set<int> S;
S.insert(0);
for(int i=0;i<R.size();i++){
for(set<int>::iterator it=S.begin();it!=S.end();++it){
int newe = *it + R[i];
if(newe > x) continue;
S.insert(newe);
}
}
int maxn = -1;
for(set<int>::iterator it=S.begin();it!=S.end();++it){
if(isPrime[*it] && *it > maxn) maxn = *it;
}
if(maxn == -1) cout << "NA" << endl;
else cout << maxn << endl;
}
return 0;
}
b | a.cc:59:1: error: 'b' does not name a type
59 | b
| ^
|
s267917429 | p00202 | C++ | #include <iostream>
#define N 1000000
using namespace std;
int main(void){
bool isprime[N+1];
for(int i=0;i<=N;i++)
isprime[i]=true;
isprime[0]=isprime[1]=false;
for(int i=2;i<=N;i++)
if(isprime[i])
for(int j=2*i;j<=N;j+=i)
isprime[j]=false;
bool budget[N+1];
int n,m;
while(cin >> n>>m,n|m){
for(int i=0;i<=m;i++)
budget[i]=false;
int tmp;
budget[0]=true;
for(int i=0;i<n;i++){
cin >> tmp;
for(int j=0;j<=m;j++)
if(budget[j]&&(j+tpm)<=m)
budget[j+tmp]=true;
}
int MAX=0;
for(int i=m;i>0;i--){
if(budget[i]&isprime[i]){
MAX=i;break;
}
}
if(MAX)
cout << MAX << endl;
else
cout << "NA" << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:50: error: 'tpm' was not declared in this scope; did you mean 'tmp'?
24 | if(budget[j]&&(j+tpm)<=m)
| ^~~
| tmp
|
s984305892 | p00202 | C++ | require 'Prime'
loop do
n, x = gets.split.map(&:to_i)
break if n.zero? && x.zero?
pb = [true]
n.times.map{ gets.to_i }.each do |p|
(0..x-p).each do |i|
pb[i+p] = true if pb[i]
end
end
na = true
x.step(2, -1) do |i|
if pb[i] && i.prime?
puts i
na = false
break
end
end
puts "NA" if na
end | a.cc:1:9: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
1 | require 'Prime'
| ^~~~~~~
a.cc:8:6: error: too many decimal points in number
8 | (0..x-p).each do |i|
| ^~~~
a.cc:1:1: error: 'require' does not name a type
1 | require 'Prime'
| ^~~~~~~
a.cc:7:27: error: expected unqualified-id before '.' token
7 | n.times.map{ gets.to_i }.each do |p|
| ^
|
s984088757 | p00202 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>
using namespace std;
vector<int> primes;
void make_primes( int lim ) {
vector<bool> vs( lim + 1 );
fill( vs.begin(), vs.end(), true );
vs[ 0 ] = vs[ 1 ] = false;
const int l = (int)sqrt( lim );
for ( int i = 2; i <= l; i++ ){
if ( vs[ i ] ) {
for ( int j = i * i; j <= lim; j += i ) {
vs[ j ] = false;
}
}
}
for ( int i = 2; i <= lim; i++ ) {
if ( vs[ i ] ) {
priems.push_back( i );
}
}
}
bool isPrime( int n ) {
return binary_search( primes.begin(), primes.end(), n );
}
int main() {
make_primes( 1000000 );
while( true ) {
int n, x;
cin >> n >> x;
if ( n == 0 and x == 0 ) break;
vector<int> vs( n );
for ( int i = 0; i < n; i++ ) {
cin >> vs[ i ];
}
sort( vs.begin(), vs.end() );
vector<int> cs;
cs.push_back( 0 );
vector<int> indices( n );
fill( indices.begin(), indices.end(), 0 );
while( cs.back() <= x ) {
int mv = 100000000;
int mi = -1;
for ( int i = 0; i < n; i++ ) {
if ( mv > cs[ indices[ i ] ] + vs[ i ] ) {
mi = i;
mv = cs[ indices[ i ] ] + vs[ i ];
}
}
if ( cs.back() < mv ) {
cs.push_back( mv );
}
indices[ mi ]++;
}
reverse( cs.begin(), cs.end() );
bool s = false;
for ( int v : cs ) {
if ( isPrime( v ) ) {
s = true;
cout << v << endl;
break;
}
}
if ( not s ) {
cout << "NA" << endl;
}
}
} | a.cc: In function 'void make_primes(int)':
a.cc:26:11: error: 'priems' was not declared in this scope; did you mean 'primes'?
26 | priems.push_back( i );
| ^~~~~~
| primes
|
s065609439 | p00202 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>
using namespace std;
vector<int> primes;
void make_primes( int lim ) {
vector<bool> vs( lim + 1 );
fill( vs.begin(), vs.end(), true );
vs[ 0 ] = vs[ 1 ] = false;
const int l = (int)sqrt( lim );
for ( int i = 2; i <= l; i++ ){
if ( vs[ i ] ) {
for ( int j = i * i; j <= lim; j += i ) {
vs[ j ] = false;
}
}
}
for ( int i = 2; i <= lim; i++ ) {
if ( vs[ i ] ) {
priems.push_back( i );
}
}
}
bool isPrime( int n ) {
return binary_search( primes.begin(), primes.end(), n );
}
int main() {
make_primes( 1000000 );
while( true ) {
int n, x;
cin >> n >> x;
if ( n == 0 and x == 0 ) break;
vector<int> vs( n );
for ( int i = 0; i < n; i++ ) {
cin >> vs[ i ];
}
sort( vs.begin(), vs.end() );
vector<int> cs;
cs.push_back( 0 );
vector<int> indices( n );
fill( indices.begin(), indices.end(), 0 );
while( cs.back() <= x ) {
int mv = 100000000;
int mi = -1;
for ( int i = 0; i < n; i++ ) {
if ( mv > cs[ indices[ i ] ] + vs[ i ] ) {
mi = i;
mv = cs[ indices[ i ] ] + vs[ i ];
}
}
if ( cs.back() < mv ) {
cs.push_back( mv );
}
indices[ mi ]++;
}
reverse( cs.begin(), cs.end() );
bool s = false;
for ( int v : cs ) {
if ( isPrime( v ) ) {
s = true;
cout << v << endl;
break;
}
}
if ( not s ) {
cout << "NA" << endl;
}
}
} | a.cc: In function 'void make_primes(int)':
a.cc:26:11: error: 'priems' was not declared in this scope; did you mean 'primes'?
26 | priems.push_back( i );
| ^~~~~~
| primes
|
s855516053 | p00202 | C++ | from datetime import datetime
def measure(f):
measure_start = datetime.now()
v = f()
print(datetime.now() - measure_start)
return v
input = raw_input
range = xrange
def init():
table = [True] * 1000001
table[0] = False
table[1] = False
n = len(table)
def prime(p):
for i in range(p + p, n, p):
table[i] = False
prime(2)
prime(3)
prime(5)
prime(7)
prime(11)
prime(13)
for i in range(2, n):
if (i % 2 != 0 and i % 3 != 0 and i % 5 != 0 and
i % 7 != 0 and i % 11 != 0 and i % 13 != 0):
for j in range(i + i, n, i):
table[j] = False
return table
def solve(price, ps, is_prime):
dp = [0] * ((price >> 5) + 1)
def get(i):
return ((dp[i >> 5] >> (i & 31)) & 1)
def set(i, v):
dp[i >> 5] |= (v << (i & 31))
def get_p(i):
return dp[i >> 5]
def set_p(i, v):
dp[i >> 5] |= v
if ps[0] <= price:
set(ps[0], 1)
set(0, 1)
for i in range(1, len(ps)):
cur_p = ps[i]
r = cur_p & 31
rest = 0
for p in range(cur_p, price + 1, 32):
i1 = (p - cur_p) >> 5
i2 = p >> 5
v = dp[i1]
dp[i2] |= (v << r) | rest
v = dp[i1]
dp[i2] |= (v << r) | rest
v = dp[i1]
dp[i2] |= (v << r) | rest
v = dp[i1]
dp[i2] |= (v << r) | rest
v = dp[i1]
dp[i2] |= (v << r) | rest
v = dp[i1]
dp[i2] |= (v << r) | rest
rest = (v >> (32 - r)) & ((1 << r) - 1)
p = -1
for i in range(0, price + 1):
if is_prime[i] and get(i) == 1:
p = i
if p == -1:
print("NA")
else:
print(p)
def main():
table = init()
while True:
n, price = map(int,input().split())
if n == 0 and price == 0:
return
ps = []
for i in range(n):
ps.append(int(input()))
solve(price, ps, table)
main() | a.cc:1:1: error: 'from' does not name a type
1 | from datetime import datetime
| ^~~~
|
s656565644 | p00203 | Java |
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
import scala.inline;
import scala.noinline;
public class Main {
public static void main(String[] args) throws IOException {
new Main().run();
}
private void run() throws IOException {
Scanner scanner = new Scanner(System.in);
while (true) {
m = scanner.nextInt();
n = scanner.nextInt();
if ((m | n) == 0)
break;
map = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
map[i][j] = scanner.nextInt();
}
}
count = 0;
for (int i = 0; i < m; i++) {
slove(i, 0, 0);
}
System.out.println(count);
}
}
private void slove(int x, int y, int r) {
if (y == n) {
count++;
return;
}
if (x < 0 || x == m)
return;
if (map[y][x] == 1)
return;
if (map[y][x] == 2 && r != 1)
return;
if (y == n - 1) {
count++;
return;
}
if (map[y][x] == 2)
slove(x, y + 2, 1);
else
for (int i = 0; i < 3; i++) {
slove(x + i - 1, y + 1, i);
}
}
int count;
int m;
int n;
int[][] map;
} | Main.java:6: error: package scala does not exist
import scala.inline;
^
Main.java:7: error: package scala does not exist
import scala.noinline;
^
2 errors
|
s320207554 | p00203 | Java | mport java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
/**
* A New Plan of Aizu Ski Resort
* PCK2009 ??????9
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
String[] words;
while ((line = br.readLine()) != null && !line.isEmpty()) {
int x, y;
x = parseInt(line.substring(0, line.indexOf(' ')));
y = parseInt(line.substring(line.indexOf(' ') + 1));
if ((x | y) == 0) break;
int[][] course = new int[y + 4][x + 2];
int[][] dp = new int[y + 4][x + 2];
for (int i = 0; i < y; i++) {
words = br.readLine().split(" ");
for (int j = 0; j < words.length; j++) {
course[i + 2][j + 1] = parseInt(words[j]);
}
}
//
for (int i = 1; i < x + 1; i++) {
if (course[2][i] == 0) dp[2][i] = 1;
}
for (int i = 2; i < y + 2; i++) {
for (int j = 1; j < x + 1; j++) {
switch (course[i][j]) {
case 0:
if (course[i - 1][j - 1] == 0) {
dp[i][j] += dp[i - 1][j - 1];
}
if (course[i - 1][j] == 0) {
dp[i][j] += dp[i - 1][j];
}
if (course[i - 1][j + 1] == 0) {
dp[i][j] += dp[i - 1][j + 1];
}
if (course[i - 2][j] == 2) {
dp[i][j] += dp[i - 2][j];
}
break;
case 1:
break;
case 2:
if (course[i - 1][j] == 0) {
dp[i][j] += dp[i - 1][j];
}
if (course[i - 2][j] == 2) {
dp[i][j] += dp[i - 2][j];
}
break;
}
}
}
for (int i = y + 2; i < y + 4; i++) {
for (int j = 1; j < x + 1; j++) {
if (course[i - 1][j] == 0) {
dp[i][j] += dp[i - 1][j];
}
if (course[i - 2][j] == 2) {
dp[i][j] += dp[i - 2][j];
}
}
}
//
int sum = 0;
for (int i = 1; i < x + 1; i++) sum += dp[y + 3][i];
System.out.println(sum);
}//end while
}//end main
} | Main.java:1: error: class, interface, enum, or record expected
mport java.io.BufferedReader;
^
Main.java:2: error: class, interface, enum, or record expected
import java.io.IOException;
^
Main.java:3: error: class, interface, enum, or record expected
import java.io.InputStreamReader;
^
Main.java:5: error: class, interface, enum, or record expected
import static java.lang.Integer.parseInt;
^
4 errors
|
s581467308 | p00203 | Java | import java.util.*;
public class Main {
Scanner sc;
int w,h;
int[][] map;
int[][] route;
void printMap(){
for(int i=0;i<h+2;i++) {
for(int j =0;j<w+2;j++) {
System.out.print(route[i][j] + " ");
}
System.out.print(" ");
for(int j =0;j<w+2;j++) {
System.out.print(map[i][j] + " ");
}
System.out.println();
}
System.out.println();
}
void run() {
sc = new Scanner(System.in);
while (true) {
w = sc.nextInt();
h = sc.nextInt();
if(w==0&&h==0) break;
map = new int[h+2][w+2];
route = new int[h+2][w+2];
for(int i=0;i<h;i++) for(int j=0;j<w+2;j++) { map[i][j] = 1; route[i][j] = 0; }
for(int i=h;i<h+2;i++)for(int j=0;j<w+2;j++) { map[i][j] = 0; route[i][j] = 0; }
for(int i=0;i<h;i++) for(int j=1;j<w+1;j++) map[i][j] = sc.nextInt();
for(int j=1;j<w+1;j++) if(map[0][j] != 1) route[0][j] = 1;
for(int i=0;i<h-1;i++) for(int j=1;j<w+1;j++){
// if(j==1)printMap();
if(map[i][j] == 0){
if(map[i+1][j-1] == 0) route[i+1][j-1] += route[i][j];
if(map[i+1][j] != 1) route[i+1][ j ] += route[i][j];
if(map[i+1][j+1] == 0) route[i+1][j+1] += route[i][j];
}
else if(map[i][j] == 2) {
if(map[i+2][j] != 1) route[i+2][ j ] += route[i][j];
}
}
int ans = 0;
for(int i=h-1;i<h+1;i++) for(int j=1;j<w+1;j++) {
ans += route[i][j];
}
System.out.println(ans);
}
}
public static void main(String[] args) {
new Main.run();
}
} | Main.java:54: error: cannot find symbol
new Main.run();
^
symbol: class run
location: class Main
1 error
|
s104353334 | p00203 | Java | import java.util.Scanner;
public class Main2 {
static int X,Y,ans;
static int[][] field;
static int[][] count;
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(true){
X=cin.nextInt();
Y=cin.nextInt();
ans=0;
if(X+Y==0){
break;
}
field = new int[Y+2][X+2];
count = new int[Y+2][X+2];
for(int i = 0;i<Y+2;i++){
for(int j = 0;j<X+2;j++){
field[i][j]=-1;
}
}
for(int i = 0;i<Y;i++){
for(int j = 1;j<X+1;j++){
field[i][j]=cin.nextInt();
}
}
for(int i = 1;i<X+1;i++){
count[0][i]=1;
}
for(int i = 0;i<Y-1;i++){
for(int j = 1;j<=X;j++){
if(field[i][j]==0){
if(field[i+1][j-1]!=2)
count[i+1][j-1]+=count[i][j];
count[i+1][j]+=count[i][j];
if(field[i+1][j+1]!=2)
count[i+1][j+1]+=count[i][j];
}
else if(field[i][j]==1){
count[i][j]=0;
}
else if(field[i][j]==2){
count[i+2][j]+=count[i][j];
}
}
}
for(int i = 1;i<=X;i++){
if(field[Y-1][i]!=1)
count[Y][i]+=count[Y-1][i];
}
for(int i = 0;i<Y+2;i++){
for(int j = 0;j<X+2;j++){
//System.out.print(count[i][j]+" " );
}
//System.out.println();
}
for(int i = 0;i<X;i++){
//System.out.println(count[Y][i+1]);
ans+=count[Y][i+1];
}
System.out.println(ans);
}
}
} | Main.java:3: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
^
1 error
|
s771443535 | p00203 | Java | import java.util.Scanner;
public class Main2 {
static int H,W;
static int[][] field;
static int[][] dp;
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
for(;;){
W=cin.nextInt();
H=cin.nextInt();
if(W+H==0)break;
field=new int[H+2][W];
dp=new int[H+2][W];
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
field[i][j]=cin.nextInt();
}
}
for(int i=0;i<W;i++){
if(field[0][i]==0)dp[0][i]=1;
}
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if(field[i][j]==0){
if(i!=H-1){
for(int k=-1;k<=1;k++){
if(j+k<0||j+k>=W)continue;
if(field[i+1][j+k]==1)continue;
if(k!=0&&field[i+1][j+k]==2)continue;
dp[i+1][j+k]+=dp[i][j];
}
}
else{
dp[i+1][j]+=dp[i][j];
}
}
else if(field[i][j]==2){
dp[i+2][j]+=dp[i][j];
}
}
}
int ans=0;
for(int i=H;i<H+2;i++){
for(int j=0;j<W;j++){
ans+=dp[i][j];
}
}
System.out.println(ans);
}
}
} | Main.java:3: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
^
1 error
|
s084307899 | p00203 | C | #include<iostream>
using namespace std;
int main(){
int x,y;
while(cin>>x>>y,x){
int D[16][16],P[16][16],ans=0;
for(int i=0;i<256;i++)P[i/16][i%16]=0;
for(int i=0;i<y;i++)for(int j=0;j<x;j++)cin>>D[i][j];
for(int i=0;i<x;i++)if(!D[0][i])P[0][i]=1;
for(int i=0;i<y-1;i++){
for(int j=0;j<x;j++){
if(!D[i][j]){
P[i+1][j]+=P[i][j];
if(j>0 && D[i + 1][j - 1] != 2)P[i+1][j-1]+=P[i][j];
if(j<x-1 && D[i + 1][j + 1] != 2)P[i+1][j+1]+=P[i][j];
}
if(D[i][j]==2){
// if(i+2>y-1)P[i+1][j]+=P[i][j];
P[i+2][j]+=P[i][j];
}
}
}
for(int i=0;i<x;i++)ans+=P[y-1][i];
cout<<ans<<endl;
}
}
| main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s243281635 | p00203 | C | #include<iostream>
using namespace std;
int main(){
int x,y;
while(cin>>x>>y,x){
int D[16][16],P[16][16],ans=0;
for(int i=0;i<256;i++)P[i/16][i%16]=0;
for(int i=0;i<y;i++)for(int j=0;j<x;j++)cin>>D[i][j];
for(int i=0;i<x;i++)if(!D[0][i])P[0][i]=1;
for(int i=0;i<y-1;i++){
for(int j=0;j<x;j++){
if(!D[i][j]){
if (D[i + 1][j] != 1) P[i+1][j]+=P[i][j];
if(j>0 && !D[i + 1][j - 1])P[i+1][j-1]+=P[i][j];
if(j<x-1 && !D[i + 1][j + 1])P[i+1][j+1]+=P[i][j];
}
if(D[i][j]==2){
if(i+2>y-1)P[i+1][j]+=P[i][j];
else P[i+2][j]+=P[i][j];
}
}
}
for(int i=0;i<x;i++)ans+=P[y-1][i];
cout<<ans<<endl;
}
}
| main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s218916988 | p00203 | C | #include<iostream>
using namespace std;
int main(){
int x,y;
while(cin>>x>>y,x){
int D[16][16],P[16][16],ans=0;
for(int i=0;i<256;i++)P[i/16][i%16]=0;
for(int i=0;i<y;i++)for(int j=0;j<x;j++)cin>>D[i][j];
for(int i=0;i<x;i++)if(!D[0][i])P[0][i]=1;
for(int i=0;i<y-1;i++){
for(int j=0;j<x;j++){
if(!D[i][j]){
P[i+1][j]+=P[i][j];
if(j>0&&!D[i+1][j-1])P[i+1][j-1]+=P[i][j];
if(j<x-1&&!D[i+1][j+1])P[i+1][j+1]+=P[i][j];
}
if(D[i][j]==2){
if(i==y-2) ans += P[i][j];
else P[i+2][j]+=P[i][j];
}
}
}
for(int i=0;i<x;i++){
if (D[y - 1][i] != 1)ans+=P[y-1][i];
}
cout<<ans<<endl;
}
}
| main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s411405185 | p00203 | C | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);} | main.c:1:1: error: return type defaults to 'int' [-Wimplicit-int]
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
| ^~~~
main.c: In function 'main':
main.c:1:8: error: 'ans' undeclared (first use in this function)
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
| ^~~
main.c:1:8: note: each undeclared identifier is reported only once for each function it appears in
main.c:1:13: error: 'num' undeclared (first use in this function)
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
| ^~~
main.c:1:26: error: 'w' undeclared (first use in this function)
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
| ^
main.c:1:29: error: 'h' undeclared (first use in this function)
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
| ^
main.c:1:32: error: 'i' undeclared (first use in this function)
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
| ^
main.c:1:35: error: 'j' undeclared (first use in this function)
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
| ^
main.c:1:38: error: 'map' undeclared (first use in this function)
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
| ^~~
main.c:1:60: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
main.c:1:60: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | main(){ans, num[15][15], w, h, i, j, map[15][15];while (1){scanf("%d%d", &w, &h);if (w + h == 0){break;}memset(map, -1, sizeof(map));for (i = 0; i < h; i++){for (j = 0; j < w; j++){scanf("%d", &map[i][j]);}}memset(num, 0, sizeof(num));for (i = 0; i < w; i++){if (map[0][i] != 1){num[0][i] = 1;}}for (i = 1; i < h; i++){for (j = 0; j < w; j++){if (j > 0 && map[i - 1][j - 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j - 1];}if (map[i - 1][j] == 0){num[i][j] += num[i - 1][j];}if (j < w - 1 && map[i - 1][j + 1] == 0 && map[i][j] != 2){num[i][j] += num[i - 1][j + 1];}if (i > 1 && map[i - 2][j] == 2){num[i][j] += num[i - 2][j];}}}ans = 0;for (j = 0; j < w; j++){if (map[h - 1][j] != 1){ans += num[h - 1][j];}if (h > 1 && map[h - 2][j] == 2){ans += num[h - 2][j];}}printf("%d\n", ans);}return (0);}
| |
s477048400 | p00203 | C | #include<stdio.h>
int dx[3] = {-1, 0, 1};
int dy[3] = {1, 1, 1};
int main(void)
{
int **map, f1, f2, f3, **temp, x, y, sum, px, py;
while(scanf("%d %d", &x, &y) && y > 0)
{
map = new int *[y];
temp = new int *[y];
sum = 0;
//マップ土地&動的計画作成
for(f1 = 0; f1 < y; f1++)
{
map[f1] = new int [x];
temp[f1] = new int [x];
}
//マップ構成入力&初期化
for(f1 = 0; f1 < y; f1++)
{
for(f2 = 0; f2 < x; f2++)
{
scanf("%d",&map[f1][f2]);
temp[f1][f2] = 0;
}
}
//最上のスタート地点設定
for(f1 = 0; f1 < x; f1++)
{
if(map[0][f1] != 1)
{
temp[0][f1] = 1;
sum++;
}
}
//探索
if(y >= 2)
{
sum = 0;
for(f1 = 0; f1 < y - 1; f1++)
{
for(f2 = 0; f2 < x; f2++)
{
if(map[f1][f2] == 0 && temp[f1][f2] > 0)
{
for(f3 = 0; f3 < 3; f3++)
{
//移動
px = f2 + dx[f3];
py = f1 + dy[f3];
//範囲内か
if(px >= 0 && px < x)
{
//同じx座標からのジャンプ台
if(f3 == 1 && py < y - 1){
//y軸2つ先へ
while(py < y - 1 && map[py][px] == 2)
py += 2;
}
//着地した場所がゴール地点のy座標と同じで障害物にぶつかってないか
//ゴール地点のy座標を超えたか
if(py > y - 1 || py == y - 1 && map[py][px] != 1)
sum += temp[f1][f2];
//超えてないが、障害物がない地点に着地したか
else if(map[py][px] == 0)
temp[py][px] += temp[f1][f2];
}
}
}
}
}
}
//出力
printf("%d\n",sum);
}
return 0;
} | main.c: In function 'main':
main.c:12:23: error: 'new' undeclared (first use in this function)
12 | map = new int *[y];
| ^~~
main.c:12:23: note: each undeclared identifier is reported only once for each function it appears in
main.c:12:26: error: expected ';' before 'int'
12 | map = new int *[y];
| ^~~~
| ;
main.c:13:27: error: expected ';' before 'int'
13 | temp = new int *[y];
| ^~~~
| ;
main.c:19:38: error: expected ';' before 'int'
19 | map[f1] = new int [x];
| ^~~~
| ;
main.c:20:39: error: expected ';' before 'int'
20 | temp[f1] = new int [x];
| ^~~~
| ;
|
s711211340 | p00203 | C | #include<stdio.h>
int dx[3] = {-1, 0, 1};
int dy[3] = {1, 1, 1};
int main(void)
{
int **map, f1, f2, f3, **temp, x, y, sum, px, py;
while(scanf("%d %d", &x, &y) && y > 0)
{
map = new int *[y];
temp = new int *[y];
sum = 0;
//マップ土地&動的計画作成
for(f1 = 0; f1 < y; f1++)
{
map[f1] = new int [x];
temp[f1] = new int [x];
}
//マップ構成入力&初期化
for(f1 = 0; f1 < y; f1++)
{
for(f2 = 0; f2 < x; f2++)
{
scanf("%d",&map[f1][f2]);
temp[f1][f2] = 0;
}
}
//最上のスタート地点設定
for(f1 = 0; f1 < x; f1++)
{
if(map[0][f1] != 1)
{
temp[0][f1] = 1;
sum++;
}
}
//探索
if(y >= 2)
{
sum = 0;
for(f1 = 0; f1 < y - 1; f1++)
{
for(f2 = 0; f2 < x; f2++)
{
if(map[f1][f2] == 0 && temp[f1][f2] > 0)
{
for(f3 = 0; f3 < 3; f3++)
{
//移動
px = f2 + dx[f3];
py = f1 + dy[f3];
//範囲内か
if(px >= 0 && px < x)
{
//同じx座標からのジャンプ台
if(f3 == 1 && py <= y - 1){
//y軸2つ先へ
while(py < y - 1 && map[py][px] == 2)
py += 2;
}
//着地した場所がゴール地点のy座標と同じで障害物にぶつかってないか
//ゴール地点のy座標を超えたか
if(py > y - 1 || py == y - 1 && map[py][px] != 1)
sum += temp[f1][f2];
//超えてないが、障害物がない地点に着地したか
else if(map[py][px] == 0)
temp[py][px] += temp[f1][f2];
}
}
}
}
}
}
//出力
printf("%d\n",sum);
}
return 0;
} | main.c: In function 'main':
main.c:12:23: error: 'new' undeclared (first use in this function)
12 | map = new int *[y];
| ^~~
main.c:12:23: note: each undeclared identifier is reported only once for each function it appears in
main.c:12:26: error: expected ';' before 'int'
12 | map = new int *[y];
| ^~~~
| ;
main.c:13:27: error: expected ';' before 'int'
13 | temp = new int *[y];
| ^~~~
| ;
main.c:19:38: error: expected ';' before 'int'
19 | map[f1] = new int [x];
| ^~~~
| ;
main.c:20:39: error: expected ';' before 'int'
20 | temp[f1] = new int [x];
| ^~~~
| ;
|
s170783991 | p00203 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int maps[20][20];
int course[20][20];
int X, Y;
void out();
int way(int y, int x){
else if(course[y][x] > 0) return course[y][x];
else if(maps[y][x] == 1) return 0;
else if(y >= Y) return 1;
else if(maps[y][x] == 2 && maps[y + 2][x] != 1) return course[y][x] = way(y + 2, x);
else{
int SUM = 0;
for(int i = 0; i < 3; i++){
int ny = y + 1;
int nx = x - 1 + i;
if(maps[ny][nx] != 1 && 1 <= nx && nx <= X){
int flug = 1;
if(i != 1 && maps[ny][nx] == 2) flug = 0;
if(flug) SUM += way(ny, nx);
}
}
return course[y][x] = SUM;
}
}
int main(){
while(1){
cin >> X >> Y;
if(X == 0 && Y == 0) break;
for(int i = 1; i <= Y; i++){
for(int j = 1; j <= X; j++){
cin >> maps[i][j];
course[i][j] = 0;
}
}
int cnt = 0;
for(int i = 1; i <= X; i++){
if(maps[0][i] != 1) cnt += way(1, i);
}
cout << cnt << endl;
}
} | a.cc: In function 'int way(int, int)':
a.cc:11:3: error: 'else' without a previous 'if'
11 | else if(course[y][x] > 0) return course[y][x];
| ^~~~
|
s368002811 | p00203 | C++ | #include<algorithm>
using namespace std;
int maps[20][20];
int course[20][20];
int X, Y;
int way(int y, int x){
if(course[y][x] > 0) return course[y][x];
else if(maps[y][x] == 1) return 0;
else if(y >= Y) return 1;
else if(maps[y][x] == 2 && maps[y + 2][x] != 1) return course[y][x] = way(y + 2, x);
else{
int SUM = 0;
for(int i = 0; i < 3; i++){
int ny = y + 1;
int nx = x - 1 + i;
if(maps[ny][nx] != 1 && 1 <= nx && nx <= X){
int flug = 1;
if(i != 1 && maps[ny][nx] == 2) flug = 0;
if(flug) SUM += way(ny, nx);
}
}
return course[y][x] = SUM;
}
}
int main(){
while(1){
cin >> X >> Y;
if(X == 0 && Y == 0) break;
for(int i = 1; i <= Y; i++){
for(int j = 1; j <= X; j++){
cin >> maps[i][j];
course[i][j] = 0;
}
}
int cnt = 0;
for(int i = 1; i <= X; i++){
if(maps[0][i] != 1) cnt += way(1, i);
}
cout << cnt << endl;
}
} | a.cc: In function 'int main()':
a.cc:30:5: error: 'cin' was not declared in this scope
30 | cin >> X >> Y;
| ^~~
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:42:5: error: 'cout' was not declared in this scope
42 | cout << cnt << endl;
| ^~~~
a.cc:42:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:42:20: error: 'endl' was not declared in this scope
42 | cout << cnt << 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;
|
s608654069 | p00203 | C++ | #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
using namespace std;
typedef pair<int,int> P;
const int INF = ~(1<<31) / 2;
int field[15][15];
int dp[15][15];
int main(){
while(1){
int X,Y;
scanf("%d %d",&X,&Y);
if(X==0)break;
for(int i=0;i<Y;i++){
for(int j=0;j<X;j++){
scanf("%d",&field[i][j]);
}
}
for(int j=0;j<X;j++){
dp[Y-1][j] = field[Y-1][j] == 1 ? 0 : 1;
}
for(int i=Y-2;i>=0;i--){
for(int j=0;j<X;j++){
if(field[i][j]==1){
dp[i][j] = 0;
}else if(field[i][j]==2){
dp[i][j] = i+2<Y ? dp[i+2][j] : 1;
}else{
dp[i][j] = 0;
if(j-1>=0 && field[i+1][j-1]==0){
dp[i][j] += dp[i+1][j-1];
}
if(j+1<X && field[i+1][j+1]==0){
dp[i][j] += dp[i+1][j+1];
}
if(field[i+1][j]!=1){
dp[i][j] += dp[i+1][j];
}
}
}
}
int ans = 0;
for(int j=0;j<X;j++){
ans += dp[0][j];
}
printf("%d\n",ans);
}
return 0;
}
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
using namespace std;
typedef pair<int,int> P;
const int INF = ~(1<<31) / 2;
int field[15][15];
int dp[15][15];
int main(){
while(1){
int X,Y;
scanf("%d %d",&X,&Y);
if(X==0)break;
for(int i=0;i<Y;i++){
for(int j=0;j<X;j++){
scanf("%d",&field[i][j]);
}
}
for(int j=0;j<X;j++){
dp[Y-1][j] = field[Y-1][j] == 1 ? 0 : 1;
}
for(int i=Y-2;i>=0;i--){
for(int j=0;j<X;j++){
if(field[i][j]==1){
dp[i][j] = 0;
}else if(field[i][j]==2){
dp[i][j] = i+2<Y ? dp[i+2][j] : 1;
}else{
dp[i][j] = 0;
if(j-1>=0 && field[i+1][j-1]==0){
dp[i][j] += dp[i+1][j-1];
}
if(j+1<X && field[i+1][j+1]==0){
dp[i][j] += dp[i+1][j+1];
}
if(field[i+1][j]!=1){
dp[i][j] += dp[i+1][j];
}
}
}
}
int ans = 0;
for(int j=0;j<X;j++){
ans += dp[0][j];
}
printf("%d\n",ans);
}
return 0;
} | a.cc:80:11: error: redefinition of 'const int INF'
80 | const int INF = ~(1<<31) / 2;
| ^~~
a.cc:16:11: note: 'const int INF' previously defined here
16 | const int INF = ~(1<<31) / 2;
| ^~~
a.cc:82:5: error: redefinition of 'int field [15][15]'
82 | int field[15][15];
| ^~~~~
a.cc:18:5: note: 'int field [15][15]' previously declared here
18 | int field[15][15];
| ^~~~~
a.cc:83:5: error: redefinition of 'int dp [15][15]'
83 | int dp[15][15];
| ^~
a.cc:19:5: note: 'int dp [15][15]' previously declared here
19 | int dp[15][15];
| ^~
a.cc:85:5: error: redefinition of 'int main()'
85 | int main(){
| ^~~~
a.cc:21:5: note: 'int main()' previously defined here
21 | int main(){
| ^~~~
|
s846308189 | p00203 | C++ | #include<iostream>
??
using namespace std;
??
int main() {
????????int x, y;
????????int skimap[15][15] = {};//x = j y = i
????????int dp[15][15] = {};//x = j y = i
????????while (cin >> x >> y, x * y) {//
????????????????int flyover = 0;
????????????????for (int i = 0; i < y; i++) {
????????????????????????for (int j = 0; j < x; j++) {
????????????????????????????????cin >> skimap[i][j];
????????????????????????}
????????????????}
????????????????for(int i = 0; i < x;i++){
????????????????????????if (skimap[0][i] == 0)dp[0][i] = 1;
????????????????}
????????????????for (int i = 0; i < y - 1; i++) {
????????????????????????for (int j = 0; j < x; j++) {
????????????????????????????????if (skimap[i][j] == 0) {
????????????????????????????????????????if (j - 1 >= 0) {
????????????????????????????????????????????????if (skimap[i + 1][j - 1] == 0) {
????????????????????????????????????????????????????????dp[i + 1][j - 1] += dp[i][j];
????????????????????????????????????????????????}
????????????????????????????????????????}
????????????????????????????????????????if (skimap[i + 1][j] != 1)dp[i + 1][j] += dp[i][j];
????????????????????????????????????????if (j + 1 < x) {
????????????????????????????????????????????????if (skimap[i + 1][j + 1] == 0) {
????????????????????????????????????????????????????????dp[i + 1][j + 1] += dp[i][j];
????????????????????????????????????????????????}
????????????????????????????????????????}
????????????????????????????????}
????????????????????????????????else if (skimap[i][j] == 1) {
????????????????????????????????????????continue;
????????????????????????????????}else {
????????????????????????????????????????if (i + 2 < y) {
????????????????????????????????????????????????dp[i + 2][j] = dp[i][j];
????????????????????????????????????????}else {
????????????????????????????????????????????????flyover += dp[i][j];
????????????????????????????????????????}
????????????????????????????????}
????????????????????????}
????????????????}
????????????????int sum = flyover;
????????????????for (int i = 0; i < x; i++) {
????????????????????????sum += dp[y - 1][i];
????????????????}
????????????????cout << sum << endl;
for (int i = 0; i < y; i++){
for(int j = 0; j < x; j++){
dp[i][j] = 0;
skimap[i][j] = 0;
}
}
????????}
????????return 0;
} | a.cc:2:1: error: expected unqualified-id before '?' token
2 | ??
| ^
a.cc:4:1: error: expected unqualified-id before '?' token
4 | ??
| ^
|
s976910112 | p00203 | C++ | 5 5
0 0 0 0 1
2 1 0 2 0
1 0 0 1 1
0 2 1 2 0
0 1 0 0 0
5 5
0 0 1 0 0
2 1 0 2 0
1 0 0 1 1
0 2 1 2 0
0 1 0 0 0
15 15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 08
6
52694573
bash-4.3(luke):~/syoribu/AOJ/PCK
512:{ei1629}$ cat AOJ203.cpp
#include <bits/stdc++.h>
using namespace std;
int main()
{
int W, H;
while ( cin >> W >> H, W || H ) {
int dp[22][22] = {};
int mas[22][22] = {};
for ( int i = 0; i < H; i++ ) {
for ( int j = 0; j < W; j++ ) {
cin >> mas[i][j];
}
}
for ( int i = 0; i < W; i++ ) {
if ( mas[0][i] == 0 ) {
dp[0][i] = 1;
}
}
for ( int i = 0; i < H - 1; i++ ) {
for ( int j = 0; j < W; j++ ) {
if ( mas[i][j] == 2 ) {
if ( mas[i + 2][j] != 1 ) {
dp[i + 2][j] += dp[i][j];
}
} else {
for ( int k = -1; k <= 1; k++ ) {
if ( 0 <= j + k && j + k < W ) {
if ( mas[i + 1][j + k] == 0 ) {
dp[i + 1][j + k] += dp[i][j];
} else if ( k == 0 && mas[i + 1][j] == 2 ) {
dp[i + 1][j] += dp[i][j];
}
}
}
}
}
}
int sum = 0;
for ( int i = 0; i < W; i++ ) {
sum += dp[H - 1][i] + dp[H][i];
}
cout << sum << endl;
}
return ( 0 );
}
| a.cc:29:3: error: invalid digit "8" in octal constant
29 | 0 08
| ^~
a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 5 5
| ^
a.cc:34:13: error: '$' does not name a type
34 | 512:{ei1629}$ cat AOJ203.cpp
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:35:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
from /usr/include/c++/14/bits/stl_algo.h:69,
from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c+ |
s052243213 | p00203 | C++ | #include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int main(){
int n,m;
int masu[17][17];
int ura[17][17];
while(1){
scanf("%d%d",&n,&m);
if(n==0 && m==0){
break;
}
for(int i=0;i<17;i++){
for(int j=0;j<17;j++){
masu[i][j]=0;
ura[i][j]=0;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
scanf("%d",&ura[i][j]);
}
}
for(int i=1;i<=n;i++){
switch(ura[1][i]){
case 0:masu[1][i]+=1;break;
case 1:masu[1][i]+=0;break;
case 2:if(ura[2][i]==0){masu[2][i]+=1};break;
}
}
for(int i=1;i<n;i++){
for(int j=1;j<=m;j++){
if(ura[i][j]==0){
if(ura[i+1][j-1]==0){
masu[i+1][j-1]+=masu[i][j];
}
if(ura[i+1][j]!=1){
masu[i+1][j]+=masu[i][j];
}
if(ura[i+1][j+1]==0){
masu[i+1][j+1]+=masu[i][j];
}
}else if(ura[i][j]==2){
if(ura[i+2][j]!=1){
masu[i+2][j]+=masu[i][j];
}
}
}
}
int cont=0;
for(int i=n;i<=n+1;i++){
for(int j=1;j<=m;j++){
cont+=masu[i][j];
}
}
printf("%d\n",cont);
}
} | a.cc: In function 'int main()':
a.cc:34:70: error: expected ';' before '}' token
34 | case 2:if(ura[2][i]==0){masu[2][i]+=1};break;
| ^
| ;
|
s270088512 | p00203 | C++ | #include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int n,m;
int masu[17][17];
int ura[17][17];
int motom(){
for(int i=0;i<17;i++){
for(int j=0;j<17;j++){
masu[i][j]=0;
}
}
for(int i=1;i<=m;i++){
switch(ura[1][i]){
case 0:masu[1][i]+=1;break;
case 1:masu[1][i]+=0;break;
case 2:masu[1][i]+=1;break;
}
}
for(int i=1;i<n;i++){
for(int j=1;j<=m;j++){
if(ura[i][j]==0){
if(ura[i+1][j-1]==0){
masu[i+1][j-1]+=masu[i][j];
}
if(ura[i+1][j]!=1){
masu[i+1][j]+=masu[i][j];
}
if(ura[i+1][j+1]==0){
masu[i+1][j+1]+=masu[i][j];
}
}else if(ura[i][j]==2){
if(ura[i+2][j]!=1){
masu[i+2][j]+=masu[i][j];
}
}
}
}
int cont=0;
for(int i=n;i<=n+1;i++){
for(int j=1;j<=m;j++){
cont+=masu[i][j];
}
}
return cont;
}
int main(){
srand(time(NULL));
int cc=0;
while(1){
scanf("%d%d",&n,&m);
if(n==0 && m==0){
break;
}
for(int i=0;i<17;i++){
for(int j=0;j<17;j++){
masu[i][j]=0;
ura[i][j]=0;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
scanf("%d",&ura[i][j]);
}
}
printf("%d\n",motom());
}
}#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int n,m;
int masu[17][17];
int ura[17][17];
int motom(){
for(int i=0;i<17;i++){
for(int j=0;j<17;j++){
masu[i][j]=0;
}
}
for(int i=1;i<=m;i++){
switch(ura[1][i]){
case 0:masu[1][i]+=1;break;
case 1:masu[1][i]+=0;break;
case 2:masu[1][i]+=1;break;
}
}
for(int i=1;i<n;i++){
for(int j=1;j<=m;j++){
if(ura[i][j]==0){
if(ura[i+1][j-1]==0){
masu[i+1][j-1]+=masu[i][j];
}
if(ura[i+1][j]!=1){
masu[i+1][j]+=masu[i][j];
}
if(ura[i+1][j+1]==0){
masu[i+1][j+1]+=masu[i][j];
}
}else if(ura[i][j]==2){
if(ura[i+2][j]!=1){
masu[i+2][j]+=masu[i][j];
}
}
}
}
int cont=0;
for(int i=n;i<=n+1;i++){
for(int j=1;j<=m;j++){
cont+=masu[i][j];
}
}
return cont;
}
int contt;
void saiki(int x,int y){
if(y<1||y>m){
return;
}
masu[x][y]++;
if(x>n-1){
contt++;
return;
}
if(ura[x][y]==0){
if(ura[x+1][y-1]==0){
saiki(x+1,y-1);
}
if(ura[x+1][y]!=1){
saiki(x+1,y);
}
if(ura[x+1][y+1]==0){
saiki(x+1,y+1);
}
}
if(ura[x][y]==2){
if(ura[x+2][y]!=1){
saiki(x+2,y);
}
}
}
int simu(){
for(int i=0;i<17;i++){
for(int j=0;j<17;j++){
masu[i][j]=0;
}
}
contt=0;
for(int i=1;i<=m;i++){
if(ura[1][i]!=1){
saiki(1,i);
}
}
/*
puts("");
for(int i=1;i<=n+1;i++){
for(int j=1;j<=m;j++){
printf("%d ",masu[i][j]);
}
puts("");
}*/
return contt;
}
int main(){
srand(time(NULL));
int cc=0;
while(1){
scanf("%d%d",&n,&m);
if(n==0 && m==0){
break;
}
for(int i=0;i<17;i++){
for(int j=0;j<17;j++){
masu[i][j]=0;
ura[i][j]=0;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
scanf("%d",&ura[i][j]);
}
}
int aa=motom();
printf("%d\n",aa);
}
} | a.cc:80:2: error: stray '#' in program
80 | }#include<cstdio>
| ^
a.cc:80:3: error: 'include' does not name a type
80 | }#include<cstdio>
| ^~~~~~~
a.cc:90:13: error: redefinition of 'int n'
90 | int n,m;
| ^
a.cc:11:13: note: 'int n' previously declared here
11 | int n,m;
| ^
a.cc:90:15: error: redefinition of 'int m'
90 | int n,m;
| ^
a.cc:11:15: note: 'int m' previously declared here
11 | int n,m;
| ^
a.cc:91:13: error: redefinition of 'int masu [17][17]'
91 | int masu[17][17];
| ^~~~
a.cc:12:13: note: 'int masu [17][17]' previously declared here
12 | int masu[17][17];
| ^~~~
a.cc:92:13: error: redefinition of 'int ura [17][17]'
92 | int ura[17][17];
| ^~~
a.cc:13:13: note: 'int ura [17][17]' previously declared here
13 | int ura[17][17];
| ^~~
a.cc:94:5: error: redefinition of 'int motom()'
94 | int motom(){
| ^~~~~
a.cc:15:5: note: 'int motom()' previously defined here
15 | int motom(){
| ^~~~~
a.cc:186:5: error: redefinition of 'int main()'
186 | int main(){
| ^~~~
a.cc:57:5: note: 'int main()' previously defined here
57 | int main(){
| ^~~~
|
s509758791 | p00203 | C++ | #include<iostream>
using namespace std;
int main(){
int n,m;
int masu[17][17];
int ura[17][17];
cin>>n>>m;
for(int i=0;i<17;i++){
for(int j=0;j<17;j++){
masu[i][j]=ura[i][j]=0;
}
}
for(int i=0;i<n;i++){
for(int j=1;j<=m;j++){
cin>>masu[i][j];
}
}
for(int j=1;j<=m;j++){
if(masu[i][j]!=1){
ura[0][j]=1;
}
}
for(int i=0;i<n-1;i++){
for(int j=1;j<=m;j++){
if(masu[i][j]==0){
if(masu[i+1][j-1]==0){
ura[i+1][j-1]+=ura[i][j];
}
if(masu[i+1][j]!=1){
ura[i+1][j]+=ura[i][j];
}
if(masu[i+1][j+1]==0){
ura[i+1][j+1]+=ura[i][j];
}
}
if(masu[i][j]==2){
if(masu[i+2][j]!=1){
ura[i+2][j]+=ura[i][j];
}
}
}
}
int cont=0;
for(int i=1;i<=m;i++){
cont+=ura[n][i]+ura[n-1][i];
}
/*
for(int i=0;i<17;i++){
for(int j=0;j<17;j++){
printf("%2d ",ura[i][j]);
}
puts("");
}*/
printf("%d\n",cont);
} | a.cc: In function 'int main()':
a.cc:23:25: error: 'i' was not declared in this scope
23 | if(masu[i][j]!=1){
| ^
|
s256733642 | p00203 | C++ | 5 5
0 0 0 0 1
2 1 0 2 0
1 0 0 1 1
0 2 1 2 0
0 1 0 0 0
5 5
0 0 1 0 0
2 1 0 2 0
1 0 0 1 1
0 2 1 2 0
0 1 0 0 0
15 15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 5 5
| ^
|
s321206808 | p00203 | C++ | #include<iostream>
using namespace std;
int DP[17][17];
int field[17][17];
int x,y;
int main(){
while(true){
cin >> x >> y;
if(!x && !y)
return 0;
for(int i=1; i<=y; i++)
for(int k=1; k<=x; k++)
cin >> field[i][k];
for(int i=1; i<=x; i++)
field[y+1][i] = 0;
for(int i=1; i<=y+1; i++)
for(int k=0; k<=x+1; k++){
DP[i][k]=0;
if(i==1 && k>0 && k<=x)
if(field[i][k] == 0)
DP[i][k] = 1;
}
for(int i=2; i<=y; i++){
for(int k=1; k<=x; k++){
if(field[i][k] == 0)
DP[i][k] += DP[i-1][k-1] + DP[i-1][k] + DP[i-1][k+1];
else if(field[i][k] == 2)
int n = i+2;
while(true){
if(field[n][k] == 0){
DP[n][k] += DP[i-1][k];
break;
}else if(field[n][k] == 1)
break;
else
n+=2;
}
}
}
}
int ans=0;
for(int i=y; i<=y+1; i++)
for(int k=1; k<=x; k++)
ans += DP[i][k];
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:35:58: error: 'n' was not declared in this scope
35 | if(field[n][k] == 0){
| ^
a.cc: At global scope:
a.cc:53:1: error: expected declaration before '}' token
53 | }
| ^
|
s406123283 | p00203 | C++ | #include<iostream>
using namespace std;
int DP[17][17];
int field[17][17];
int x,y;
int main(){
while(true){
cin >> x >> y;
if(!x && !y)
return 0;
for(int i=1; i<=y; i++)
for(int k=1; k<=x; k++)
cin >> field[i][k];
for(int i=1; i<=x; i++)
field[y+1][i] = 0;
for(int i=1; i<=y+1; i++)
for(int k=0; k<=x+1; k++){
DP[i][k]=0;
if(i==1 && k>0 && k<=x)
if(field[i][k] == 0)
DP[i][k] = 1;
}
for(int i=2; i<=y; i++){
for(int k=1; k<=x; k++){
if(field[i][k] == 0)
DP[i][k] += DP[i-1][k-1] + DP[i-1][k] + DP[i-1][k+1];
else if(field[i][k] == 2)
int n = i+2;
while(true){
if(field[n][k] == 0){
DP[n][k] += DP[i-1][k];
break;
}else if(field[n][k] == 1)
break;
else
n+=2;
}
}
}
}
int ans=0;
for(int i=y; i<=y+1; i++)
for(int k=1; k<=x; k++)
ans += DP[i][k];
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:35:58: error: 'n' was not declared in this scope
35 | if(field[n][k] == 0){
| ^
a.cc: At global scope:
a.cc:53:1: error: expected declaration before '}' token
53 | }
| ^
|
s816961985 | p00203 | C++ | #include<iostream>
using namespace std;
int DP[17][17];
int field[17][17];
int x,y;
int main(){
while(true){
cin >> x >> y;
if(!x && !y)
return 0;
for(int i=1; i<=y; i++)
for(int k=1; k<=x; k++)
cin >> field[i][k];
for(int i=1; i<=x; i++)
field[y+1][i] = 0;
for(int i=1; i<=y+1; i++)
for(int k=0; k<=x+1; k++){
DP[i][k]=0;
if(i==1 && k>0 && k<=x)
if(field[i][k] == 0)
DP[i][k] = 1;
}
for(int i=2; i<=y; i++){
for(int k=1; k<=x; k++){
if(field[i][k] == 0)
DP[i][k] += DP[i-1][k-1] + DP[i-1][k] + DP[i-1][k+1];
else if(field[i][k] == 2)
int n = i+2;
while(true){
if(field[n][k] == 0){
DP[n][k] += DP[i-1][k];
break;
}else if(field[n][k] == 1)
break;
else
n+=2;
}
}
}
}
int ans=0;
for(int i=y; i<=y+1; i++)
for(int k=1; k<=x; k++)
ans += DP[i][k];
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:35:58: error: 'n' was not declared in this scope
35 | if(field[n][k] == 0){
| ^
a.cc: At global scope:
a.cc:53:1: error: expected declaration before '}' token
53 | }
| ^
|
s240787724 | p00203 | C++ | #include <iostream>
using namespace std;
void solve(int f[20][20] , w , h ){
int dp[20][20] = {0};
for(int x=1 ; x <= w ; x++ ){
dp[1][x] = 1;
}
for(int y=1 ; y <= h-1 ; y++ ){
for(int x=1 ; x <= w ; x++ ){
if( f[y][x] == 0 ){
if( f[y+1][x-1] == 0 ) dp[y+1][x-1] += dp[y][x];
if( f[y+1][x] == 0 ) dp[y+1][x] += dp[y][x];
if( f[y+1][x+1] == 0 ) dp[y+1][x+1] += dp[y][x];
if( f[y+1][x] == 2 ) dp[y+1][x] += dp[y][x];
}else if( f[y][x] == 2 ){
if( f[y+2][x] == 0 || f[y+2][x] == 2 ){
dp[y+2][x] += dp[y][x];
}
}
}
}
int ans = 0;
for(int x=1 ; x <= w ; x++ ){
ans += dp[h][x] + dp[h+1][x];
}
return ans;
}
int main(){
int w,h;
while( cin >> w >> h , w||h ){
int f[20][20] = {0};
for(int y=1 ; y <= h ; y++ ){
for(int x=1 ; x <= w ; x++ ){
cin >> f[y][x];
}
}
int ans = solve( f , w , h );
cout << ans << endl;
}
} | a.cc:4:28: error: 'w' has not been declared
4 | void solve(int f[20][20] , w , h ){
| ^
a.cc:4:32: error: 'h' has not been declared
4 | void solve(int f[20][20] , w , h ){
| ^
a.cc: In function 'void solve(int (*)[20], int, int)':
a.cc:6:24: error: 'w' was not declared in this scope
6 | for(int x=1 ; x <= w ; x++ ){
| ^
a.cc:10:24: error: 'h' was not declared in this scope
10 | for(int y=1 ; y <= h-1 ; y++ ){
| ^
a.cc:11:28: error: 'w' was not declared in this scope
11 | for(int x=1 ; x <= w ; x++ ){
| ^
a.cc:25:24: error: 'w' was not declared in this scope
25 | for(int x=1 ; x <= w ; x++ ){
| ^
a.cc:26:19: error: 'h' was not declared in this scope
26 | ans += dp[h][x] + dp[h+1][x];
| ^
a.cc:28:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
28 | return ans;
| ^~~
a.cc: In function 'int main()':
a.cc:42:24: error: void value not ignored as it ought to be
42 | int ans = solve( f , w , h );
| ~~~~~^~~~~~~~~~~~~
|
s159833178 | p00203 | C++ | #include<iostream>
using namespace std;
int w,h;
int s[40][40];
int dp[40][40];
int dx[]={-1,0,1};
int ret(int y,int x){
if(y>=h-1){
if(h-1==y&&s[y][x]==1)
return 0;
return 1;
}
if(dp[y][x]!=-1)
return dp[y][x];
if(s[y][x]==1)
return dp[y][x]=0;
if(s[y][x]==2){
return dp[y][x]=ret(y+2,x);
}
int ans=0;
for(int i=0;i<3;i++){
int nx=dx[i]+x;
if(nx>=w||nx<0)
continue;
if(s[y+1][nx]==0){
ans+=ret(y+1,nx);
}else if(s[y+1][nx]==2){
if(i!=1)
continue;
ans+=ret(y+1,nx);
}
}
return dp[y][x]=ans;
}
int main(){
while(cin>>w>>h,w||h){
memset(dp,-1,sizeof(dp));
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
cin>>s[i][j];
int ans=0;
for(int i=0;i<w;i++){
//if(s[0][i]==0)
ans+=ret(0,i);
}
cout<<dp[3][0]<<endl;
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:38:17: error: 'memset' was not declared in this scope
38 | memset(dp,-1,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;
|
s969300233 | p00203 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
int x,y;
int fie[20][20];
long long int dp[20][20];
long long int ans=0;
int main(void){
while(1){
scanf("%d%d",&x,&y);
if(x==0 && y==0)break;
memset(fie,0,sizeof(fie));
memset(dp,0,sizeof(dp));
ans=0;
for(int i=0;i<y;i++){
for(int j=0;j<x;j++){
scanf("%d",&fie[j][i]);
}
}
for(int i=0;i<x;i++){
if(fie[i][0]==0)dp[i][0]=1;
if(fie[i][0]==2)dp[i][2]=1;
}
for(int i=0;i<y;i++){
for(int j=0;j<x;j++){
if(fie[j][i]==0){
for(int k=j-1;k<=j+1;k++){
if(k>=0 && k<x){
if(fie[k][i+1]==0){
dp[k][i+1]+=dp[j][i];
}
if(fie[k][i+1]==2 && k==j){
dp[k][i+1]+=dp[j][i];
}
}
}
}
if(fie[j][i]==2){
dp[j][i+2]+=dp[j][i];
}
}
}
for(int i=0;i<y;i++){
for(int j=0;j<x;j++){
if(i>=y-2 && fie[j][i]==2)ans+=dp[j][i];
if(i==y-1 && fie[j][i]==0)ans+=dp[j][i];
}
}
printf("%lld\n",ans);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:17: error: 'memset' was not declared in this scope
15 | memset(fie,0,sizeof(fie));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<cstdio>
+++ |+#include <cstring>
3 |
|
s978389623 | p00203 | C++ | #include<iostream>
using namespace std;
int X, Y;
int status[17][18]; //status[x][y]
int memo[17][18];
int i, j;
int count;
int check(int x, int y);
int main(){
while(1){
count = 0;
cin >> X >> Y;
if(X == 0 && Y == 0){break;}
else{
//フィールドの入力
//i行目について( 1 <= i <= Y+2 )
for(i = 1; i <= Y+2; i++){
//j文字目について( 0 <= j <= X+1)
for(j = 0; j <= X+1; j++){
//Y+1, Y+2列目に移動できるようにする。
if(i > Y){
status[j][i] = 0;
}
//両サイドには障害物を敷き詰める。
else if(j == 0 || j == X+1){
status[j][i] = 1;
}
else{
cin >> status[j][i];
}
}
}
/*//フィールド出力
for(i = 1; i <= Y+2; i++){
for(j = 0; j <= X+1; j++){
cout << status[j][i];
}
cout << endl;
}
*/
for(i = 1; i <= X; i++){
memset(memo, 0, sizeof(memo));
count += check(i, 1);
}
cout << count << endl;
}
}
return 0;
}
int check(int x, int y){
// cout << "x:" << x << "y:" << y << " : "<< status[x][y] << endl;
//関数のメモが残っているならメモを返す
if(memo[x][y] > 0){return memo[x][y];}
//status[x][y]の次でゴール
if(status[x][y] == 1){return 0;}
if(status[x][y] == 0 && y == Y){return 1;}
if(status[x][y] == 2 && (y == Y-1 || y == Y)){return 1;}
//それ以外
else{
//ジャンプ台
if(status[x][y] == 2){
memo[x][y] += check(x, y+2);
}
//平地
else{
if(status[x-1][y+1] == 0){
memo[x][y] += check(x-1, y+1);
}
if(status[x][y+1] == 0 || status[x][y+1] == 2){
memo[x][y] += check(x, y+1);
}
if(status[x+1][y+1] == 0){
memo[x][y] += check(x+1, y+1);
}
}
return memo[x][y];
}
} | a.cc: In function 'int main()':
a.cc:55:33: error: 'memset' was not declared in this scope
55 | memset(memo, 0, sizeof(memo));
| ^~~~~~
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 |
|
s535652424 | p00203 | C++ | #include <iostream>
using namespace std;
int w,h;
int map[16][16];
int dp[16][16][4][2];
int rec(int x,int y,int state,bool str){
if(state == 1 || x < 0 || x >= w) return 0;
if(state == 2 && !str) return 0;
if(y >= h-1) return 1;
if(dp[y][x][state][str] != -1) return dp[y][x][state][str];
int res;
if(state == 2) res = rec(x,y+2,map[y+2][x],true);
else res = (rec(x-1,y+1,map[y+1][x-1],false) + rec(x,y+1,map[y+1][x],true) + rec(x+1,y+1,map[y+1][x+1],false));
return dp[y][x][state][str] = res;
}
int main(){
while(cin >> w >> h,w||h){
memset(dp,-1,sizeof(dp));
for(int i=0;i<h;i++){
for(int j=0;j<w;j++) cin >> map[i][j];
}
int d = 0;
for(int i=0;i<w;i++) d += rec(i,0,map[0][i],true);
cout << d << endl;
}
} | a.cc: In function 'int main()':
a.cc:21:9: error: 'memset' was not declared in this scope
21 | memset(dp,-1,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;
|
s044838995 | p00204 | C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define PIE atan(1.0)*4
typedef struct nd{
int id;
//
int x, y;
int r;
int v;
//
double polar_r;
double polar_t;
//
int state; // 0:接近中,1:撃破, 2:到達
struct nd *next;
struct nd *prev;
bool dummy;
} node;
void initList(node **top, int num) {
// 極座標変換
for (int i = 0; i < num; i++) {
top[i]->polar_r = sqrt((double)(top[i]->x*top[i]->x + top[i]->y*top[i]->y));
top[i]->polar_t = acos((double)top[i]->x / top[i]->polar_r);
if (top[i]->y < 0)
top[i]->polar_t = 2*PIE-top[i]->polar_t;
top[i]->prev = i!=0 ? top[i - 1] : NULL;
top[i]->next = i!=num-1 ? top[i + 1] : NULL;
top[i]->dummy = false;
}
}
node *removeNode(node *target) {
node *next = target->next;
target->next->prev = target->prev;
target->prev->next = target->next;
free(target);
return next;
}
void removeNodes(node *begin) {
node *temp = begin->next;
while (temp->next != NULL) {
if (temp->state != 0)
temp = removeNode(temp);
else
temp = temp->next;
}
}
int main(int argc, char* argv[]) {
while (true) {
// データ読み込み
int invaridR, ufoNum;
scanf_s("%d %d", &invaridR, &ufoNum);
if (invaridR == 0 && ufoNum == 0) break;
node **ufos = (node**)malloc(sizeof(node*)*ufoNum);
for (int i = 0; i < ufoNum; i++) {
ufos[i] = (node*)malloc(sizeof(node));
ufos[i]->id = i;
scanf_s("%d %d %d %d", &(ufos[i]->x), &(ufos[i]->y), &(ufos[i]->r), &(ufos[i]->v));
ufos[i]->next = ufos[i]->prev = NULL;
ufos[i]->state = 0;
}
initList(ufos, ufoNum);
node *begin = (node*)malloc(sizeof(node));
begin->dummy = true;
begin->id = -1;
begin->prev = NULL;
begin->next = ufos[0];
ufos[0]->prev = begin;
node *end = (node*)malloc(sizeof(node));
end->dummy = true;
end->id = -2;
end->next = NULL;
end->prev = ufos[ufoNum - 1];
ufos[ufoNum - 1]->next = end;
// 計算
int t = 0;
int count = 0;
while (begin->next != end) {
// 位置&時刻更新
t++;
for (int i = 0; i < ufoNum; i++) {
ufos[i]->polar_r -= ufos[i]->v;
}
// 照射方向決定
double minR = 1500;
double fireT = 0;
for (node *temp = begin->next; temp != end; temp = temp->next) {
if (temp->polar_r < minR && temp->polar_r>invaridR) {
minR = temp->polar_r;
fireT = temp->polar_t;
}
}
// 照射
for (node *temp = begin->next; temp != end; temp = temp->next) {
double dt = fireT - temp->polar_t;
if (dt > 2 * PIE) dt -= 2 * PIE;
if (dt < 0) dt += 2 * PIE;
if (temp->polar_r < invaridR) {
// 到達
temp->state = 2;
count++;
}
else if (fabs(temp->polar_r*sin(dt)) < temp->r){
// 撃破
temp->state = 1;
}
}
// 不要ufo削除
removeNodes(begin);
}
fprintf(stdout, "%d\n", count);
}
} | main.c: In function 'main':
main.c:60:17: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
60 | scanf_s("%d %d", &invaridR, &ufoNum);
| ^~~~~~~
| scanf
|
s086295699 | p00204 | C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define PIE atan(1.0)*4
typedef struct nd{
int id;
//
int x, y;
int r;
int v;
//
double polar_r;
double polar_t;
//
int state; // 0:接近中,1:撃破, 2:到達
struct nd *next;
struct nd *prev;
bool dummy;
} node;
void initList(node **top, int num) {
int i;
// 極座標変換
for (i = 0; i < num; i++) {
top[i]->polar_r = sqrt((double)(top[i]->x*top[i]->x + top[i]->y*top[i]->y));
top[i]->polar_t = acos((double)top[i]->x / top[i]->polar_r);
if (top[i]->y < 0)
top[i]->polar_t = 2*PIE-top[i]->polar_t;
top[i]->prev = i!=0 ? top[i - 1] : NULL;
top[i]->next = i!=num-1 ? top[i + 1] : NULL;
top[i]->dummy = false;
}
}
node *removeNode(node *target) {
node *next = target->next;
target->next->prev = target->prev;
target->prev->next = target->next;
free(target);
return next;
}
void removeNodes(node *begin) {
node *temp = begin->next;
while (temp->next != NULL) {
if (temp->state != 0)
temp = removeNode(temp);
else
temp = temp->next;
}
}
int main(int argc, char* argv[]) {
while (true) {
// データ読み込み
int invaridR, ufoNum;
scanf_s("%d %d", &invaridR, &ufoNum);
if (invaridR == 0 && ufoNum == 0) break;
node **ufos = (node**)malloc(sizeof(node*)*ufoNum);
for (int i = 0; i < ufoNum; i++) {
ufos[i] = (node*)malloc(sizeof(node));
ufos[i]->id = i;
scanf_s("%d %d %d %d", &(ufos[i]->x), &(ufos[i]->y), &(ufos[i]->r), &(ufos[i]->v));
ufos[i]->next = ufos[i]->prev = NULL;
ufos[i]->state = 0;
}
initList(ufos, ufoNum);
node *begin = (node*)malloc(sizeof(node));
begin->dummy = true;
begin->id = -1;
begin->prev = NULL;
begin->next = ufos[0];
ufos[0]->prev = begin;
node *end = (node*)malloc(sizeof(node));
end->dummy = true;
end->id = -2;
end->next = NULL;
end->prev = ufos[ufoNum - 1];
ufos[ufoNum - 1]->next = end;
// 計算
int t = 0;
int count = 0;
node *temp;
int i;
while (begin->next != end) {
// 位置&時刻更新
t++;
for (i = 0; i < ufoNum; i++) {
ufos[i]->polar_r -= ufos[i]->v;
}
// 照射方向決定
double minR = 1500;
double fireT = 0;
for (temp = begin->next; temp != end; temp = temp->next) {
if (temp->polar_r < minR && temp->polar_r>invaridR) {
minR = temp->polar_r;
fireT = temp->polar_t;
}
}
// 照射
for (temp = begin->next; temp != end; temp = temp->next) {
double dt = fireT - temp->polar_t;
if (dt > 2 * PIE) dt -= 2 * PIE;
if (dt < 0) dt += 2 * PIE;
if (temp->polar_r < invaridR) {
// 到達
temp->state = 2;
count++;
}
else if (fabs(temp->polar_r*sin(dt)) < temp->r){
// 撃破
temp->state = 1;
}
}
// 不要ufo削除
removeNodes(begin);
}
fprintf(stdout, "%d\n", count);
}
} | main.c: In function 'main':
main.c:61:17: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
61 | scanf_s("%d %d", &invaridR, &ufoNum);
| ^~~~~~~
| scanf
|
s480954790 | p00204 | C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define PIE atan(1.0)*4
typedef struct nd{
int id;
//
int x, y;
int r;
int v;
//
double polar_r;
double polar_t;
//
int state; // 0:接近中,1:撃破, 2:到達
struct nd *next;
struct nd *prev;
bool dummy;
} node;
void initList(node **top, int num) {
int i;
// 極座標変換
for (i = 0; i < num; i++) {
top[i]->polar_r = sqrt((double)(top[i]->x*top[i]->x + top[i]->y*top[i]->y));
top[i]->polar_t = acos((double)top[i]->x / top[i]->polar_r);
if (top[i]->y < 0)
top[i]->polar_t = 2*PIE-top[i]->polar_t;
top[i]->prev = i!=0 ? top[i - 1] : NULL;
top[i]->next = i!=num-1 ? top[i + 1] : NULL;
top[i]->dummy = false;
}
}
node *removeNode(node *target) {
node *next = target->next;
target->next->prev = target->prev;
target->prev->next = target->next;
free(target);
return next;
}
void removeNodes(node *begin) {
node *temp = begin->next;
while (temp->next != NULL) {
if (temp->state != 0)
temp = removeNode(temp);
else
temp = temp->next;
}
}
int main(int argc, char* argv[]) {
int invaridR, ufoNum;
int i;
node *temp;
while (true) {
// データ読み込み
scanf_s("%d %d", &invaridR, &ufoNum);
if (invaridR == 0 && ufoNum == 0) break;
node **ufos = (node**)malloc(sizeof(node*)*ufoNum);
for (i = 0; i < ufoNum; i++) {
ufos[i] = (node*)malloc(sizeof(node));
ufos[i]->id = i;
scanf_s("%d %d %d %d", &(ufos[i]->x), &(ufos[i]->y), &(ufos[i]->r), &(ufos[i]->v));
ufos[i]->next = ufos[i]->prev = NULL;
ufos[i]->state = 0;
}
initList(ufos, ufoNum);
node *begin = (node*)malloc(sizeof(node));
begin->dummy = true;
begin->id = -1;
begin->prev = NULL;
begin->next = ufos[0];
ufos[0]->prev = begin;
node *end = (node*)malloc(sizeof(node));
end->dummy = true;
end->id = -2;
end->next = NULL;
end->prev = ufos[ufoNum - 1];
ufos[ufoNum - 1]->next = end;
// 計算
int t = 0;
int count = 0;
while (begin->next != end) {
// 位置&時刻更新
t++;
for (i = 0; i < ufoNum; i++) {
ufos[i]->polar_r -= ufos[i]->v;
}
// 照射方向決定
double minR = 1500;
double fireT = 0;
for (temp = begin->next; temp != end; temp = temp->next) {
if (temp->polar_r < minR && temp->polar_r>invaridR) {
minR = temp->polar_r;
fireT = temp->polar_t;
}
}
// 照射
for (temp = begin->next; temp != end; temp = temp->next) {
double dt = fireT - temp->polar_t;
if (dt > 2 * PIE) dt -= 2 * PIE;
if (dt < 0) dt += 2 * PIE;
if (temp->polar_r < invaridR) {
// 到達
temp->state = 2;
count++;
}
else if (fabs(temp->polar_r*sin(dt)) < temp->r){
// 撃破
temp->state = 1;
}
}
// 不要ufo削除
removeNodes(begin);
}
fprintf(stdout, "%d\n", count);
}
} | main.c: In function 'main':
main.c:65:17: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
65 | scanf_s("%d %d", &invaridR, &ufoNum);
| ^~~~~~~
| scanf
|
s374627591 | p00204 | C | #include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <vector>
// ???, ????????????
typedef std::complex<double> Point;
typedef Point Vector;
namespace std {
bool operator < (const Point &a, const Point &b){
return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
}
istream& operator >> (istream &is, Point &a){
double x, y;
is >> x >> y;
a = Point(x, y);
return is;
}
ostream& operator << (ostream &os, Point a){
return os << a.real() << " " << a.imag();
}
}
// ??´???
struct Line {
Point p1, p2;
Line(){}
Line(const Point &p1, const Point &p2): p1(p1), p2(p2){}
};
typedef Line Segment;
namespace std {
istream& operator >> (istream &is, Line &a){
return is >> a.p1 >> a.p2;
}
}
// ???
struct Circle {
Point p; double r;
Circle(){}
Circle(const Point &p, double r): p(p), r(r){}
};
namespace std {
istream& operator >> (istream &is, Circle &a){
return is >> a.p >> a.r;
}
}
// ????§???¢
typedef std::vector<Point> Polygon;
const double EPS = 1e-12;
const double INF = 1e12;
const double PI = acos(-1.0);
// ????????¨??????????????¢???
enum CCW {
COUNTER_CLOCKWISE = 1,
CLOCKWISE = -1,
ONLINE_BACK = 2,
ONLINE_FRONT = -2,
ON_SEGMENT = 0,
};
// ?????¢????£????????????¢???
enum {
OUT = 0,
ON = 1,
IN = 2,
};
// a ??? 2 ??? (a ^ 2)
double SQ(double a);
// ?????????????????????????????¢??°
bool EQ(double a, double b);
bool NEQ(double a, double b);
bool LT(double a, double b);
bool GT(double a, double b);
bool LEQ(double a, double b);
bool GEQ(double a, double b);
// ??§?????? <=> ?????°?????????
double toDeg(double t);
double toRad(double t);
// ????????? (dot(a, a))
double norm(const Vector &a);
// ??????, ??????
double dot(const Vector &a, const Vector &b);
double cross(const Vector &a, const Vector &b);
// ??´???, ??????
bool orthogonal(const Segment &s1, const Segment &s2);
bool parallel(const Segment &s1, const Segment &s2);
// ?°???±, ????°?
Point project(const Line &l, const Point &p);
Point reflect(const Line &l, const Point &p);
// ?????? (p0, p1) ??¨??? p2 ???????????¢???
int ccw(const Point &p0, const Point &p1, const Point &p2);
// ????????????
bool intersectLP(const Line &l, const Point &p);
bool intersectLL(const Line &l1, const Line &l2);
bool intersectLS(const Line &l, const Segment &s);
bool intersectSP(const Segment &s, const Point &p);
bool intersectSS(const Segment &s1, const Segment &s2);
int intersectCP(const Circle &c, const Point &p);
bool intersectCL(const Circle &c, const Line &l);
int intersectCS(const Circle &c, const Segment &s);
int intersectCC(const Circle &c1, const Circle &c2);
// ?????¢
double distanceLP(const Line &l, const Point &p);
double distanceLL(const Line &l1, const Line &l2);
double distanceLS(const Line &l, const Segment &s);
double distanceSP(const Segment &s, const Point &p);
double distanceSS(const Segment &s1, const Segment &s2);
double distanceCP(const Circle &c, const Point &p);
double distanceCL(const Circle &c, const Line &l);
double distanceCS(const Circle &c, const Segment &s);
double distanceCC(const Circle &c1, const Circle &c2);
// ??????
Point crossPointLL(const Line &l1, const Line &l2);
Point crossPointLS(const Line &l, const Segment &s);
Point crossPointSS(const Segment &s1, const Segment &s2);
std::vector<Point> crossPointCL(const Circle &c, const Line &l);
std::vector<Point> crossPointCS(const Circle &c, const Segment &s);
std::vector<Point> crossPointCC(const Circle &c1, const Circle &c2);
double SQ(double a){
return a * a;
}
bool EQ(double a, double b){
return std::abs(a - b) < EPS;
}
bool NEQ(double a, double b){
return !EQ(a, b);
}
bool LT(double a, double b){
return a - b < -EPS;
}
bool GT(double a, double b){
return a - b > EPS;
}
bool LEQ(double a, double b){
return !GT(a, b);
}
bool GEQ(double a, double b){
return !LT(a, b);
}
double toDeg(double t){
return t * 180 / PI;
}
double toRad(double t){
return t / 180 * PI;
}
double norm(const Vector &a){
return SQ(a.real()) + SQ(a.imag());
}
double dot(const Vector &a, const Vector &b){
return (conj(a) * b).real();
}
double cross(const Vector &a, const Vector &b){
return (conj(a) * b).imag();
}
// AOJ CGL_2_A
bool orthogonal(const Segment &s1, const Segment &s2){
return EQ(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
// AOJ CGL_2_A
bool parallel(const Segment &s1, const Segment &s2){
return EQ(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
// AOJ CGL_1_A
Point project(const Line &l, const Point &p){
Vector base = l.p2 - l.p1;
double r = dot(p - l.p1, base) / norm(base);
return l.p1 + base * r;
}
// AOJ CGL_1_B
Point reflect(const Line &l, const Point &p){
return p + (project(l, p) - p) * 2.0;
}
// AOJ CGL_1_C
int ccw(const Point &p0, const Point &p1, const Point &p2){
Vector a = p1 - p0;
Vector b = p2 - p0;
if (GT(cross(a, b), 0.0)) return COUNTER_CLOCKWISE;
if (LT(cross(a, b), 0.0)) return CLOCKWISE;
if (LT(dot(a, b), 0.0)) return ONLINE_BACK;
if (LT(norm(a), norm(b))) return ONLINE_FRONT;
return ON_SEGMENT;
}
bool intersectLP(const Line &l, const Point &p){
return LEQ(std::abs(cross(l.p1 - p, l.p2 - p)), 0.0);
}
bool intersectLL(const Line &l1, const Line &l2){
return !parallel(l1, l2) || LEQ(std::abs(cross(l1.p2 - l1.p1, l2.p1 - l1.p1)), 0.0);
}
bool intersectLS(const Line &l, const Segment &s){
return LEQ(cross(l.p2 - l.p1, s.p1 - l.p1) * cross(l.p2 - l.p1, s.p2 - l.p1), 0.0);
}
bool intersectSP(const Segment &s, const Point &p){
//std::cout << abs(s.p1 - p) + abs(s.p2 - p) << " " << abs(s.p2 - s.p1) << std::endl;
return abs(s.p1 - p) + abs(s.p2 - p) - abs(s.p2 - s.p1) < EPS;
}
// CGL_2_B
bool intersectSS(const Segment &s1, const Segment &s2){
return ccw(s1.p1, s1.p2, s2.p1) * ccw(s1.p1, s1.p2, s2.p2) <= 0 &&
ccw(s2.p1, s2.p2, s1.p1) * ccw(s2.p1, s2.p2, s1.p2) <= 0;
}
int intersectCP(const Circle &c, const Point &p){
double dd = norm(c.p - p);
if (LT(dd, SQ(c.r))) return IN;
if (EQ(dd, SQ(c.r))) return ON;
return OUT;
}
bool intersectCL(const Circle &c, const Line &l){
double d = distanceLP(l, c.p);
return LEQ(d, c.r);
}
int intersectCS(const Circle &c, const Segment &s){
double dd1 = norm(c.p - s.p1);
double dd2 = norm(c.p - s.p2);
if (LT(dd1, SQ(c.r)) && LT(dd2, SQ(c.r))) return IN;
if (GT(dd1, SQ(c.r)) && GT(dd2, SQ(c.r))) return OUT;
return ON;
}
// c1 ??? c2 ???????????????????????¨??? IN
// c1 ??? c2 ????????£???????????¨??? ON
// c1 ??? c2 ?????????????????¨??? OUT
int intersectCC(const Circle &c1, const Circle &c2){
if (GT(norm(c1.p - c2.p), SQ(c1.r + c2.r))) return OUT;
if (LT(norm(c1.p - c2.p), SQ(c2.r))) return IN;
if (LT(norm(c1.p - c2.p), SQ(c1.r))) return OUT;
return ON;
}
double distanceLP(const Line &l, const Point &p){
return std::abs(cross(l.p2 - l.p1, p - l.p1)) / std::abs(l.p2 - l.p1);
}
double distanceLL(const Line &l1, const Line &l2){
if (intersectLL(l1, l2)) return 0.0;
return distanceLP(l1, l2.p1);
}
double distanceLS(const Line &l, const Segment &s){
if (intersectLS(l, s)) return 0.0;
return std::min(distanceLP(l, s.p1), distanceLP(l, s.p2));
}
double distanceSP(const Segment &s, const Point &p){
if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return std::abs(p - s.p1);
if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return std::abs(p - s.p2);
return distanceLP(s, p);
}
// AOJ CGL_2_D
double distanceSS(const Segment &s1, const Segment &s2){
if (intersectSS(s1, s2)) return 0.0;
return std::min(
std::min(
distanceSP(s1, s2.p1),
distanceSP(s1, s2.p2)
),
std::min(
distanceSP(s2, s1.p1),
distanceSP(s2, s1.p2)
)
);
}
double distanceCP(const Circle &c, const Point &p){
return std::abs(std::abs(c.p - p) - c.r);
}
double distanceCL(const Circle &c, const Line &l){
if (intersectCL(c, l)) return 0.0;
return distanceLP(l, c.p) - c.r;
}
double distanceCS(const Circle &c, const Segment &s){
if (intersectCS(c, s)) return 0.0;
return std::min(distanceCP(c, s.p1), distanceCP(c, s.p2));
}
double distanceCC(const Circle &c1, const Circle &c2){
if (intersectCC(c1, c2) == ON) return 0.0;
if (intersectCC(c1, c2) == IN){
return c2.r - (std::abs(c1.p - c2.p) + c1.r);
}
if (intersectCC(c2, c1) == IN){
return c1.r - (std::abs(c1.p - c2.p) + c2.r);
}
return (c1.r + c2.r) - (c1.r + c2.r);
}
Point crossPointLL(const Line &l1, const Line &l2){
assert(intersectLL(l1, l2));
Vector base = l2.p2 - l2.p1;
double d1 = std::abs(cross(base, l1.p1 - l2.p1));
double d2 = std::abs(cross(base, l1.p2 - l2.p1));
double t = d1 / (d1 + d2);
return l1.p1 + (l1.p2 - l1.p1) * t;
}
Point crossPointLS(const Line &l, const Segment &s){
assert(intersectLS(l, s));
return crossPointLL(l, s);
}
Point crossPointSS(const Segment &s1, const Segment &s2){
assert(intersectSS(s1, s2));
return crossPointSS(s1, s2);
}
std::vector<Point> crossPointCL(const Circle &c, const Line &l){
if (!intersectCL(c, l)) return std::vector<Point>();
std::vector<Point> ret;
Vector proj = project(l, c.p);
Vector e = (l.p2 - l.p1) / std::abs(l.p2 - l.p1);
double base = sqrt(SQ(c.r) - norm(proj - c.p));
ret.push_back(proj + e * base);
ret.push_back(proj - e * base);
return ret;
}
std::vector<Point> crossPointCS(const Circle &c, const Segment &s){
std::vector<Point> ret = crossPointCL(c, s);
for (int i = 0; i < ret.size(); i++){
if (!intersectCP(c, ret[i])){
swap(ret[i], ret.back());
ret.pop_back();
i--;
}
}
return ret;
}
std::vector<Point> crossPointCC(const Circle &c1, const Circle &c2){
if (!intersectCC(c1, c2)) return std::vector<Point>();
std::vector<Point> ret;
double d = std::abs(c1.p - c2.p);
double a = std::acos((SQ(c1.r) + SQ(d) - SQ(c2.r)) / (2 * c1.r * d));
double t = std::arg(c2.p - c1.p);
ret.push_back(c1.p + std::polar(c1.r, t + a));
ret.push_back(c1.p + std::polar(c1.r, t - a));
return ret;
}
using namespace std;
struct UFO {
Circle c;
Vector v;
};
double R;
int N;
vector<UFO> ufo;
int solve()
{
int res = 0;
while (true){
for (int i = 0; i < ufo.size(); i++){
Point nx = ufo[i].c.p + ufo[i].v;
if (LEQ(norm(nx), SQ(R)) || LEQ(dot(nx, ufo[i].c.p), 0.0)){
swap(ufo[i], ufo.back());
ufo.pop_back();
i--;
res++;
continue;
}
ufo[i].c.p = nx;
}
if (ufo.size() == 0) break;
double mind = INF;
int near = -1;
for (int i = 0; i < ufo.size(); i++){
if (norm(ufo[i].c.p) < mind){
mind = norm(ufo[i].c.p);
near = i;
}
}
Vector e = ufo[near].c.p / abs(ufo[near].c.p);
Segment s(e * R, e * 10000.0);
for (int i = 0; i < ufo.size(); i++){
if (LEQ(distanceSP(s, ufo[i].c.p), ufo[i].c.r)){
swap(ufo[i], ufo.back());
ufo.pop_back();
i--;
}
}
if (ufo.size() == 0) break;
}
return res;
}
int main()
{
std::cout << std::fixed << std::setprecision(12);
while (cin >> R >> N, N){
ufo.resize(N);
for (int i = 0; i < N; i++){
double v;
cin >> ufo[i].c >> v;
ufo[i].v = -ufo[i].c.p * v / abs(ufo[i].c.p);
}
cout << solve() << endl;
}
} | main.c:1:10: fatal error: algorithm: No such file or directory
1 | #include <algorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s035812217 | p00204 | C | #include <stdio.h>
#include <complex.h>
#include <math.h>
double complex coordinate(double complex z, int v, int t){
return t*v*(-z/cabs(z))+z;
}
double theta(double complex z, int r, int i){
return carg(z+(z/cabs(z))*r*i*I);
}
struct UFO{
char discrim;
int v;
int radius;
double complex z0;
};
int main(){
int range,number,time;
while(range != 0 || number != 0){
scanf("%d %d",&range,&number);
time=0;
struct UFO ufo[number];
int i,x,y;
for(i=0;i<number;i++){
scanf("%d %d %d %d",&x,&y,&ufo[i].radius,&ufo[i].v);
ufo[i].z0=x+y*I;
ufo[i].discrim=1;
}
int target=0;
int live = 0;
double complex cod[number];
double argtarget;
while(target != -1){
time++;
target=-1;
for(i=0;i<number;i++){
if(ufo[i].discrim == 1){
cod[i]=coordinate(ufo[i].z0,ufo[i].v,time);
if(cabs(cod[i])<=range){
live++;
ufo[i].discrim=0;
}
else{
if(target==-1){
target=i;
}
else{
if(cabs(cod[i])<cabs(cod[target])){
target=i;
}
}
}
}
}
if(target != -1){
argtarget=carg(cod[target]);
for(i=0;i<number;i++){
if(ufo[i].discrim==1){
if(((theta(cod[i],ufo[i].radius,-1)<=argtarget)&&(argtarget<=theta(cod[i],ufo[i].radius,1)))||(theta(cod[i],ufo[i].radius,1)<0&&theta(cod[i],ufo[i].radius,-1)>0&&(theta(cod[i],ufo[i].radius,-1)<=argtarget||argtarget<=theta(cod[i],ufo[i].radius,1)))){
ufo[i].discrim=0;
}
}
}
}
}
if(range!=0 || number!=0){
printf("%d\n",live);
{
}
return NULL;
} | main.c: In function 'main':
main.c:76:16: error: returning 'void *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]
76 | return NULL;
| ^~~~
main.c:77:1: error: expected declaration or statement at end of input
77 | }
| ^
main.c:77:1: error: expected declaration or statement at end of input
|
s928913582 | p00204 | C | #include <cstdio>
#include <cmath>
#include <cfloat>
#include <cstring>
#include <cassert>
#include <vector>
#include <algorithm>
using namespace std;
/* double extention Library. */
const double EPS = 1e-8;
bool eq(double a, double b)
{
return (fabs(a - b) <= EPS);
}
bool lt(double a, double b)
{
return (a - b < EPS);
}
bool leq(double a, double b)
{
return (lt(a, b) || eq(a, b));
}
bool gt(double a, double b)
{
return (a - b > -EPS);
}
bool geq(double a, double b)
{
return (gt(a, b) || eq(a, b));
}
/* 2-D Geometry Library. */
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);
}
bool operator != (const Point &p) const {
return (!(*this == p));
}
};
typedef Point Vector;
typedef vector<Point> Polygon;
double norm(Vector a)
{
return (a.x * a.x + a.y * a.y);
}
double abs(Vector a)
{
return (sqrt(norm(a)));
}
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);
}
bool isIntersect(Point p1, Point p2, Point p3, Point p4){
return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0 );
}
bool isInside(Polygon gon, Point p)
{
for (int i = 0; i < gon.size(); i++){
if (ccw(gon[i], gon[(i + 1) % gon.size()], p) == CLOCKWISE) return (false);
}
return (true);
}
Point unitVector(Vector t)
{
double u = abs(t);
return (Point(t.x / u , t.y / u));
}
double getCos(Vector a, Vector b)
{
return (dot(a, b) / (abs(a) * abs(b)));
}
double getSin(Point a , Point b)
{
double t = getCos(a, b);
return (sqrt(1.0 - t * t));
}
double getDistPL(Point p, Point a, Point b)
{
return (fabs(cross(b - a, p - a)) / abs(b - a));
}
double getDistPS(Point p, Point a, Point b)
{
if(dot(b - a, p - a) < EPS) return (abs(p - a));
if(dot(a - b, p - b) < EPS) return (abs(p - b));
return (getDistPL(p, a, b));
}
Point interPointS(Point a1 , Point a2 , Point b1 , Point b2)
{
Point b = b2 - b1;
double d1 = fabs(cross(b, a1 - b1));
double d2 = fabs(cross(b, a2 - b1));
double t = d1 / (d1 + d2);
Point a = a2 - a1;
Point v = a * t;
return (a1 + v);
}
Point interPointL(Point a1 , Point a2 , Point b1 , Point b2)
{
Point a = a2 - a1;
Point b = b2 - b1;
double t = cross(b, b1 - a1) / cross(b, a);
Point v = a * t;
return (a1 + v);
}
void interPointLC(Point a, Point b, Point c, double r, Point ans[])
{
if (getDistPL(c, a, b) > r + EPS) return;
Point v = unitVector(b - a);
double delta = dot(v, a - c) * dot(v, a - c) - abs(a - c) * abs(a - c) + r * r;
double t = -dot(v, a - c);
double s = sqrt(delta);
ans[0] = a + v * (t + s);
ans[1] = a + v * (t - s);
}
Point xTranslate(Point t, double k)
{
return (Point(t.x, 2 * k - t.y));
}
Point yTranslate(Point t, double k)
{
return (Point(2 * k - t.x, t.y));
}
Point oTranslate(Point t, Point k)
{
return (k + (k - t));
}
Point rotate(Point t , Point p , double r)
{
double ta=cos(r)*(t.x-p.x)-sin(r)*(t.y-p.y)+p.x;
double tb=sin(r)*(t.x-p.x)+cos(r)*(t.y-p.y)+p.y;
return Point(ta , tb);
}
void interPointCC(Point a , double ra , Point b , double rb , Point ans[])
{
double di=fabs(abs(a-b));
if(di > ra+rb || di < fabs(ra-rb)) return;
double t=(ra*ra-rb*rb+di*di)/(di+di);
double rd=acos(t/ra);
Point dv=unitVector(b-a);
Point g1=rotate(dv , Point(0,0) , rd);
Point g2=rotate(dv , Point(0,0) , -rd);
ans[0]=a+g1*ra;
ans[1]=a+g2*ra;
}
Point normalVector(Point p,Point a,Point b)
{
Point v=unitVector(b-a);
v = cross(v , p-a) > 0 ? Point(v.y,(-1)*v.x) : Point((-1)*v.y , v.x);
return v*getDistPL(p,a,b);
}
Point fTranslate(Point t , Point a , Point b)
{
return t+normalVector(t,a,b)*2;
}
double area(Point a, Point b, Point c){
return fabs(cross(c-a , b-a)*0.5);
}
double polygonArea(Polygon t){
double ans = 0.0;
for (unsigned int i = 0; i < t.size(); i++)
ans += cross(t[i] , t[(i + 1) % t.size()]);
return (ans / 2);
}
Polygon conhel(Polygon& ps)
{
sort(ps.begin(), ps.end());
int k = 0, n = static_cast<int>(ps.size());
Polygon qs(n * 2);
for (int i = 0; i < n; i++){
while (k > 1 && cross(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) < EPS) k--;
qs[k++] = ps[i];
}
for (int i = n - 2, t = k; i >= 0; i--){
while (k > t && cross(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) < EPS) k--;
qs[k++] = ps[i];
}
qs.resize(k - 1);
return (qs);
}
#define INVADED (-1)
#define DELETED (-2)
Point P[128];
double r[128], v[128];
int state[128];
int main()
{
int R, N;
while (scanf("%d %d", &R, &N) && R + N){
for (int i = 0; i < N; i++){
scanf("%lf %lf %lf %lf", &P[i].x, &P[i].y, &r[i], &v[i]);
}
memset(state, 0, sizeof(state));
while (1){
bool finished = true;
for (int i = 0; i < N; i++){
if (state[i] >= 0){
finished = false;
Point x = Point(0, 0) - P[i];
x = unitVector(x);
Point next = P[i] + x * v[i];
if (leq(next.x * P[i].x, 0) && leq(next.y * P[i].y, 0)){
P[i] = Point(0, 0);
}
else {
P[i] = P[i] + x * v[i];
}
if (leq(abs(P[i]), R)){
state[i] = INVADED;
}
}
}
if (finished) break;
int cand = -1;
double dist;
for (int i = 0; i < N; i++){
if (state[i] >= 0){
if (cand == -1 || gt(abs(P[cand]), abs(P[i]))){
cand = i;
dist = abs(P[i]);
}
}
}
Point check[2], dummy = Point(-999999999, -999999999);
for (int i = 0; i < N; i++){
if (state[i] >= 0){
interPointLC(Point(0, 0), P[cand], P[i], r[i], check);
bool flag1 = check[0] != dummy && P[i].x * P[cand].x >= 0 && P[i].y * P[cand].y >= 0 && gt(abs(check[0]), R);
bool flag2 = check[1] != dummy && P[i].x * P[cand].x >= 0 && P[i].y * P[cand].y >= 0 && gt(abs(check[1]), R);
if (flag1 || flag2){
state[i] = DELETED;
}
}
}
}
int ct = 0;
for (int i = 0; i < N; i++){
if (state[i] == INVADED) ct++;
}
printf("%d\n", ct);
}
return (0);
} | main.c:1:10: fatal error: cstdio: No such file or directory
1 | #include <cstdio>
| ^~~~~~~~
compilation terminated.
|
s188339633 | p00204 | C++ | ### main
while true
rlimit, n = gets.strip.split(' ').map{|s| s.to_i}
break if rlimit == 0 && n == 0
rlimit2 = rlimit ** 2
ufos = []
n.times.each do
x0, y0, r, v = gets.strip.split(' ').map{|s| s.to_i}
d2 = x0 ** 2 + y0 ** 2
d = Math.sqrt(d2)
vx = -x0.to_f * v / d
vy = -y0.to_f * v / d
ufos << [x0.to_f, y0.to_f, d2, x0, y0, vx, vy, r * r]
end
count = 0
t = 0
while ! ufos.empty?
#puts "t=#{t}"
ufos0 = ufos.sort{|a, b| a[2] <=> b[2]}
min_u = nil
for u0 in ufos0
#p ['u0'] + u0
if u0[2] <= rlimit2
count += 1
ufos.delete(u0)
#puts " d2=#{u0[2]}, rlimit2=#{rlimit2}: enter (delete)"
next
end
if min_u.nil?
min_u = u0
lx = u0[3]
ly = u0[4]
lxy2 = lx ** 2 + ly ** 2
## lazer: ly * x - lx * y = 0
ufos.delete(u0)
#puts " nearest (delete)"
next
end
ld2 = (ly * u0[0] - lx * u0[1]) ** 2
if ld2 <= u0[7] * lxy2 && lx * u0[0] + ly * u0[1] > 0
ufos.delete(u0)
#puts " dr2=#{ld2/lxy2} <= r2=#{u0[7]} : hit (delete)"
end
end
t += 1
for u in ufos
u[0] = u[5] * t + u[3]
u[1] = u[6] * t + u[4]
u[2] = u[0] ** 2 + u[1] ** 2
end
end
puts count
end | a.cc:1:1: error: stray '##' in program
1 | ### main
| ^~
a.cc:1:3: error: stray '#' in program
1 | ### main
| ^
a.cc:25:6: error: invalid preprocessing directive #puts
25 | #puts "t=#{t}"
| ^~~~
a.cc:31:8: error: invalid preprocessing directive #p
31 | #p ['u0'] + u0
| ^
a.cc:36:10: error: invalid preprocessing directive #puts
36 | #puts " d2=#{u0[2]}, rlimit2=#{rlimit2}: enter (delete)"
| ^~~~
a.cc:45:9: error: stray '##' in program
45 | ## lazer: ly * x - lx * y = 0
| ^~
a.cc:47:10: error: invalid preprocessing directive #puts
47 | #puts " nearest (delete)"
| ^~~~
a.cc:54:10: error: invalid preprocessing directive #puts
54 | #puts " dr2=#{ld2/lxy2} <= r2=#{u0[7]} : hit (delete)"
| ^~~~
a.cc:1:5: error: 'main' does not name a type
1 | ### main
| ^~~~
a.cc:5:3: error: expected unqualified-id before 'break'
5 | break if rlimit == 0 && n == 0
| ^~~~~
a.cc:14:5: error: 'd2' does not name a type
14 | d2 = x0 ** 2 + y0 ** 2
| ^~
a.cc:28:5: error: 'min_u' does not name a type
28 | min_u = nil
| ^~~~~
|
s310829887 | p00204 | C++ | #include<iostream>
#include<cfloat>
#include<cassert>
#include<cmath>
#include<vector>
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;
class Circle{
public:
Point c;
double r;
Circle(Point c = Point(), double r = 0.0): c(c), r(r){}
};
typedef vector<Point> Polygon;
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 ) );
Vector v = project(l, c1.c);
double th = acos(abs(v)/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);
}
/*
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);
}
*/
#define NON 0
#define IN 1
#define OUT 2
double R;
class UFO{
public:
Circle body;
double v, dx, dy;
int state;
UFO( Circle c = Circle(Point(0,0),0), double v=0):body(c), v(v){
Point ct = Point(0, 0);
Vector a = ct - body.c;
dx = v*cos(arg(a));
dy = v*sin(arg(a));
state = NON;
}
void move(){
if ( state != NON ) return;
double pred = getDistance(Point(0, 0), body.c);
if ( v > pred || equals(v, pred)){ state = IN; return; }
body.c.x += dx;
body.c.y += dy;
double d = getDistance(Point(0, 0), body.c);
if ( R > d || equals(R, d) ) state = IN;
}
};
#define MAX 100
UFO U[MAX];
int n;
void attack( Point p1, Point p2){
Line l = Line(p1, p2);
for ( int i = 0; i < n; i++ ){
if ( U[i].state != NON ) continue;
if ( !isIntersect(U[i].body, l) ) continue;
pair<Point, Point> pp = getCrossPoints(U[i].body, l);
if ( equals( arg(p2 - p1), arg(pp.first - p1)) && getDistance(p1, pp.first) > R ) {
U[i].state = OUT;
}
if ( equals( arg(p2 - p1), arg(pp.second - p1)) && getDistance(p1, pp.second) > R ) {
U[i].state = OUT;
}
}
}
int simulate(){
while(1){
int life = 0;
for ( int i = 0; i < n; i++ ) {
U[i].move();
if ( U[i].state == NON ) life++;
}
if ( life == 0 ) break;
int target = -1;
double md = 1000000;
for ( int i = 0; i < n; i++ ){
if ( U[i].state != NON ) continue;
double d = getDistance(Point(0, 0), U[i].body.c);
assert( !equals(md, d) );
if ( d < md ){
md = d;
target = i;
}
}
attack(Point(0, 0), U[target].body.c);
}
int cnt = 0;
for ( int i = 0; i < n; i++ ) if ( U[i].state == IN ) cnt++;
return cnt;
}
main(){
double x, y, r, v;
while( cin >> R && R ){
cin >> n;
for ( int i = 0; i < n; i++ ){
cin >> x >> y >> r >> v;
U[i] = UFO(Circle(Point(x, y), r), v);
}
cout << simulate() << endl;
}
} | a.cc: In function 'std::pair<Point, Point> getCrossPoints(Circle, Line)':
a.cc:93:16: error: 'project' was not declared in this scope
93 | Vector v = project(l, c1.c);
| ^~~~~~~
a.cc: At global scope:
a.cc:195:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
195 | main(){
| ^~~~
|
s822626278 | p00204 | C++ | #include<iostream>
#include<cfloat>
#include<cassert>
#include<cmath>
#include<vector>
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;
class Circle{
public:
Point c;
double r;
Circle(Point c = Point(), double r = 0.0): c(c), r(r){}
};
typedef vector<Point> Polygon;
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;
Point project( Segment s, Point p ){
Vector base = s.p2 - s.p1;
double t = dot(p - s.p1, base)/norm(base);
return s.p1 + base*t;
}
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);
}
*/
pair<Point, Point> getCrossPoints(Circle c, Line l ){
assert( isIntersect( c, l ) );
Vector pr = project(l, c.c);
Vector e = (l.p2 - l.p1)/abs(l.p2 - l.p1);
double base = sqrt(c.r*c.r - norm(pr));
Point p1 = pr + e*base;
Point p2 = pr - e*base;
return make_pair(p1, p2);
}
#define NON 0
#define IN 1
#define OUT 2
double R;
class UFO{
public:
Circle body;
double v, dx, dy;
int state;
UFO( Circle c = Circle(Point(0,0),0), double v=0):body(c), v(v){
Point ct = Point(0, 0);
Vector a = ct - body.c;
dx = v*cos(arg(a));
dy = v*sin(arg(a));
state = NON;
}
void move(){
if ( state != NON ) return;
double pred = getDistance(Point(0, 0), body.c);
if ( v > pred || equals(v, pred)){ state = IN; return; }
body.c.x += dx;
body.c.y += dy;
double d = getDistance(Point(0, 0), body.c);
if ( R > d || equals(R, d) ) state = IN;
}
};
#define MAX 100
UFO U[MAX];
int n;
void attack( Point p1, Point p2){
Line l = Line(p1, p2);
for ( int i = 0; i < n; i++ ){
if ( U[i].state != NON ) continue;
if ( !isIntersect(U[i].body, l) ) continue;
pair<Point, Point> pp = getCrossPoints(U[i].body, l);
if ( equals( arg(p2 - p1), arg(pp.first - p1)) && getDistance(p1, pp.first) > R ) {
U[i].state = OUT;
}
if ( equals( arg(p2 - p1), arg(pp.second - p1)) && getDistance(p1, pp.second) > R ) {
U[i].state = OUT;
}
}
}
int simulate(){
while(1){
int life = 0;
for ( int i = 0; i < n; i++ ) {
U[i].move();
if ( U[i].state == NON ) life++;
}
if ( life == 0 ) break;
int target = -1;
double md = 1000000;
for ( int i = 0; i < n; i++ ){
if ( U[i].state != NON ) continue;
double d = getDistance(Point(0, 0), U[i].body.c);
assert( !equals(md, d) );
if ( d < md ){
md = d;
target = i;
}
}
attack(Point(0, 0), U[target].body.c);
}
int cnt = 0;
for ( int i = 0; i < n; i++ ) if ( U[i].state == IN ) cnt++;
return cnt;
}
main(){
double x, y, r, v;
while( cin >> R && R ){
cin >> n;
for ( int i = 0; i < n; i++ ){
cin >> x >> y >> r >> v;
U[i] = UFO(Circle(Point(x, y), r), v);
}
cout << simulate() << endl;
}
} | a.cc: In function 'std::pair<Point, Point> getCrossPoints(Circle, Line)':
a.cc:118:29: error: no match for 'operator/' (operand types are 'Point' and 'double')
118 | Vector e = (l.p2 - l.p1)/abs(l.p2 - l.p1);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
| | |
| Point double
a.cc: At global scope:
a.cc:206:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
206 | main(){
| ^~~~
|
s955887736 | p00204 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;
const double eps = 1e-7;
int xs[100], ys[100], rs[100], vs[100];
bool shoot[100];
inline int sq(int x) {
return x*x;
}
int main() {
int R, N;
while (cin >> R >> N, (R || N)) {
for (int i=0; i<N; ++i) {
cin >> xs[i] >> ys[i] >> rs[i] >> vs[i];
}
memset(shoot, false, sizeof shoot);
for (int m=1; ; ++m) {
int k = -1, minDist = INT_MAX;
for (int i=0; i<N; ++i) {
int dist = sq(xs[i])+sq(ys[i]) - sq(R+vs[i]*m);
if ( ! shoot[i] && 0 < dist && dist < minDist) {
minDist = dist;
k = i;
}
}
if (k == -1) break;
shoot[k] = true;
for (int i=0; i<N; ++i) {
int dist = sq(xs[i])+sq(ys[i]) - sq(R+vs[i]*m);
if ( ! shoot[i] && 0 < dist) {
double x = xs[k] - vs[k] * cos(atan2(xs[k], ys[k]));
double y = ys[k] - vs[k] * sin(atan2(xs[k], ys[k]));
double p = xs[i] - vs[i] * cos(atan2(xs[i], ys[i]));
double q = ys[i] - vs[i] * sin(atan2(xs[i], ys[i]));
double a = y/x;
double t = sq(a*p-q)/(1+a*a);
if (t <= sq(rs[i]) + eps) {
shoot[i] = true;
}
}
}
}
int res = 0;
for (int i=0; i<N; ++i) {
if ( ! shoot[i]) ++res;
}
cout << res << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:39:72: error: 'atan2' was not declared in this scope
39 | double x = xs[k] - vs[k] * cos(atan2(xs[k], ys[k]));
| ^~~~~
a.cc:39:68: error: 'cos' was not declared in this scope
39 | double x = xs[k] - vs[k] * cos(atan2(xs[k], ys[k]));
| ^~~
a.cc:40:68: error: 'sin' was not declared in this scope
40 | double y = ys[k] - vs[k] * sin(atan2(xs[k], ys[k]));
| ^~~
|
s714388222 | p00204 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PIE atan(1.0)*4
typedef struct nd{
int id;
//
int x, y;
int r;
int v;
//
double polar_r;
double polar_t;
//
int state; // 0:接近中,1:撃破, 2:到達
struct nd *next;
struct nd *prev;
bool dummy;
} node;
void initList(node **top, int num) {
// 極座標変換
for (int i = 0; i < num; i++) {
top[i]->polar_r = sqrt((double)(top[i]->x*top[i]->x + top[i]->y*top[i]->y));
top[i]->polar_t = acos((double)top[i]->x / top[i]->polar_r);
if (top[i]->y < 0)
top[i]->polar_t = 2*PIE-top[i]->polar_t;
top[i]->prev = i!=0 ? top[i - 1] : NULL;
top[i]->next = i!=num-1 ? top[i + 1] : NULL;
top[i]->dummy = false;
}
}
node *remove(node *target) {
node *next = target->next;
target->next->prev = target->prev;
target->prev->next = target->next;
free(target);
return next;
}
void removeNodes(node *begin) {
node *temp = begin->next;
while (temp->next != NULL) {
if (temp->state != 0)
temp = remove(temp);
else
temp = temp->next;
}
}
int main(int argc, char* argv[]) {
while (true) {
// データ読み込み
int invaridR, ufoNum;
fscanf_s(stdin, "%d %d", &invaridR, &ufoNum);
if (invaridR == 0 && ufoNum == 0) break;
node **ufos = (node**)malloc(sizeof(node*)*ufoNum);
for (int i = 0; i < ufoNum; i++) {
ufos[i] = (node*)malloc(sizeof(node));
ufos[i]->id = i;
fscanf_s(stdin, "%d %d %d %d", &(ufos[i]->x), &(ufos[i]->y), &(ufos[i]->r), &(ufos[i]->v));
ufos[i]->next = ufos[i]->prev = NULL;
ufos[i]->state = 0;
}
initList(ufos, ufoNum);
node *begin = (node*)malloc(sizeof(node));
begin->dummy = true;
begin->id = -1;
begin->prev = NULL;
begin->next = ufos[0];
ufos[0]->prev = begin;
node *end = (node*)malloc(sizeof(node));
end->dummy = true;
end->id = -2;
end->next = NULL;
end->prev = ufos[ufoNum - 1];
ufos[ufoNum - 1]->next = end;
// 計算
int t = 0;
int count = 0;
while (begin->next != end) {
// 位置&時刻更新
t++;
for (int i = 0; i < ufoNum; i++) {
ufos[i]->polar_r -= ufos[i]->v;
}
// 照射方向決定
double minR = 1500;
double fireT = 0;
for (node *temp = begin->next; temp != end; temp = temp->next) {
if (temp->polar_r < minR && temp->polar_r>invaridR) {
minR = temp->polar_r;
fireT = temp->polar_t;
}
}
// 照射
for (node *temp = begin->next; temp != end; temp = temp->next) {
double dt = fireT - temp->polar_t;
if (dt > 2 * PIE) dt - 2 * PIE;
if (dt < 0) dt += 2 * PIE;
if (temp->polar_r < invaridR) {
// 到達
temp->state = 2;
count++;
}
else if (fabs(temp->polar_r*sin(dt)) < temp->r){
// 撃破
temp->state = 1;
}
}
// 不要ufo削除
removeNodes(begin);
}
fprintf(stdout, "%d\n", count);
}
} | a.cc: In function 'int main(int, char**)':
a.cc:59:17: error: 'fscanf_s' was not declared in this scope; did you mean 'fscanf'?
59 | fscanf_s(stdin, "%d %d", &invaridR, &ufoNum);
| ^~~~~~~~
| fscanf
|
s409750602 | p00204 | C++ | from math import sqrt,fabs,ceil,floor,pow,exp,log,sin,cos,tan,asin,acos,atan,atan2,pi
eps=1e-10
inf=float("inf")
class Angle: #angle. kaku.
def __init__(self,th):
self.th = float(th)%(2*pi)
def __float__(self):
return self.th
def __eq__(self,other):
return abs(float(self)-float(other))<eps or abs(abs(float(self)-float(other))-2*pi)<eps
def isParaWith(self,other):
return self==other or self==other+pi
def __add__(self,other):
return Angle( (float(self) + float(other)) % (2*pi) )
def __sub__(self,other):
return Angle( (float(self) - float(other)) % (2*pi) )
def __mul__(self,c):
return Angle( (float(self) * c) % (2*pi) )
def __rmul__(self,c):
return Angle( (float(self) * c) % (2*pi) )
def __div__(self,c):
return Angle( (float(self) / c) % (2*pi) )
def __repr__(self):
return "Angle("+str(float(self))+")"
class Vector: #point, vector. ten, bekutoru.
def __init__(self,x=None,y=None,d=None,th=None):
if not(x is None) and not(y is None):
self.setXY(x,y)
if not(d is None) and not(th is None):
self.setDTh(d, th)
def setXY(self,x,y):
self.x=float(x);
self.y=float(y);
self.calcFromXY()
def setDTh(self,d,th):
self.d=float(d)
self.th=Angle(th)
self.calcFromDTh()
def calcFromXY(self):
self.d=sqrt(self.x**2+self.y**2)
self.th=Angle(atan2(self.y,self.x))
def calcFromDTh(self):
self.x=self.d*cos(self.th)
self.y=self.d*sin(self.th)
def e(self):
return self/self.d
def __eq__(self,other):
return fabs(self.x-other.x)<eps and fabs(self.y-other.y)<eps
def isParaWith(self,other):
return self.th.isParaWith(other.th)
def __add__(self,other):
return Vector(self.x+other.x, self.y+other.y)
def __sub__(self,other):
return Vector(self.x-other.x, self.y-other.y)
def __neg__(self):
return Vector(-self.x, -self.y)
def __mul__(self,c):
return Vector(self.x*c, self.y*c)
def __rmul__(self,c):
return Vector(self.x*c, self.y*c)
def __div__(self,c):
return Vector(self.x/c, self.y/c)
def __abs__(self):
return self.d
def rotated(self,th):
v=Vector(d=self.d, th=self.th+th)
return v
def rotatedWithCenter(self,th,p):
return (self-p).rotated(th)+p
def inprod(self,other):
return self.x*other.x+self.y*other.y
def outprod(self,other):
return self.x*other.y-self.y*other.x
def isOn(self,obj):
if isinstance(obj,DirSegLine) or isinstance(obj,SegLine):
return obj.ap==self or obj.bp==self or (obj.th==(self-obj.ap).th and obj.th==(obj.bp-self).th)
if isinstance(obj,HalfLine):
return obj.ap==self or obj.th==(self-obj.ap).th
if isinstance(obj,Line):
return obj.th==(self-obj.ap).th or obj.th==(obj.bp-self).th
if isinstance(obj,Circle):
return abs(abs(self-obj.p)-obj.d)<eps
def isIn(self,obj):
if isinstance(obj,Circle):
return abs(self-obj.p)<obj.d
def isOut(self,obj):
if isinstance(obj,Circle):
return abs(self-obj.p)>obj.d
def __repr__(self):
return "Vector("+str(self.x)+", "+str(self.y)+")"
Point=Vector
class DirSegLine: #directed line segment. yuukou senbun.
def __init__(self,ap=None,bp=None,dv=None):
if not(ap is None) and not(bp is None): self.setApBp(ap, bp)
if not(ap is None) and not(dv is None): self.setApBp(ap, ap+dv)
if not(bp is None) and not(dv is None): self.setApBp(bp-dv, bp)
def setApBp(self,ap,bp):
self.ap=ap
self.bp=bp
self.calcFromApBp()
def calcFromApBp(self):
self.dv = self.bp - self.ap
self.d = abs(self.dv)
self.th = self.dv.th
def __eq__(self,other):
return self.ap==other.ap and self.bp==other.bp
def isParaWith(self,other):
return self.th.isParaWith(other.th)
def __add__(self,v):
return DirSegLine(self.ap+v, self.bp+v)
def __sub__(self,v):
return DirSegLine(self.ap-v, self.bp-v)
def __abs__(self):
return self.d
def rotated(self,th):
return DirSegLine(self.ap.rotated(th), self.bp.rotated(th))
def rotatedWithCenter(self,th,p):
return (self-p).rotated(th)+p
def __repr__(self):
return "DirSegLine(ap="+str(self.ap)+", bp="+str(self.bp)+")"
class SegLine: #line segmeny. senbun.
def __init__(self,ap=None,bp=None,dv=None):
if not(ap is None) and not(bp is None): self.setApBp(ap, bp)
if not(ap is None) and not(dv is None): self.setApBp(ap, ap+dv)
if not(bp is None) and not(dv is None): self.setApBp(bp-dv, bp)
def setApBp(self,ap,bp):
self.ap=ap
self.bp=bp
self.calcFromApBp()
def calcFromApBp(self):
self.dv = self.bp - self.ap
self.d = abs(self.dv)
self.th = self.dv.th
def __eq__(self,other):
return (self.ap==other.ap and self.bp==other.bp) or (self.ap==other.bp and self.bp==other.ap)
def isParaWith(self,other):
return self.th.isParaWith(other.th)
def __add__(self,v):
return SegLine(self.ap+v, self.bp+v)
def __sub__(self,v):
return SegLine(self.ap-v, self.bp-v)
def __abs__(self):
return self.d
def rotated(self,th):
return SegLine(self.ap.rotated(th), self.bp.rotated(th))
def rotatedWithCenter(self,th,p):
return (self-p).rotated(th)+p
def __repr__(self):
return "SegLine(ap="+str(self.ap)+", bp="+str(self.bp)+")"
class HalfLine:
def __init__(self,ap=None,bp=None,dv=None,th=None):
if not(ap is None) and not(bp is None): self.setApBp(ap, bp)
if not(ap is None) and not(dv is None): self.setApBp(ap, ap+dv)
if not(bp is None) and not(dv is None): self.setApBp(bp-dv, bp)
if not(ap is None) and not(th is None): self.setApBp(ap, ap+Vector(d=1,th=th))
def setApBp(self,ap,bp):
self.ap=ap
self.bp=bp
self.calcFromApBp()
def calcFromApBp(self):
self.dv = self.bp - self.ap
self.th = self.dv.th
def __eq__(self,other):
return self.ap==other.ap and self.th==other.th
def isParaWith(self,other):
return self.th.isParaWith(other.th)
def __add__(self,v):
return HalfLine(self.ap+v, self.bp+v)
def __sub__(self,v):
return HalfLine(self.ap-v, self.bp-v)
def rotated(self,th):
return HalfLine(self.ap.rotated(th), self.bp.rotated(th))
def rotatedWithCenter(self,th,p):
return (self-p).rotated(th)+p
def __repr__(self):
return "HalfLine(ap="+str(self.ap)+", bp="+str(self.bp)+")"
class Line:
def __init__(self,ap=None,bp=None,dv=None,th=None):
if not(ap is None) and not(bp is None): self.setApBp(ap, bp)
if not(ap is None) and not(dv is None): self.setApBp(ap, ap+dv)
if not(bp is None) and not(dv is None): self.setApBp(bp-dv, bp)
if not(ap is None) and not(th is None): self.setApBp(ap, ap+Vector(d=1,th=th))
if not(bp is None) and not(th is None): self.setApBp(bp-Vector(d=1,th=th), bp)
def setApBp(self,ap,bp):
self.ap=ap
self.bp=bp
self.calcFromApBp()
def calcFromApBp(self):
self.dv = self.bp - self.ap
self.th = self.dv.th
def __eq__(self,other):
#return ( self.ap==other.ap or self.ap==other.bp or (self.ap-other.ap).isParaWith(other.dv) ) \
# and( self.bp==other.ap or self.bp==other.bp or (self.bp-other.bp).isParaWith(other.dv) )
return self.ap.isOn(other) and self.bp.isOn(other)
def isParaWith(self,other):
return self.th.isParaWith(other.th)
def __add__(self,v):
return Line(self.ap+v, self.bp+v)
def __sub__(self,v):
return Line(self.ap-v, self.bp-v)
def rotated(self,th):
return Line(self.ap.rotated(th), self.bp.rotated(th))
def rotatedWithCenter(self,th,p):
return (self-p).rotated(th)+p
def __repr__(self):
return "Line(ap="+str(self.ap)+", bp="+str(self.bp)+")"
class Circle:
def __init__(self,p,d):
self.setPD(p,d)
def setPD(self,p,d):
self.p=p
self.d=float(d)
def __eq__(self,other):
return self.p==other.p and abs(self.d-other.d)<eps
def __add__(self,v):
return Circle(self.p+v, self.d)
def __sub__(self,v):
return Circle(self.p-v, self.d)
def rotated(self,th):
return Circle(self.p.rotated(th), self.d)
def rotatedWithCenter(self,th,p):
return (self-p).rotated(th)+p
def __repr__(self):
return "Circle(p="+str(self.ap)+", d="+str(self.d)+")"
class Triangle:
def __init__(self,ap,bp,cp):
self.setApBpCp(ap,bp,cp)
def setApBpCp(self,ap,bp,cp):
self.ap=ap
self.bp=bp
self.cp=cp
self.calcFromApBpCp(ap, bp, cp)
def calcFromApBpCp(self,ap,bp,cp):
self.ae=SegLine(bp,cp)
self.be=SegLine(cp,ap)
self.ce=SegLine(ap,bp)
def __eq__(self,other):
return (self.ap==other.ap and self.bp==other.bp and self.cp==other.cp) \
or (self.ap==other.bp and self.bp==other.cp and self.cp==other.ap) \
or (self.ap==other.cp and self.bp==other.ap and self.cp==other.bp)
def __add__(self,v):
return Triangle(self.ap+v,self.bp+v,self.cp+v)
def __sub__(self,v):
return Triangle(self.ap-v,self.bp-v,self.cp-v)
def rotated(self,th):
return Triangle(self.ap.rotated(th),self.bp.rotated(th),self.cp.rotated(th))
def rotatedWithCenter(self,th,p):
return (self-p).rotated(th)+p
def area(self):
return abs((self.cp-self.ap).outprod(self.bp-self.cp))/2
def gravityCenter(self): #juushin
return (self.ap+self.bp+self.cp)/3
def innerCenter(self): #naishin
return crossPoints(angleBisector(self.ae,self.be), angleBisector(self.be,self.ce))[0]
def exterCenter(self): #gaishin
return crossPoints(perpendicularBisector(self.ae), perpendicularBisector(self.be))[0]
def orthoCenter(self): #suishin
return crossPoints(perpendicular(self.ap,self.ae), perpendicular(self.bp,self.be))[0]
def crossPoints(m,n):
if (isinstance(m,DirSegLine) or isinstance(m,SegLine) or isinstance(m,HalfLine) or isinstance(m,Line)) \
and (isinstance(n,DirSegLine) or isinstance(n,SegLine) or isinstance(n,HalfLine) or isinstance(n,Line)):
c = m.dv.outprod(n.dv)
if abs(c)<eps: return []
s = n.dv.outprod(m.ap-n.ap) / c
t = m.dv.outprod(n.ap-m.ap) / c
if ( ((isinstance(m,DirSegLine) or isinstance(m,SegLine)) and 0<=s<=1) \
or (isinstance(m,HalfLine) and 0<=s) \
or (isinstance(m,Line)) \
)and( ((isinstance(m,DirSegLine) or isinstance(m,SegLine)) and 0<=t<=1) \
or (isinstance(m,HalfLine) and 0<=t) \
or (isinstance(m,Line)) \
):
return [m.ap+m.dv*s]
if (isinstance(m,DirSegLine) or isinstance(m,SegLine) or isinstance(m,HalfLine) or isinstance(m,Line)) \
and isinstance(n,Circle):
l=perpendicular(n.p, m)
if l.bp.isOn(n):
return [l.bp]
if l.bp.isOut(n):
return []
if l.bp.isIn(n):
if l.dv==Vector(0,0):
p1 = n.p+m.dv.e()*n.d
p2 = n.p-m.dv.e()*n.d
else:
r=sqrt(n.d**2-l.d**2)
p1 = l.bp+Vector(d=r,th=l.th+pi/2)
p2 = l.bp+Vector(d=r,th=l.th-pi/2)
re=[]
if p1.isOn(m): re.append(p1)
if p2.isOn(m): re.append(p2)
return re
if isinstance(m,Circle) \
and (isinstance(n,DirSegLine) or isinstance(n,SegLine) or isinstance(n,HalfLine) or isinstance(n,Line)):
return crossPoints(n, m)
if isinstance(m,Circle) and isinstance(n,Circle):
if m.p==n.p and abs(m.d-n.d)<eps: #itchi
return []
if abs( abs(m.p-n.p)-(m.d-n.d) )<eps: #naisetsu(n in m)
return [(n.p*m.d-m.p*n.d)/(m.d-n.d)]
if abs(m.p-n.p) < (m.d-n.d): #naihou(n in m)
return []
if abs( abs(m.p-n.p)-(n.d-m.d) )<eps: #naisetsu(m in n)
return [(m.p*n.d-n.p*m.d)/(n.d-m.d)]
if abs(m.p-n.p) < (n.d-m.d): #naihou(n in m)
return []
if abs( abs(m.p-n.p)-(m.d+n.d) )<eps: #gaisetsu
return [(m.p*n.d+n.p*m.d)/(m.d+n.d)]
if abs(m.p-n.p) > (m.d+n.d): #hanareteru
return []
if abs(m.p-n.p) < (m.d+n.d):
d = abs(m.p-n.p)
x = (d**2+m.d**2-n.d**2)/(2*d)
y = sqrt(m.d**2-x**2)
v1 = Vector(x,y)
v2 = Vector(x,-y)
th = (n.p-m.p).th
return [m.p+v1.rotated(th), m.p+v2.rotated(th)]
def perpendicular(p,m):
m=Line(m.ap,m.bp)
ap=p
th=m.th+pi/2
bp=crossPoints(m, Line(ap=ap,th=th))[0]
return DirSegLine(ap,bp)
def angleBisector(m,n):
if m.isParaWith(n):
return Line(ap=(m.ap+n.ap)/2,th=m.th)
else:
return Line(ap=crossPoints(Line(m.ap,m.bp),Line(n.ap,n.bp))[0], th = (m.th+n.th)/2)
def perpendicularBisector(m):
return Line(ap=(m.ap+m.bp)/2,th=m.th+pi/2)
class Ufo:
def __init__(self,px,py,d,vd,i):
p=Vector(px,py)
self.p=p
self.d=d
self.c=Circle(p,d)
self.v=-p.e()*vd
self.i=i
def move(self): #genten toottaka wo kaesu
if(abs(self.p)<=abs(self.v)): return True
self.p=self.p+self.v
self.c=self.c+self.v
return False
class Laser:
def __init__(self,u,R): #yuukou hanni R ijou de u ni mukatte utu
self.line = HalfLine(ap=neu.p.e()*R, bp=neu.p)
while True:
R,ul = tuple(map(int,raw_input().split()))
if(R==0 and ul==0): break
ignArea = Circle(Vector(0,0),R)
us=[]
for ui in xrange(ul):
px,py,d,vd = tuple(map(int,raw_input().split()))
u = Ufo(px,py,d,vd,ui)
us.append(u)
re=0
while True:
#print "ufos moved"
rus=[] #us to be removed
for u in us:
passed = u.move()
if passed or u.p.isIn(ignArea):
re+=1
rus.append(u)
for u in rus:
#print u.i, "removed due to it invaded inside"
us.remove(u)
if len(us)==0:
break
neu=Ufo(inf,inf,1,1,1000)
for u in us:
if abs(u.p)<abs(neu.p):
neu=u
laser = Laser(neu,R)
rus=[]
for u in us:
if len(crossPoints(laser.line, u.c))!=0:
#print u.i, "removed due to laser hit"
rus.append(u)
for u in rus:
us.remove(u)
if len(us)==0:
break
print re | a.cc:8:17: error: stray '#' in program
8 | class Angle: #angle. kaku.
| ^
a.cc:30:17: error: stray '#' in program
30 | class Vector: #point, vector. ten, bekutoru.
| ^
a.cc:99:25: error: stray '#' in program
99 | class DirSegLine: #directed line segment. yuukou senbun.
| ^
a.cc:129:17: error: stray '#' in program
129 | class SegLine: #line segmeny. senbun.
| ^
a.cc:202:18: error: invalid preprocessing directive #return
202 | #return ( self.ap==other.ap or self.ap==other.bp or (self.ap-other.ap).isParaWith(other.dv) ) \
| ^~~~~~
a.cc:263:41: error: stray '#' in program
263 | def gravityCenter(self): #juushin
| ^
a.cc:265:41: error: stray '#' in program
265 | def innerCenter(self): #naishin
| ^
a.cc:267:41: error: stray '#' in program
267 | def exterCenter(self): #gaishin
| ^
a.cc:269:41: error: stray '#' in program
269 | def orthoCenter(self): #suishin
| ^
a.cc:310:65: error: stray '#' in program
310 | if m.p==n.p and abs(m.d-n.d)<eps: #itchi
| ^
a.cc:312:57: error: stray '#' in program
312 | if abs( abs(m.p-n.p)-(m.d-n.d) )<eps: #naisetsu(n in m)
| ^
a.cc:314:65: error: stray '#' in program
314 | if abs(m.p-n.p) < (m.d-n.d): #naihou(n in m)
| ^
a.cc:316:57: error: stray '#' in program
316 | if abs( abs(m.p-n.p)-(n.d-m.d) )<eps: #naisetsu(m in n)
| ^
a.cc:318:65: error: stray '#' in program
318 | if abs(m.p-n.p) < (n.d-m.d): #naihou(n in m)
| ^
a.cc:320:57: error: stray '#' in program
320 | if abs( abs(m.p-n.p)-(m.d+n.d) )<eps: #gaisetsu
| ^
a.cc:322:65: error: stray '#' in program
322 | if abs(m.p-n.p) > (m.d+n.d): #hanareteru
| ^
a.cc:358:25: error: stray '#' in program
358 | def move(self): #genten toottaka wo kaesu
| ^
a.cc:365:33: error: stray '#' in program
365 | def __init__(self,u,R): #yuukou hanni R ijou de u ni mukatte utu
| ^
a.cc:380:18: error: invalid preprocessing directive #print
380 | #print "ufos moved"
| ^~~~~
a.cc:381:24: error: stray '#' in program
381 | rus=[] #us to be removed
| ^
a.cc:388:26: error: invalid preprocessing directive #print
388 | #print u.i, "removed due to it invaded inside"
| ^~~~~
a.cc:403:34: error: invalid preprocessing directive #print
403 | #print u.i, "removed due to laser hit"
| ^~~~~
a.cc:1:1: error: 'from' does not name a type
1 | from math import sqrt,fabs,ceil,floor,pow,exp,log,sin,cos,tan,asin,acos,atan,atan2,pi
| ^~~~
a.cc:38:17: error: 'self' does not name a type
38 | self.y=float(y);
| ^~~~
a.cc:39:17: error: 'self' does not name a type
39 | self.calcFromXY()
| ^~~~
|
s813042691 | p00204 | C++ | from math import sqrt
class Ufo:
def __init__(self,px,py,d,vd,ui):
self.pd=sqrt(px**2+py**2)
self.px=float(px)
self.py=float(py)
self.ex=self.px/self.pd
self.ey=self.py/self.pd
self.d=float(d)
self.vd=float(vd)
self.vx=-self.vd*self.ex
self.vy=-self.vd*self.ey
self.i=ui
def move(self):
self.pd -= self.vd
self.px += self.vx
self.py += self.vy
while True:
R,ul=tuple(map(int,raw_input().split()))
if(R==0 and ul==0): break
us=[]
for ui in xrange(ul):
px,py,d,vd = tuple(map(int,raw_input().split()))
u = Ufo(px,py,d,vd,ui)
us.append(u)
re=0
while True:
for u in us:
u.move()
for u in us[:]:
if u.pd<=R:
re+=1
us.remove(u)
if len(us)==0: break
neu = Ufo(2000,2000,1,1,1)
for u in us:
if u.pd < neu.pd:
neu=u
laserex=neu.ex
laserey=neu.ey
for u in us[:]:
d = u.pd*abs(laserex*u.ey-laserey*u.ex) #u kara laser ni orosita suisen no nagasa
if d<u.d:
if u.pd*abs(laserex*u.ex+laserey*u.ey)+sqrt(u.d**2-d**2) > R:
us.remove(u)
if len(us)==0: break
print re | a.cc:50:65: error: stray '#' in program
50 | d = u.pd*abs(laserex*u.ey-laserey*u.ex) #u kara laser ni orosita suisen no nagasa
| ^
a.cc:1:1: error: 'from' does not name a type
1 | from math import sqrt
| ^~~~
|
s252325968 | p00204 | C++ | from math import sqrt
class Ufo:
def __init__(self,px,py,d,vd,ui):
self.pd=sqrt(px**2+py**2)
self.px=float(px)
self.py=float(py)
self.ex=self.px/self.pd
self.ey=self.py/self.pd
self.d=float(d)
self.vd=float(vd)
self.vx=-self.vd*self.ex
self.vy=-self.vd*self.ey
self.i=ui
def move(self):
self.pd -= self.vd
self.px += self.vx
self.py += self.vy
while True:
R,ul=tuple(map(int,raw_input().split()))
if(R==0 and ul==0): break
us=[]
for ui in xrange(ul):
px,py,d,vd = tuple(map(int,raw_input().split()))
u = Ufo(px,py,d,vd,ui)
us.append(u)
re=0
while len(us)!=0:
for u in us: u.move()
us.sort(key=lambda u: u.pd)
for u in us[:]:
if u.pd<=R:
re+=1
us.remove(u)
#print u.i, "due to invade"
continue
else:
break
neu=us.pop(0)
#print "focus",neu.i
#print neu.i,"due to hit"
laserex=neu.ex
laserey=neu.ey
for u in us[:]:
d = u.pd*abs(laserex*u.ey-laserey*u.ex) #u kara laser ni orosita suisen no nagasa
if d<u.d:
if u.pd*abs(laserex*u.ex+laserey*u.ey)+sqrt(u.d**2-d**2) > R:
us.remove(u)
#print u.i, "due to hit"
print re | a.cc:40:34: error: invalid preprocessing directive #print
40 | #print u.i, "due to invade"
| ^~~~~
a.cc:46:18: error: invalid preprocessing directive #print
46 | #print "focus",neu.i
| ^~~~~
a.cc:47:18: error: invalid preprocessing directive #print
47 | #print neu.i,"due to hit"
| ^~~~~
a.cc:52:65: error: stray '#' in program
52 | d = u.pd*abs(laserex*u.ey-laserey*u.ex) #u kara laser ni orosita suisen no nagasa
| ^
a.cc:56:42: error: invalid preprocessing directive #print
56 | #print u.i, "due to hit"
| ^~~~~
a.cc:1:1: error: 'from' does not name a type
1 | from math import sqrt
| ^~~~
|
s132844161 | p00204 | C++ | from math import sqrt,cos,atan2
class Ufo:
def __init__(self,px,py,d,vd,ui):
self.pd=sqrt(px**2+py**2)
self.px=float(px)
self.py=float(py)
self.fpd=self.pd
self.fpx=self.px
self.fpy=self.py
self.ex=self.fpx/self.fpd
self.ey=self.fpy/self.fpd
self.d=float(d)
self.vd=float(vd)
self.vx=-self.vd*self.ex
self.vy=-self.vd*self.ey
self.i=ui
def move(self):
self.pd -= self.vd
self.px += self.vx
self.py += self.vy
while True:
R,ul=tuple(map(int,raw_input().split()))
if(R==0 and ul==0): break
us=[]
for ui in xrange(ul):
px,py,d,vd = tuple(map(int,raw_input().split()))
u = Ufo(px,py,d,vd,ui)
us.append(u)
re=0
while True:
for u in us: u.move()
us.sort(key=lambda u: u.pd)
for u in us[:]:
if u.pd<=R:
re+=1
us.remove(u)
#print u.i, "due to invade"
continue
else:
break
if len(us)==0: break
neu=us.pop(0)
#print "focus",neu.i
#print neu.i,"due to hit"
for u in us[:]:
d = u.pd*abs(neu.fpx*u.fpy-neu.fpy*u.fpx)/neu.fpd/u.fpd #u kara laser ni orosita suisen no nagasa
if d<u.d:
if u.pd*cos(atan2(u.fpy,u.fpx)-atan2(neu.fpy,neu.fpx)) + sqrt(u.d**2-d**2) > R:
us.remove(u)
#print u.i, "due to hit"
if len(us)==0: break
print re | a.cc:43:34: error: invalid preprocessing directive #print
43 | #print u.i, "due to invade"
| ^~~~~
a.cc:50:18: error: invalid preprocessing directive #print
50 | #print "focus",neu.i
| ^~~~~
a.cc:51:18: error: invalid preprocessing directive #print
51 | #print neu.i,"due to hit"
| ^~~~~
a.cc:54:81: error: stray '#' in program
54 | d = u.pd*abs(neu.fpx*u.fpy-neu.fpy*u.fpx)/neu.fpd/u.fpd #u kara laser ni orosita suisen no nagasa
| ^
a.cc:58:42: error: invalid preprocessing directive #print
58 | #print u.i, "due to hit"
| ^~~~~
a.cc:1:1: error: 'from' does not name a type
1 | from math import sqrt,cos,atan2
| ^~~~
|
s875874588 | p00204 | C++ | #include <iostream>
#include <vector>
#include <math.h>
class UFO
{
private:
double dist; /* ??????????????????????????§????????¢ */
int speed; /* ??\????????? */
double rad; /* ?????\?§???? */
int r; /* UFO????????? */
bool alive;
public:
UFO(int x, int y, int r,int v);
bool IsAlive();
double EchoDist();
double EchoRad();
int EchoSize();
void PastTime();
void Hit();
};
int UFOShootingDownOperation();
int main()
{
while (0 == UFOShootingDownOperation());
return 0;
}
UFO::UFO(int x, int y, int r,int v) : r(r), speed(v), alive(true)
{
dist = sqrt(pow(x,2) + pow(y,2));
rad = acos(x / dist) * 180.0 / M_PI;
if (y < 0) {
rad = 360 - rad;
}
}
bool UFO::IsAlive()
{
return alive;
}
double UFO::EchoDist()
{
return dist;
}
double UFO::EchoRad()
{
return rad;
}
int UFO::EchoSize()
{
return r;
}
void UFO::PastTime()
{
if (dist - speed >= 0) {
dist -= speed;
}
else {
dist = 0;
}
}
void UFO::Hit()
{
alive = false;
}
int UFOShootingDownOperation()
{
using namespace std;
int R; /*??¬?????¶???????¨??????????????????????*/
int N; /*UFO?????°*/
int x0; /* UFO?????????????????????????????? */
int y0; /* UFO?????????????????????????????? */
int r; /* UFO???????????????????????? */
int v; /* UFO???????????????????????? */
bool existsTarget; /* ?????????UFO????????£????????????????????? */
int aliveUFO; /* ???????????£???UFO??????????????? */
double difRad; /* UFO?????????????§???¨??¬?????¶?????¨????§?????????????????´?(<=180) */
vector<UFO> aliens; /* UFO????????± */
vector<UFO>::iterator itr;
vector<UFO>::iterator target;
cin >> R >> N;
if (0 == R && 0 == N) {/* ???????????? */
return -1;
}
/* ??\??? */
for (int i = 0; N > i; ++i) {
cin >> x0 >> y0 >> r >> v;
aliens.push_back(UFO(x0, y0, r, v));
}
/* ????????????1????????????????????? */
for (itr = aliens.begin(); aliens.end() != itr; ++itr) {
itr->PastTime();
}
/* ???????????????????±?????????¬?????¶??????????°??????????????????? */
existsTarget = true;
while (1a) {
existsTarget = false;
target = aliens.end();
for (itr = aliens.begin(); aliens.end() != itr; ++itr) {
if (false == itr->IsAlive()) {/* ??¬?????¶??????????????????UFO??????????????? */
continue;
}
if (itr->EchoDist() > R) {
if (aliens.end() == target) {
target = itr;
}
else if (target->EchoDist() > itr->EchoDist()){
target = itr;
}
existsTarget = true;
}
}
if (existsTarget) {
break;
}
/* ???????????? */
for (itr = aliens.begin(); aliens.end() != itr; ++itr) {
if (false == itr->IsAlive()) {/* ??¬?????¶??????????????????UFO??????????????? */
continue;
}
difRad = fabs(target->EchoRad() - itr->EchoRad());
if (difRad >180) {
difRad = 360 - difRad;
}
if (difRad < 90) {
if (itr->EchoDist() * sin(difRad * M_PI / 180.0) <= itr->EchoSize()) {
if (itr->EchoDist() > R) {
itr->Hit();
}
}
}
else {
if (itr->EchoDist() <= itr->EchoSize()) {
if (itr->EchoDist() > R) {
itr->Hit();
}
}
}
/*???????????????*/
itr->PastTime();
}
}
aliveUFO = 0;
for (itr = aliens.begin(); aliens.end() != itr; ++itr) {
if (true == itr->IsAlive()) {
++aliveUFO;
}
}
cout << aliveUFO << endl;
return 0;
} | a.cc: In function 'int UFOShootingDownOperation()':
a.cc:107:16: error: unable to find numeric literal operator 'operator""a'
107 | while (1a) {
| ^~
|
s432229492 | p00204 | C++ | #include <iostream>
#include <vector>
#include <math.h>
class UFO
{
private:
double dist; /* ??????????????????????????§????????¢ */
int speed; /* ??\????????? */
double rad; /* ?????\?§???? */
int r; /* UFO????????? */
bool alive;
public:
UFO(int x, int y, int r,int v);
bool IsAlive();
double EchoDist();
double EchoRad();
int EchoSize();
void PastTime();
void Hit();
};
int UFOShootingDownOperation();
int main()
{
while (0 == UFOShootingDownOperation());
return 0;
}
UFO::UFO(int x, int y, int r,int v) : r(r), speed(v), alive(true)
{
dist = sqrt(pow(x,2) + pow(y,2));
rad = acos(x / dist) * 180.0 / M_PI;
if (y < 0) {
rad = 360 - rad;
}
}
bool UFO::IsAlive()
{
return alive;
}
double UFO::EchoDist()
{
return dist;
}
double UFO::EchoRad()
{
return rad;
}
int UFO::EchoSize()
{
return r;
}
void UFO::PastTime()
{
if (dist - speed >= 0) {
dist -= speed;
}
else {
dist = 0;
}
}
void UFO::Hit()
{
alive = false;
}
int UFOShootingDownOperation()
{
using namespace std;
int R; /*??¬?????¶???????¨??????????????????????*/
int N; /*UFO?????°*/
int x0; /* UFO?????????????????????????????? */
int y0; /* UFO?????????????????????????????? */
int r; /* UFO???????????????????????? */
int v; /* UFO???????????????????????? */
bool existsTarget; /* ?????????UFO????????£????????????????????? */
int aliveUFO; /* ???????????£???UFO??????????????? */
double difRad; /* UFO?????????????§???¨??¬?????¶?????¨????§?????????????????´?(<=180) */
vector<UFO> aliens; /* UFO????????± */
vector<UFO>::iterator itr;
vector<UFO>::iterator target;
cin >> R >> N;
if (0 == R && 0 == N) {/* ???????????? */
return -1;
}
/* ??\??? */
for (int i = 0; N > i; ++i) {
cin >> x0 >> y0 >> r >> v;
aliens.push_back(UFO(x0, y0, r, v));
}
/* ????????????1????????????????????? */
for (itr = aliens.begin(); aliens.end() != itr; ++itr) {
itr->PastTime();
}
/* ???????????????????±?????????¬?????¶??????????°??????????????????? */
existsTarget = true;
while (1a) {
existsTarget = false;
target = aliens.end();
for (itr = aliens.begin(); aliens.end() != itr; ++itr) {
if (false == itr->IsAlive()) {/* ??¬?????¶??????????????????UFO??????????????? */
continue;
}
if (itr->EchoDist() > R) {
if (aliens.end() == target) {
target = itr;
}
else if (target->EchoDist() > itr->EchoDist()){
target = itr;
}
existsTarget = true;
}
}
if (existsTarget) {
break;
}
/* ???????????? */
for (itr = aliens.begin(); aliens.end() != itr; ++itr) {
if (false == itr->IsAlive()) {/* ??¬?????¶??????????????????UFO??????????????? */
continue;
}
difRad = fabs(target->EchoRad() - itr->EchoRad());
if (difRad >180) {
difRad = 360 - difRad;
}
if (difRad < 90) {
if (itr->EchoDist() * sin(difRad * M_PI / 180.0) <= itr->EchoSize()) {
if (itr->EchoDist() > R) {
itr->Hit();
}
}
}
else {
if (itr->EchoDist() <= itr->EchoSize()) {
if (itr->EchoDist() > R) {
itr->Hit();
}
}
}
/*???????????????*/
itr->PastTime();
}
}
aliveUFO = 0;
for (itr = aliens.begin(); aliens.end() != itr; ++itr) {
if (true == itr->IsAlive()) {
++aliveUFO;
}
}
cout << aliveUFO << endl;
return 0;
} | a.cc: In function 'int UFOShootingDownOperation()':
a.cc:107:16: error: unable to find numeric literal operator 'operator""a'
107 | while (1a) {
| ^~
|
s256290165 | p00204 | C++ | /*
jin_matakich's geometry libraly
*/
#include <bits/stdc++.h>
using namespace std;
#define x() real()
#define y() imag()
#define EPS (1e-10)
#define INF (1e12)
#define SQ(a) ((a) * (a))
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).x(), (b).x()) && EQ((a).y(), (b).y()))
enum {
COUNTER_CLOCKWISE = 1,
CLOCKWISE = -1,
ONLINE_BACK = 2,
ONLINE_FRONT = -2,
ON_SEGMENT = 0
};
enum {OUT, ON, IN};
typedef double D;
typedef complex<D> P;
typedef P V;
namespace std {
bool operator < (const P &a, const P &b){
if (a.x() != b.x()) return a.x() < b.x();
return a.y() < b.y();
}
}
struct S{
P p1, p2;
S(){}
S(P p1, P p2): p1(p1), p2(p2){}
};
typedef S L;
typedef S PP;
struct C{
P p;
D r;
C(){}
C(P p, D r): p(p), r(r){}
};
typedef vector<P> G;
struct Edge {
int to;
D cost;
Edge(){}
Edge(int to, D cost = 0.0): to(to), cost(cost){}
bool operator < (const Edge &t) const {
return cost > t.cost;
}
};
typedef vector<vector<Edge> > Graph;
inline D inD(){
D d;
cin >> d;
return d;
}
inline P inP(){
D x, y;
cin >> x >> y;
return P(x, y);
}
inline S inS(){
P p1(inP());
P p2(inP());
return S(p1, p2);
}
inline C inC(){
P p(inP());
D r(inD());
return C(p, r);
}
D norm(P a){
return SQ(a.x()) + SQ(a.y());
}
D dot(P a, P b){
return a.x() * b.x() + a.y() * b.y();
}
D cross(P a, P b){
return a.x() * b.y() - a.y() * b.x();
}
bool orthogonal(L a, L b){
return EQ( dot(a.p1 - a.p2, b.p1 - b.p2), 0.0 );
}
bool parallel(L a, L b){
return EQ( cross(a.p1 - a.p2, b.p1 - b.p2), 0.0 );
}
bool PonL(L l, P p){
return EQ( cross(l.p1 - l.p2, p - l.p2), 0.0 );
}
bool PonS(S s, P p){
return EQ( cross(s.p1 - s.p2, p - s.p2), 0.0 ) &&
(dot(s.p1 - s.p2, p - s.p2) > -EPS) &&
(dot(s.p2 - s.p1, p - s.p1) > -EPS);
}
P project(S s, P p){
V base = s.p2 - s.p1;
D r = dot(p - s.p1, base) / norm(base);
return s.p1 + base * r;
}
P reflect(S s, P p){
return p + (project(s, p) - p) * 2.0;
}
int ccw(P p0, P p1, P p2){
P a = p1 - p0;
P 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;
}
bool intersectLL(L l1, L l2){
return !parallel(l1, l2) ||
abs( cross(l1.p1 - l1.p2, l2.p1 - l2.p2) ) < EPS;
}
bool intersectLS(L l, S s){
return cross(l.p2 - l.p1, s.p1) * cross(l.p2 - l.p1, s.p2) < EPS;
}
bool intersectSS(S s1, S s2){
return ccw(s1.p1, s1.p2, s2.p1) * ccw(s1.p1, s1.p2, s2.p2) <= 0 &&
ccw(s2.p1, s2.p2, s1.p1) * ccw(s2.p1, s2.p2, s1.p2) <= 0;
}
bool intersectCC(C c1, C c2){
return abs(c1.p - c1.p) - (c1.r + c2.r) < EPS;
}
D distanceLP(L l, P p){
return abs( cross(l.p2 - l.p1, p - l.p1) ) / abs(l.p2 - l.p1);
}
D distanceLL(L l1, L l2){
return intersectLL(l1, l2) ? 0 : distanceLP(l1, l2.p1);
}
D distanceLS(L l, S s){
return intersectLS(l, s) ?
0 :
min(distanceLP(l, s.p1), distanceLP(l, s.p2));
}
D distanceSP(S s, P p){
P pr = project(s, p);
if (PonS(s, pr)) return abs(pr - p);
return min( abs(s.p1 - p), abs(s.p2 - p) );
}
D distanceSS(S s1, S s2){
if (intersectSS(s1, s2)) return 0;
return min(
min(distanceSP(s1, s2.p1), distanceSP(s1, s2.p2)),
min(distanceSP(s2, s1.p1), distanceSP(s2, s1.p2))
);
}
bool intersectLC(L l, C c)
{
return distanceLP(l, c.p) - c.r < EPS;
}
/*
bool intersect(G g1, G g2){
for (int i = 0; i < g1.size(); i++){
for (int j = 0; j < g2.size(); j++){
S s1(g1[i], g1[(i + 1) % g1.size()]);
S s2(g2[j], g2[(j + 1) % g2.size()]);
if (intersect(s1, s2)) return true;
}
}
return false;
}
bool intersect(G g, S s){
for (int i = 0; i < g.size(); i++){
S s0(g[i], g[(i + 1) % g.size()]);
if (intersect(s, s0)) return true;
}
return false;
}
*/
P crossP(S s1, S s2){
assert(intersectSS(s1, s2));
P base = s2.p2 - s2.p1;
D d1 = abs(cross(base, s1.p1 - s2.p1));
D d2 = abs(cross(base, s1.p2 - s2.p1));
D t = d1 / (d1 + d2);
if (isnan(t)){
//printf("%f %f %f %f %f %f %f %f\n", s1.p1.x(), s1.p1.y(), s1.p2.x(), s1.p2.y(), s2.p1.x(), s2.p1.y(), s2.p2.x(), s2.p2.y());
if (EQV(s1.p1, s2.p1)) return s1.p1;
if (EQV(s1.p1, s2.p2)) return s1.p1;
if (EQV(s1.p2, s2.p1)) return s1.p2;
if (EQV(s1.p2, s2.p2)) return s1.p2;
}
P p = s1.p1 + (s1.p2 - s1.p1) * t;
assert(!isnan(p.x()));
return s1.p1 + (s1.p2 - s1.p1) * t;
}
PP crossPP(C c, L l){
P pr = project(l, c.p);
P e = (l.p2 - l.p1) / abs(l.p2 - l.p1);
D base = sqrt( SQ(c.r) - norm(pr - c.p) );
return PP(pr + e * base, pr - e * base);
}
PP crossPP(C c1, C c2){
D d = abs(c1.p - c2.p);
D a = acos( SQ(c1.r) + SQ(d) - SQ(c2.r) ) / (2 * c2.r * d);
D t = arg(c2.p - c1.p);
return PP( c1.p + polar(c1.r, t + a), c1.p + polar(c1.r, t - a) );
}
bool mergeIfAble(S &s1, S s2){
if (!parallel(s1, s2)) return false;
if (abs(ccw(s1.p1, s2.p1, s1.p2)) == 1) return false;
if (ccw(s1.p1, s1.p2, s2.p1) == ONLINE_FRONT ||
ccw(s2.p1, s2.p2, s1.p1) == ONLINE_FRONT){
return false;
}
s1 = S(min(s1.p1, s2.p1), max(s1.p2, s2.p2));
return true;
}
void merge(vector<S> &ss){
for (int i = 0; i < ss.size(); i++){
if (ss[i].p2 < ss[i].p1){
swap(ss[i].p1, ss[i].p2);
}
}
for (int i = 0; i < ss.size(); i++){
for (int j = i + 1; j < ss.size(); j++){
if (mergeIfAble(ss[i], ss[j])){
ss[j--] = ss.back();
ss.pop_back();
}
}
}
}
int contains(G &g, P p){
int n = g.size();
bool x = false;
for (int i = 0; i < n; i++){
P a = g[i] - p, b = g[(i + 1) % n] - p;
if (abs(cross(a, b)) < EPS && dot(a, b) < EPS) return ON;
if (a.y() > b.y()) swap(a, b);
if (a.y() < EPS && EPS < b.y() && cross(a, b) > EPS) x != x;
}
return x ? IN : OUT;
}
G convexHull(vector<P> s){
if (s.size() < 3) return s;
G u, l;
sort(s.begin(), s.end());
u.push_back(s[0]);
u.push_back(s[1]);
l.push_back(s[s.size() - 1]);
l.push_back(s[s.size() - 2]);
for (int i = 2; i < s.size(); i++){
for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], s[i]) != CLOCKWISE; n--){
u.pop_back();
}
u.push_back(s[i]);
}
for (int i = s.size() - 3; i >= 0; i--){
for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], s[i]) != CLOCKWISE; n--){
l.pop_back();
}
l.push_back(s[i]);
}
reverse(l.begin(), l.end());
for (int i = u.size() - 2; i >= 1; i--){
l.push_back(u[i]);
}
return l;
}
Graph SArrangement(const vector<S> &ss, vector<P> &ps){
for (int i = 0; i < ss.size(); i++){
ps.push_back(ss[i].p1);
ps.push_back(ss[i].p2);
for (int j = i + 1; j < ss.size(); j++){
if (intersectSS(ss[i], ss[j])){
ps.push_back(crossP(ss[i], ss[j]));
}
}
}
sort(ps.begin(), ps.end());
ps.erase(unique(ps.begin(), ps.end()), ps.end());
Graph g(ps.size());
for (int i = 0; i < ss.size(); i++){
vector<pair<D, int> > v;
for (int j = 0; j < ps.size(); j++){
if (PonS(ss[i], ps[j])){
v.push_back(make_pair(norm(ss[i].p1 - ps[i]), j));
}
}
sort(v.begin(), v.end());
for (int j = 0; j < (int)v.size() - 1; j++){
int a = v[j].second, b = v[j + 1].second;
D c = abs(ps[a] - ps[b]);
g[a].push_back(Edge(b, c));
g[b].push_back(Edge(a, c));
}
}
return g;
}
typedef pair<C, D> U;
D R, N;
vector<U> us;
vector<bool> f;
int main()
{
while (scanf("%lf %lf", &R, &N), (int)(R+N)){
us.clear();
f.clear();
for (int i = 0; i < N; i++){
C c(inC());
D v(inD());
us.push_back(U(c, v));
f.push_back(false);
}
int res = 0;
while (true){
for (int i = 0; i < N; i++){
if (f[i]) continue;
V e = -us[i].first.p / abs(us[i].first.p);
V v = e * us[i].second;
P to = us[i].first.p + v;
if (dot(us[i].first.p, to) < EPS){
f[i] = true;
res++;
}
else us[i].first.p = to;
}
int near = -1;
for (int i = 0; i < N; i++){
if (f[i]) continue;
else if (norm(us[i].first.p) - us[i].first.r < SQ(R) ||
norm(us[i].first.p) - us[i].first.r < EPS)){
res++;
f[i] = true;
}
else if (near == -1) near = i;
else if (norm(us[near].first.p) - us[near].first.r > norm(us[i].first.p) - us[i].first.r) near = i;
}
if (near == -1) break;
L l(P(0, 0), us[near].first.p);
for (int i = 0; i < N; i++){
if (f[i]) continue;
if (intersectLC(l, us[i].first)){
f[i] = true;
}
}
}
printf("%d\n", res);
}
} | a.cc: In function 'int main()':
a.cc:343:75: error: expected primary-expression before ')' token
343 | norm(us[i].first.p) - us[i].first.r < EPS)){
| ^
|
s846245417 | p00204 | C++ | /*include*/
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#include<complex>
#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()
const double PI=acos(-1);
const double EPS=1e-10;
const double inf=1e8;
using namespace std;
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 intersectCL(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));
}
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 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));
}
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);
}
int main(){
int n;
double R;
while(cin>>R>>n,n){
vector<C>c;
vector<double>v(n);
vector<bool>h(n);
int co=0;
rep(i,n){
double a,b,e;
cin>>a>>b>>e>>v[i];
c.pb(C(P(a,b),e));
}
while(1){
rep(i,n)if(!h[i]){
double d=abs(c[i].c);
P p=c[i].c;
p-=(c[i].c/d*v[i]);
if(abs(p)<R+EPS||d<v[i]+EPS){
h[i]=true;
co++;
}
c[i].c=p;
}
double mi=inf;
int mii=-1;
rep(i,n)if(!h[i])if(mi>abs(c[i].c)){
mi=abs(c[i].c);
mii=i;
}
if(mii==-1)break;
L rz(P(0,0),c[mii].c*100000);
rep(i,n)if(!h[i]&&distanceSP(rz,c[i].c)<c[i].r+EPS)h[i]=true;
}
cout<<co<<endl;
}
} | a.cc: In function 'int main()':
a.cc:291:45: error: no match for 'operator*' (operand types are 'P' {aka 'std::complex<double>'} and 'int')
291 | L rz(P(0,0),c[mii].c*100000);
| ^~~~~~~
| |
| int
In file included from a.cc:11:
/usr/include/c++/14/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)'
400 | operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:400:5: note: template argument deduction/substitution failed:
a.cc:291:46: note: mismatched types 'const std::complex<_Tp>' and 'int'
291 | L rz(P(0,0),c[mii].c*100000);
| ^~~~~~
/usr/include/c++/14/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)'
409 | operator*(const complex<_Tp>& __x, const _Tp& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:409:5: note: template argument deduction/substitution failed:
a.cc:291:46: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'int')
291 | L rz(P(0,0),c[mii].c*100000);
| ^~~~~~
/usr/include/c++/14/complex:418:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)'
418 | operator*(const _Tp& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:418:5: note: template argument deduction/substitution failed:
a.cc:291:46: note: mismatched types 'const std::complex<_Tp>' and 'int'
291 | L rz(P(0,0),c[mii].c*100000);
| ^~~~~~
|
s650049802 | p00204 | C++ | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
/* ??????????????¬ */
#include <complex>
typedef long double ld;
typedef complex<ld> Point;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const ld pi = acos(-1.0);
const ld dtop = pi / 180.;
const ld ptod = 1. / dtop;
namespace std {
bool operator<(const Point &lhs, const Point &rhs) {
if (lhs.real() < rhs.real() - eps) return true;
if (lhs.real() > rhs.real() + eps) return false;
return lhs.imag() < rhs.imag();
}
}
// ????????\???
Point input_point() {
ld x, y;
cin >> x >> y;
return Point(x, y);
}
// ????????????????????????
bool eq(const ld a, const ld b) {
return (abs(a - b) < eps);
}
// ??????
ld dot(const Point& a, const Point& b) {
return real(conj(a) * b);
}
// ??????
ld cross(const Point& a, const Point& b) {
return imag(conj(a) * b);
}
// ??´????????????
class Line {
public:
Point a, b;
Line() : a(Point(0, 0)), b(Point(0, 0)) {}
Line(Point a, Point b) : a(a), b(b) {}
Point operator[](const int _num)const {
if (_num == 0)return a;
else if (_num == 1)return b;
else {
assert(false);
return Point();
}
}
};
// ????????????
class Circle {
public:
Point p;
ld r;
Circle() : p(Point(0, 0)), r(0) {}
Circle(Point p, ld r) : p(p), r(r) {}
};
// CCW
int ccw(const Point& a, const Point &b, const Point &c) {
const Point nb(b - a);
const Point nc(c - a);
if (cross(nb, nc) > eps) return 1; // a,b,c??????????¨???¨?????????????????¶
if (cross(nb, nc) < -eps) return -1; // a,b,c???????¨???¨?????????????????¶
if (dot(nb, nc) < 0) return 2; // c,a,b???????????´???????????¶
if (norm(nb) < norm(nc)) return -2; // a,b,c???????????´???????????¶
return 0; // a,c,b???????????´???????????¶
}
/* ???????????? */
// ??´?????¨??´??????????????????
bool isis_ll(const Line& l, const Line& m) {
return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
// ??´?????¨?????????????????????
bool isis_ls(const Line& l, const Line& s) {
return isis_ll(l, s) &&
(cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}
// ????????¨?????????????????????
bool isis_ss(const Line& s, const Line& t) {
return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
// ????????´????????????
bool isis_lp(const Line& l, const Point& p) {
return (abs(cross(l.b - p, l.a - p)) < eps);
}
// ?????????????????????
bool isis_sp(const Line& s, const Point& p) {
return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
// ??????????¶?
Point proj(const Line &l, const Point& p) {
ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
return l.a + t * (l.a - l.b);
}
// ??´?????¨??´????????????
Point is_ll(const Line &s, const Line& t) {
Point sv = s.b - s.a, tv = t.b - t.a;
assert(cross(sv, tv) != 0);
return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
// ??´?????¨??´????????????
vector<Point> is_ll2(const Line &s, const Line& t) {
Point sv = s.b - s.a, tv = t.b - t.a;
if (cross(sv, tv) != 0)return vector<Point>(1, is_ll(s, t));
else {
vector<Point>ans;
for (int k = 0; k < 2; ++k) {
if (isis_sp(s, t[k]) && find(ans.begin(), ans.end(), t[k]) == ans.end())ans.push_back(t[k]);
if (isis_sp(t, s[k]) && find(ans.begin(), ans.end(), s[k]) == ans.end())ans.push_back(s[k]);
}
return ans;
}
}
// ????????¨???????????????
//???????????£????????¨???????????¨assert(false)
Point is_ss(const Line &s, const Line& t) {
if (isis_ss(s, t)) {
for (int k = 0; k < 2; ++k) {
for (int l = 0; l < 2; ++l) {
if (s[k] == t[l])return s[k];
}
}
return is_ll(s, t);
}
else {
//??????isis_ss?????????
assert(false);
return Point(0, 0);
}
}
// ????????¨???????????????
vector<Point> is_ss2(const Line &s, const Line& t) {
vector<Point> kouho(is_ll2(s, t));
vector<Point>ans;
for (auto p : kouho) {
if (isis_sp(s, p) && isis_sp(t, p))ans.emplace_back(p);
}
return ans;
}
// ??´?????¨???????????¢
ld dist_lp(const Line& l, const Point& p) {
return abs(p - proj(l, p));
}
// ??´?????¨??´???????????¢
ld dist_ll(const Line& l, const Line& m) {
return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
// ??´?????¨??????????????¢
ld dist_ls(const Line& l, const Line& s) {
return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
// ????????¨???????????¢
ld dist_sp(const Line& s, const Point& p) {
Point r = proj(s, p);
return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}
// ????????¨??????????????¢
ld dist_ss(const Line& s, const Line& t) {
if (isis_ss(s, t)) return 0;
return min({ dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b) });
}
//??´?????¨??´?????????????????????????????????
Line bisection(const Line &s, const Line &t) {
const Point laglanju(is_ll(s, t));
const Point avec = !(abs(laglanju - s[0])<eps) ? s[0] - laglanju : s[1] - laglanju;
const Point bvec = !(abs(laglanju - t[0])<eps) ? t[0] - laglanju : t[1] - laglanju;
return Line(laglanju, laglanju + (abs(bvec)*avec + abs(avec)*bvec) / (abs(avec) + abs(bvec)));
}
//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
Point inner_center(const vector<Line>&ls) {
vector<Point>vertics;
for (int i = 0; i <static_cast<int>(ls.size()); ++i) {
vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
}
if (vertics[0] == vertics[1] || vertics[1] == vertics[2] || vertics[2] == vertics[0])return vertics[0];
Line bi1(bisection(Line(vertics[0], vertics[1]), Line(vertics[0], vertics[2])));
Line bi2(bisection(Line(vertics[1], vertics[2]), Line(vertics[1], vertics[0])));
if (bi1[0] == bi2[0])return bi1[0];
else {
return is_ll(bi1, bi2);
}
}
//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
vector<Point> ex_center(const vector<Line>&ls) {
vector<Point>vertics;
for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
}
if (abs(vertics[0] - vertics[1])<eps || abs(vertics[1] - vertics[2])<eps || (abs(vertics[2] - vertics[0])<eps))return vector<Point>();
vector<Point>ecs;
for (int i = 0; i < 3; ++i) {
Line bi1(bisection(Line(vertics[i], vertics[i] * 2.0l - vertics[(i + 2) % 3]), Line(vertics[i], vertics[(i + 1) % 3])));
Line bi2(bisection(Line(vertics[(i + 1) % 3], vertics[(i + 1) % 3] * 2.0l - vertics[(i + 2) % 3]), Line(vertics[(i + 1) % 3], vertics[i])));
ecs.push_back(is_ll(bi1, bi2));
}
return ecs;
}
//a,b:??????
//c:????????§??????
//???????????´?????????????????¢?????????????±??????????
vector<Point> same_dis(const vector<Line>&ls) {
vector<Point>vertics;
vertics.push_back(is_ll(ls[0], ls[2]));
vertics.push_back(is_ll(ls[1], ls[2]));
if (abs(vertics[0] - vertics[1]) < eps)return vector<Point>{vertics[0]};
Line bis(bisection(ls[0], ls[1]));
vector<Point>ecs;
Line abi(bisection(Line(vertics[0], vertics[1]), ls[0]));
ecs.push_back(is_ll(bis, abi));
Line bbi(bisection(Line(vertics[0], 2.l*vertics[0] - vertics[1]), ls[0]));
ecs.push_back(is_ll(bis, bbi));
return ecs;
}
/* ??? */
// ?????¨????????????
vector<Point> is_cc(const Circle& c1, const Circle& c2) {
vector<Point> res;
ld d = abs(c1.p - c2.p);
ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
ld dfr = c1.r * c1.r - rc * rc;
if (abs(dfr) < eps) dfr = 0.0;
else if (dfr < 0.0) return res; // no intersection
ld rs = sqrt(dfr);
Point diff = (c2.p - c1.p) / d;
res.push_back(c1.p + diff * Point(rc, rs));
if (dfr != 0.0) res.push_back(c1.p + diff * Point(rc, -rs));
return res;
}
//???????????????????????????
// 0 => out
// 1 => on
// 2 => in
int is_in_circle(const Circle &cir, const Point& p) {
ld dis = abs(cir.p - p);
if (dis > cir.r + eps)return 0;
else if (dis < cir.r - eps)return 2;
else return 1;
}
//???lc??????rc??????????????????
// 0 => out
// 1 => on
// 2 => in
int circle_in_circle(const Circle &lc, const Circle&rc) {
ld dis = abs(lc.p - rc.p);
if (dis < rc.r - lc.r - eps)return 2;
else if (dis>rc.r - lc.r + eps)return 0;
else return 1;
}
// ?????¨??´????????????
vector<Point> is_lc(const Circle& c, const Line& l) {
vector<Point> res;
ld d = dist_lp(l, c.p);
if (d < c.r + eps) {
ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); //safety;
Point nor = (l.a - l.b) / abs(l.a - l.b);
res.push_back(proj(l, c.p) + len * nor);
res.push_back(proj(l, c.p) - len * nor);
}
return res;
}
// ?????¨??????????????¢
vector<Point> is_sc(const Circle& c, const Line& l) {
vector<Point> v = is_lc(c, l), res;
for (Point p : v)
if (isis_sp(l, p)) res.push_back(p);
return res;
}
// ?????¨????????\???
vector<Line> tangent_cp(const Circle& c, const Point& p) {
vector<Line> ret;
Point v = c.p - p;
ld d = abs(v);
ld l = sqrt(norm(v) - c.r * c.r);
if (isnan(l)) { return ret; }
Point v1 = v * Point(l / d, c.r / d);
Point v2 = v * Point(l / d, -c.r / d);
ret.push_back(Line(p, p + v1));
if (l < eps) return ret;
ret.push_back(Line(p, p + v2));
return ret;
}
// ?????¨????????\???
vector<Line> tangent_cc(const Circle& c1, const Circle& c2) {
vector<Line> ret;
if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
Point center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
ret = tangent_cp(c1, center);
}
if (abs(c1.r - c2.r) > eps) {
Point out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
vector<Line> nret = tangent_cp(c1, out);
ret.insert(ret.end(), ALL(nret));
}
else {
Point v = c2.p - c1.p;
v /= abs(v);
Point q1 = c1.p + v * Point(0, 1) * c1.r;
Point q2 = c1.p + v * Point(0, -1) * c1.r;
ret.push_back(Line(q1, q1 + v));
ret.push_back(Line(q2, q2 + v));
}
return ret;
}
//??????????????????????????¢???
ld two_circle_area(const Circle&l, const Circle&r) {
ld dis = abs(l.p - r.p);
if (dis > l.r + r.r)return 0;
else if (dis + r.r < l.r) {
return r.r*r.r*pi;
}
else if (dis + l.r < r.r) {
return l.r*l.r*pi;
}
else {
ld ans = (l.r)*(l.r)*acos((dis*dis + l.r*l.r - r.r*r.r) / (2 * dis*l.r)) +
(r.r)*(r.r)*acos((dis*dis + r.r*r.r - l.r*l.r) / (2 * dis*r.r)) -
sqrt(4 * dis*dis*l.r*l.r - (dis*dis + l.r*l.r - r.r*r.r)*(dis*dis + l.r*l.r - r.r*r.r)) / 2;
return ans;
}
}
/* ????§???¢ */
typedef vector<Point> Polygon;
// ??¢???
ld area(const Polygon &p) {
ld res = 0;
int n = p.size();
REP(j, n) res += cross(p[j], p[(j + 1) % n]);
return res / 2;
}
// ????§???¢????????¢??????
bool is_counter_clockwise(const Polygon &poly) {
ld angle = 0;
int n = poly.size();
REP(i, n) {
Point a = poly[i], b = poly[(i + 1) % n], c = poly[(i + 2) % n];
angle += arg((c - b) / (b - a));
}
return angle > eps;
}
// ??????????????????
// 0 => out
// 1 => on
// 2 => in
int is_in_polygon(const Polygon &poly, const Point& p) {
ld angle = 0;
int n = poly.size();
REP(i, n) {
Point a = poly[i], b = poly[(i + 1) % n];
if (isis_sp(Line(a, b), p)) return 1;
angle += arg((b - p) / (a - p));
}
return eq(angle, 0) ? 0 : 2;
}
//??????????????????2?????????
enum { OUT, ON, IN };
int convex_contains(const Polygon &P, const Point &p) {
const int n = P.size();
Point g = (P[0] + P[n / 3] + P[2 * n / 3]) / 3.0l; // inner-point
int a = 0, b = n;
while (a + 1 < b) { // invariant: c is in fan g-P[a]-P[b]
int c = (a + b) / 2;
if (cross(P[a] - g, P[c] - g) > 0) { // angle < 180 deg
if (cross(P[a] - g, p - g) > 0 && cross(P[c] - g, p - g) < 0) b = c;
else a = c;
}
else {
if (cross(P[a] - g, p - g) < 0 && cross(P[c] - g, p - g) > 0) a = c;
else b = c;
}
}
b %= n;
if (cross(P[a] - p, P[b] - p) < 0) return 0;
if (cross(P[a] - p, P[b] - p) > 0) return 2;
return 1;
}
// ??????
// ???????????????????????¨????????????????????§??¨???
Polygon convex_hull(vector<Point> ps) {
int n = ps.size();
int k = 0;
sort(ps.begin(), ps.end());
Polygon ch(2 * n);
for (int i = 0; i < n; ch[k++] = ps[i++])
while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
ch.resize(k - 1);
return ch;
}
// ????????????
vector<Polygon> convex_cut(const Polygon &ps, const Line& l) {
int n = ps.size();
Polygon Q;
Polygon R;
REP(i, n) {
Point A = ps[i], B = ps[(i + 1) % n];
Line m = Line(A, B);
if (ccw(l.a, l.b, A) != -1) Q.push_back(A);
if (ccw(l.a, l.b, A) != 1) R.push_back(A);
if (ccw(l.a, l.b, A) * ccw(l.a, l.b, B) < 0 && isis_ll(l, m)) {
Q.push_back(is_ll(l, m));
R.push_back(is_ll(l, m));
}
}
const vector<Polygon>polys{ Q,R };
return polys;
}
/* ??¢??¬??????????????? */
void add_point(vector<Point> &ps, const Point p) {
for (Point q : ps) if (abs(q - p) < eps) return;
ps.push_back(p);
}
typedef int Weight;
struct Edge {
int src, dst;
Weight weight;
Edge(int src, int dst, Weight weight) :
src(src), dst(dst), weight(weight) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, const int from, const int to, const Weight weight) {
g[from].push_back(Edge{ from, to, weight });
}
Graph segment_arrangement(const vector<Line> &s, const vector<Point> &p) {
int n = p.size(), m = s.size();
Graph g(n);
REP(i, m) {
vector<pair<ld, int>> vec;
REP(j, n) if (isis_sp(s[i], p[j]))
vec.emplace_back(abs(s[i].a - p[j]), j);
sort(ALL(vec));
REP(j, vec.size() - 1) {
int from = vec[j].second, to = vec[j + 1].second;
add_edge(g, from, to, static_cast<Weight>(abs(p[from] - p[to])));
}
}
return g;
}
Graph sennbunn_arrangement(const vector<Line>&s) {
vector<Point>crss;
for (int i = 0; i < static_cast<int>(s.size()); ++i) {
for (int j = i + 1; j < static_cast<int>(s.size()); ++j) {
if (isis_ss(s[i], s[j])) {
crss.push_back(is_ll(s[i], s[j]));
}
}
}
for (int i = 0; i <static_cast<int>(s.size()); ++i) {
crss.push_back(s[i][0]);
crss.push_back(s[i][1]);
}
return segment_arrangement(s, crss);
}
//Graph circle_arrangement(const vector<Circle> &c, const vector<Point> &p) {
// int n = p.size(), m = c.size();
// Graph g(n);
// REP(i, m) {
// vector<pair<ld, int>> vec;
// REP(j, n) if (abs(abs(c[i].p - p[j]) - c[i].r) < eps)
// vec.emplace_back(arg(c[i].p - p[j]), j);
// sort(ALL(vec));
// REP(j, vec.size() - 1) {
// int from = vec[j].second, to = vec[j + 1].second;
// ld angle = vec[j + 1].first - vec[j].first;
// add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
// }
// if (vec.size() >= 2) {
// int from = vec.back().second, to = vec.front().first;
// ld angle = vec.front().first - vec.back().first;
// add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
// }
// }
// return g;
//}
/* ????????°?????? */
// ?????????????????¢?????¢??¬??????????????????????????????????????°???????????????
// ?????´?????????????¨?????????§????????´????????????????¨?????????§???????????????
// ?????° polygon ??????vector<int> ??§??¨?????????????§???¢???????????§?????????
// vector<int> ??§??¨????????? ????§???¢???i???????????????????????????????????????p????????????????????§?????????
vector<vector<int>> polygon;
vector<int> seg2p[1024][1024];
//Graph dual_graph(const vector<Line> &s, const vector<Point> &p) {
// int N = p.size();
// polygon.clear();
// REP(i, 1024) REP(j, 1024) seg2p[i][j].clear();
// vector<vector<tuple<ld, int, bool>>> tup(N);
// REP(i, s.size()) {
// int a = -1, b = -1;
// REP(j, N) if (abs(s[i].a - p[j]) < eps) a = j;
// REP(j, N) if (abs(s[i].b - p[j]) < eps) b = j;
// assert(a >= 0 && b >= 0);
// tup[a].emplace_back(arg(s[i].b - s[i].a), b, false);
// tup[b].emplace_back(arg(s[i].a - s[i].b), a, false);
// }
// REP(i, N) sort(ALL(tup[i]));
// REP(i, N) {
// REP(j, tup[i].size()) {
// ld angle; int pos = j, from = i, to; bool flag;
// tie(angle, to, flag) = tup[i][j];
// if (flag) continue;
// vector<int> ps;
// while (!flag) {
// ps.push_back(from);
// get<2>(tup[from][pos]) = true;
// seg2p[from][to].push_back(polygon.size());
// seg2p[to][from].push_back(polygon.size());
// angle += pi + eps;
// if (angle > pi) angle -= 2 * pi;
// auto it = lower_bound(ALL(tup[to]), make_tuple(angle, 0, false));
// if (it == tup[to].end()) it = tup[to].begin();
// from = to; tie(angle, to, flag) = *it;
// pos = it - tup[from].begin();
// }
// polygon.push_back(ps);
// }
// }
//int aa = 0;
//ld amax = 0;
//for (int i = 0; i < int(polygon.size()); ++i) {
// vector<Point>ps;
// for (auto id : polygon[i]) {
// ps.push_back(p[id]);
// }
// ld aarea = area(p);
// if (amax < aarea) {
// aa = i;
// amax = aarea;
// }
//}
// Graph g(polygon.size());
// REP(i, N) REP(j, i) {
// if (seg2p[i][j].size() == 2) {
// int from = seg2p[i][j][0], to = seg2p[i][j][1];
// g[from].push_back(Edge{ from, to });
// g[to].push_back(Edge{ to, from });
// }
// }
// return g;
//}
struct ufo {
Circle c;
Point v;
};
int main() {
while (1) {
int R, N; cin >> R >> N;
if (!R)break;
vector<ufo>us;
for (int i = 0; i < N; ++i) {
ld x, y, r, v; cin >> x >> y >> r >> v;
Point p(x, y);
us.push_back(ufo{ Circle(p,r) , Point(v*(-x) / abs(p), v*(-y) / abs(p))});
}
int ans = 0;
while (1) {
{
vector<ufo>nextus;
for (auto u : us) {
if (abs(u.c.p) - R < abs(u.v))ans++;
else {
u.c.p += u.v;
nextus.emplace_back(u);
}
}
us = nextus;
}
if (us.empty())break;
else {
auto it = min_element(us.begin(), us.end(), [](const ufo&l, const ufo&r) {
return abs(l.c.p) < abs(r.c.p); });
ld px = it->c.p.real();
ld py = it->c.p.imag();
Line l(Point(R*px/abs(it->c.p), R*py / abs(it->c.p)), Point(5000.l*it->c.p / abs(it->c.p))));
{
vector<ufo>nextus;
for (auto u : us) {
if (is_sc(u.c, l).empty()) {
nextus.emplace_back(u);
}
}
us = nextus;
}
}
}
cout << ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:658:124: error: expected ',' or ';' before ')' token
658 | Line l(Point(R*px/abs(it->c.p), R*py / abs(it->c.p)), Point(5000.l*it->c.p / abs(it->c.p))));
| ^
|
s933828040 | p00204 | C++ | #include<iostream>
#define PI 3.141592653589793
using namespace std;
struct tagUFO{
tagUFO*pBefore;
tagUFO*pNext;
double x;//??§?¨?x
double y;//??§?¨?y
int r;//UFO?????????
int v;//UFO?????????(??????)
double Distance;
};
void AddUFO(tagUFO*p);
tagUFO*DeleteUFO(tagUFO*pDelete);
int ShotUFO(tagUFO*pAimedUFO, tagUFO*pShotUFO, int R);
tagUFO*pFirst = NULL;
tagUFO*pLast = NULL;
int main() {
while (true) {
int R;//??¬?????¶???????¨???????????????????????????????
int N;//UFO?????°
tagUFO*p;
int InvadingUFO = 0;
cin >> R >> N;
if (R == 0 && N == 0)break;//0 0?????\?????????????????????
for (int i = 0; i < N; i++) {
p = new tagUFO;
cin >> p->x >> p->y >> p->r >> p->v;
p->Distance = sqrt(p->x*p->x + p->y*p->y);
//??????????????§??????R??????UFO?????????
if (p->Distance < R) {
InvadingUFO++;
delete p;
}
else
AddUFO(p);
}
p = pFirst;
while (p!=NULL) {
//UFO?????§?¨????1???????????´??°
while (p != NULL) {
p->x -= p->x*p->v / p->Distance;
p->y -= p->y*p->v / p->Distance;
p->Distance = sqrt(p->x*p->x + p->y*p->y);
p = p->pNext;
}
//??????R??????UFO?????????
p = pFirst;
while (p != NULL) {
if (p->Distance < R) {
InvadingUFO++;
p = DeleteUFO(p);
}
else
p = p->pNext;
}
//UFO???????¢?
p = pFirst;
double Nearest = p->Distance;
p = p->pNext;
while (p != NULL) {
if (p->Distance < Nearest)
Nearest = p->Distance;
p = p->pNext;
}
p = pFirst;
while (p != NULL) {
if (p->Distance == Nearest) {
tagUFO tmp = *p;
p = pFirst;
while (p != 0) {
if (ShotUFO(&tmp, p, R)) {
p = DeleteUFO(p);
}
else {
p = p->pNext;
}
}
break;
}
p = p->pNext;
}
p = pFirst;
}
tagUFO*pNext = pFirst;
while (pNext) {
p = pNext;
pNext = p->pNext;
delete p;
}
pFirst = pLast = NULL;
//??????????????????R???????????\??????UFO?????°?????????
cout << InvadingUFO << endl;
}
return 0;
}
void AddUFO(tagUFO*pAdd) {
if (!pFirst)
pFirst = pAdd;
if (pLast)
pLast->pNext = pAdd;
pAdd->pBefore = pLast;
pAdd->pNext = NULL;
pLast = pAdd;
}
tagUFO*DeleteUFO(tagUFO*pDelete) {
tagUFO*pReturn = pDelete->pNext;
if (pDelete->pBefore)
pDelete->pBefore->pNext = pReturn;
else
pFirst = pReturn;
if (pReturn)
pReturn->pBefore = pDelete->pBefore;
else
pLast = pDelete->pBefore;
delete pDelete;
return pReturn;
}
int ShotUFO(tagUFO*pAimedUFO,tagUFO*pShotUFO,int R) {
double AimedUFOAngle = atan(pAimedUFO->y / pAimedUFO->x);
if (pAimedUFO->x < 0) {
AimedUFOAngle += PI;
}
else if (pAimedUFO->y < 0) {
AimedUFOAngle += 2 * PI;
}
double ShotUFOCenterAngle = atan(pShotUFO->y / pShotUFO->x);
if (pShotUFO->x < 0) {
ShotUFOCenterAngle += PI;
}
else if (pShotUFO->y < 0) {
ShotUFOCenterAngle += 2 * PI;
}
double ShotUFORangeAngle;
if ((pShotUFO->Distance*pShotUFO->Distance - pShotUFO->r*pShotUFO->r) > R*R) {
ShotUFORangeAngle = asin(pShotUFO->r / pShotUFO->Distance);
}
else if (pShotUFO->Distance + R>pShotUFO->r) {
ShotUFORangeAngle = acos((pShotUFO->r*pShotUFO->r + R*R - pShotUFO->Distance*pShotUFO->Distance) / (2 * pShotUFO->r*R));
}
else {
return 1;
}
if (ShotUFOCenterAngle - ShotUFORangeAngle <= AimedUFOAngle&&AimedUFOAngle <= ShotUFOCenterAngle + ShotUFORangeAngle)
return 1;
else if (ShotUFOCenterAngle - ShotUFORangeAngle + PI <= AimedUFOAngle&&AimedUFOAngle <= ShotUFOCenterAngle + ShotUFORangeAngle + PI)
return 1;
else if (ShotUFOCenterAngle - ShotUFORangeAngle <= AimedUFOAngle + PI&&AimedUFOAngle + PI <= ShotUFOCenterAngle + ShotUFORangeAngle)
return 1;
else
return 0;
} | a.cc: In function 'int main()':
a.cc:37:39: error: 'sqrt' was not declared in this scope
37 | p->Distance = sqrt(p->x*p->x + p->y*p->y);
| ^~~~
a.cc:54:47: error: 'sqrt' was not declared in this scope
54 | p->Distance = sqrt(p->x*p->x + p->y*p->y);
| ^~~~
a.cc: In function 'int ShotUFO(tagUFO*, tagUFO*, int)':
a.cc:139:32: error: 'atan' was not declared in this scope
139 | double AimedUFOAngle = atan(pAimedUFO->y / pAimedUFO->x);
| ^~~~
a.cc:157:37: error: 'asin' was not declared in this scope
157 | ShotUFORangeAngle = asin(pShotUFO->r / pShotUFO->Distance);
| ^~~~
a.cc:160:37: error: 'acos' was not declared in this scope
160 | ShotUFORangeAngle = acos((pShotUFO->r*pShotUFO->r + R*R - pShotUFO->Distance*pShotUFO->Distance) / (2 * pShotUFO->r*R));
| ^~~~
|
s925307080 | p00204 | C++ | #include <iostream>
#include <vector>
#include <stack>
#include <tuple>
#include <functional>
#include <type_traits>
#include <cmath>
#include <algorithm>
constexpr long double pi = 3.14159265359;
template <typename F, typename Func>
auto map(Func func, const F &vec) -> std::vector<typename decltype(func(*vec.begin()))>{
std::vector<decltype(func(*vec.begin()))> res(vec.size());
int idx{ 0 };
for (const auto &v : vec) {
res[idx++] = func(v);
}
return res;
}
template <typename F, typename Func>
auto filter(Func func, const F &traversable)->std::vector<typename std::remove_reference<decltype(*traversable.begin())>::type> {
std::vector<typename std::remove_reference<decltype(*traversable.begin())>::type> res;
for (const auto &v : traversable) {
if (func(v))
res.push_back(v);
}
return res;
}
template<typename F, typename Func>
void inner_filter(Func func, std::vector<F> &traversable) {
int idx{ 0 };
for (unsigned int i = 0; i < traversable.size(); ++i) {
if (func(traversable[i])) {
traversable[idx++] = std::move(traversable[i]);
}
}
traversable.resize(idx);
}
struct Point {
long double x, y;
Point(long double ax, long double ay) :x{ ax }, y{ ay } {}
Point() {}
};
struct Angle {
long double sin, cos;
Angle(long double s, long double c) :sin{ (s > 1) ? 1 : (s < -1) ? -1 : s }, cos{ (c > 1) ? 1 : (c < -1) ? -1 : c } {};
static Angle to_angle(long double x, long double y);
Angle operator+(const Angle other) const;
Angle operator-(const Angle other) const;
long double to_radian() const;
};
struct Vector {
long double x, y;
long double length() const;
Angle angle() const;
Vector(const Point from, const Point to);
Vector(const long double ax, const long double ay) :x{ ax }, y{ ay } {}
Vector(const Point p) :x{ p.x }, y{ p.y } {}
Vector() {}
Point end_point() const;
};
struct UFO {
Point center;
long double radius, velocity;
UFO(long double x, long double y, long double r, long double v);
UFO() { };
Point position(int time) const;
Angle angle() const;
};
Angle Angle::to_angle(long double x, long double y)
{
return Angle(y / std::sqrt(x * x + y * y), x / std::sqrt(x * x + y * y));
}
Angle Angle::operator+(const Angle other) const
{
return Angle(sin * other.cos + cos * other.sin, cos * other.cos - sin * other.sin);
}
Angle Angle::operator-(const Angle other) const
{
return Angle(sin * other.cos - cos * other.sin, cos * other.cos + sin * other.sin);
}
long double Angle::to_radian() const
{
return (sin >= 0) ? std::acos(cos) : 2 * pi - std::acos(cos);
}
long double Vector::length() const
{
return std::sqrt(x * x + y * y);
}
Angle Vector::angle() const
{
return Angle::to_angle(x, y);
}
Vector::Vector(const Point from, const Point to) :x{ to.x - from.x }, y{ to.y - from.y }
{
}
Point Vector::end_point() const
{
return Point(x, y);
}
Point operator+(const Point p, const Vector v) {
return Point{ p.x + v.x, p.y + v.y };
}
Point operator-(const Point p, const Vector v)
{
return Point{ p.x - v.x, p.y - v.y };
}
Vector operator*(const Vector v, const long double d) {
return Vector{ v.x * d, v.y * d };
}
Vector operator*(const Vector v, const int d)
{
return Vector{ v.x * d, v.y * d };
}
Vector operator*(const long double d, const Vector v) {
return Vector{ v.x * d, v.y * d };
}
Vector operator*(const int d, const Vector v)
{
return Vector(d * v.x, d * v.y);
}
UFO::UFO(long double x, long double y, long double r, long double v) :center{ x, y }, radius{ r }, velocity{ v }
{
}
Point UFO::position(int time) const
{
auto reach_time = Vector(center).length() / velocity;
if (reach_time <= time) return Point(0, 0);
return ((reach_time - time) / reach_time * Vector(center)).end_point();
}
Angle UFO::angle() const
{
return Angle::to_angle(center.x, center.y);
}
bool is_shooted(const UFO ufo, const Angle razer, int time) {
auto ufo_pos = ufo.position(time);
auto relative_razer = razer - ufo.angle();
auto sin = ufo.radius / Vector(ufo_pos).length();
auto projection_ufo = Angle(sin, std::sqrt(1 - sin * sin));
return !(projection_ufo.to_radian() < relative_razer.to_radian() && relative_razer.to_radian() < Angle(-projection_ufo.sin, projection_ufo.cos).to_radian());
}
int solve(std::vector<UFO> &ufos, int rad, int time = 1) {
if (ufos.size() == 0) return 0;
auto ufo_count = ufos.size();
inner_filter([time, rad](const UFO ufo) {return Vector(ufo.position(time)).length() >= rad; }, ufos);
auto through = ufo_count - ufos.size();
std::sort(ufos.begin(), ufos.end(), [time](const UFO a, const UFO b) {return Vector(a.position(time)).length() > Vector(b.position(time)).length(); });
auto target = ufos.back();
inner_filter([time, target](const UFO ufo) {return !is_shooted(ufo, target.angle(), time); }, ufos);
return through + solve(ufos, rad, time + 1);
}
void f(int rad, int n) {
if (n != 0 && rad != 0) {
std::vector<UFO> ufos(n);
{
int x, y, r, v;
for (auto &ufo : ufos) {
std::cin >> x >> y >> r >> v;
ufo = UFO(x, y, r, v);
}
}
std::cout << solve(ufos, rad) << std::endl;
std::cin >> rad >> n;
f(rad, n);
}
}
int main() {
int r, n;
std::cin >> r >> n;
f(r, n);
}
| a.cc:11:87: error: template argument 1 is invalid
11 | auto map(Func func, const F &vec) -> std::vector<typename decltype(func(*vec.begin()))>{
| ^
a.cc:11:87: error: template argument 2 is invalid
a.cc:11:87: error: template argument 1 is invalid
a.cc:11:87: error: template argument 2 is invalid
a.cc:11:87: error: template argument 1 is invalid
a.cc:11:87: error: template argument 2 is invalid
a.cc:11:38: error: invalid template-id
11 | auto map(Func func, const F &vec) -> std::vector<typename decltype(func(*vec.begin()))>{
| ^~~
a.cc:11:59: error: expected nested-name-specifier before 'decltype'
11 | auto map(Func func, const F &vec) -> std::vector<typename decltype(func(*vec.begin()))>{
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:59: error: expected '(' before 'decltype'
11 | auto map(Func func, const F &vec) -> std::vector<typename decltype(func(*vec.begin()))>{
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| (
a.cc:11:59: error: expected '>' before 'decltype'
11 | auto map(Func func, const F &vec) -> std::vector<typename decltype(func(*vec.begin()))>{
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:1: error: deduced class type 'vector' in function return type
11 | auto map(Func func, const F &vec) -> std::vector<typename decltype(func(*vec.begin()))>{
| ^~~~
In file included from /usr/include/c++/14/vector:66,
from a.cc:2:
/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>
| ^~~~~~
|
s367515951 | p00204 | C++ | #include <cstdio>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
#define EPS 1e-6
typedef complex<double> P;
struct L : public vector<P> {
L(const P &a, const P &b) {
push_back(a); push_back(b);
}
};
struct C {
P p; double r;
C(const P &p, double r) : p(p), r(r) { }
};
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);
}
double dist(const P& a, const P& b)
{
return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}
bool intersectSC(const L& l, const C& c)
{
double vc=dot(l[1]-l[0], c.p-l[0]);
if(vc<0)
{
double dif=c.r-dist(l[0], c.p);
return dif+EPS > 0;
}
double vv=dot(l[1]-l[0], l[1]-l[0]);
if(vc > vv)
{
double d=dist(l[1], c.p);
double dif=c.r*c.r-d*d;
return dif+EPS > 0;
}
double cc=dot(c.p-l[0], c.p-l[0]);
double dif=c.r*c.r-(cc-(vc/vv)*vc);
return dif+EPS > 0;
}
class UFO
{
public:
C c;
int v;
double d;
UFO(C c, int v, double d)
:c(c),v(v),d(d)
{}
bool operator<(const UFO& u) const
{
return d>u.d;
}
};
int main()
{
int R,N;
while(cin >> R >> N)
{
priority_queue<UFO> q;
while(N--)
{
int x,y,r,v;
cin >> x >> y >> r >> v;
q.push(UFO(C(P(x,y),r),v, dist(P(0,0), P(x,y))));
}
int cnt=0;
while(!q.empty())
{
UFO u=q.top(); q.pop();
if(u.d < R+EPS)
{
cnt++;
continue;
}
priority_queue<UFO> tq;
L s(P(0,0),P(u.c.p.real()*1000, u.c.p.imag()*1000));
while(!q.empty())
{
UFO uf=q.top(); q.pop();
if(intersectSC(s, uf.c)) continue;
tq.push(UFO(uf.c, uf.v, uf.d-uf.v));
}
while(!tq.empty())
{
q.push(tq.top()); tq.pop();
}
}
cout << cnt << endl;
}
} | a.cc: In function 'int main()':
a.cc:80:15: error: 'cin' was not declared in this scope
80 | while(cin >> R >> N)
| ^~~
a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
6 | #include <queue>
+++ |+#include <iostream>
7 | using namespace std;
a.cc:115:17: error: 'cout' was not declared in this scope
115 | cout << cnt << endl;
| ^~~~
a.cc:115:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s625529397 | p00204 | C++ | #include <cstdio>
#include <complex>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
using namespace std;
#define EPS 1e-6
typedef complex<double> P;
struct L : public vector<P> {
L(const P &a, const P &b) {
push_back(a); push_back(b);
}
};
struct C {
P p; double r;
C(const P &p, double r) : p(p), r(r) { }
};
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);
}
double dist(const P& a, const P& b)
{
return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}
bool isIntoC(const P& p, const C& c)
{
return dist(p, c.p) < c.r+EPS;
}
bool isIntoC(const L& l, const C& c)
{
return dist(l[0], c.p) < c.r+EPS && dist(l[1], c.p) < c.r+EPS;
}
int CrossPtNum(const C& c, const L& l)
{
P LV=l[0]-l[1];
double A=(LV.real()*LV.real())+(LV.imag()*LV.imag());
double B=(LV.real()*l[0].real())-(LV.real()*c.p.real())+(LV.imag()*l[0].imag())-(LV.imag()*c.p.imag());
double C=(l[0].real()-c.p.real())*(l[0].real()-c.p.real())+(l[0].imag()-c.p.imag())*(l[0].imag()-c.p.imag())-(c.r*c.r);
if(fabs(B*B-A*C) < EPS) return 1;
if(B*B-A*C > 0) return 2;
return 0;
}
bool intersectSC(const L& l, const C& c)
{
if(isIntoC(l, c)) return false;
double vc=dot(l[1]-l[0], c.p-l[0]);
if(vc<0)
{
double dif=c.r-dist(l[0], c.p);
return dif+EPS > 0;
}
double vv=dot(l[1]-l[0], l[1]-l[0]);
if(vc > vv)
{
double d=dist(l[1], c.p);
double dif=c.r*c.r-d*d;
return dif+EPS > 0;
}
double cc=dot(c.p-l[0], c.p-l[0]);
double dif=c.r*c.r-(cc-(vc/vv)*vc);
return dif+EPS > 0;
}
class UFO
{
public:
double x,y,r,v,d,dx,dy;
UFO(int X, int Y, int R, int V)
{
x=X;
y=Y;
r=R;
v=V;
d=sqrt(x*x+y*y);
dx=v*x/d;
dy=v*y/d;
}
int move()
{
x-=dx;
y-=dy;
d=sqrt(x*x+y*y);
return d;
}
};
int main()
{
int R,N,x,y,r,v;
while(cin >> R >> N, (R||N))
{
list<UFO> ls;
while(N--)
{
cin >> x >> y >> r >> v;
ls.push_back(UFO(x,y,r,v));
}
int cnt = 0;
while(true)
{
double md = 1e20;
double mx,my;
for(list<UFO>::iterator it=ls.begin(); it!=ls.end();)
{
it->move();
if(it->d <= R)
{
it = ls.erase(it);
cnt++;
}
else
{
if(md>it->d)
{
mx=it->x;
my=it->y;
md=it->d;
}
it++;
}
}
if(ls.empty()) { cout << cnt << endl; break; }
L laser(P(0,0),P(mx*1000,my*1000));
for(list<UFO>::iterator it=ls.begin(); it!=ls.end();)
{
C ufo(P(it->x,it->y),it->r);
if(intersectSC(laser,ufo))
{
it = ls.erase(it);
}
else
{
it++;
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:115:15: error: 'cin' was not declared in this scope
115 | while(cin >> R >> N, (R||N))
| ^~~
a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
6 | #include <cmath>
+++ |+#include <iostream>
7 | using namespace std;
a.cc:148:42: error: 'cout' was not declared in this scope
148 | if(ls.empty()) { cout << cnt << endl; break; }
| ^~~~
a.cc:148:42: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s343630965 | p00204 | C++ | #include<iostream>
#include<vector>
#include<complex>
#include<list>
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
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])));
}
P crosspoint(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
if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
return m[0] + B / A * (m[1] - m[0]);
}
struct U{
P p,dp; double r,v;
U(P p,double r,double v):p(p),r(r),v(v){
dp=p*v/P(abs(p),0);
}
};
int main(){
int r,n; P O(0,0);
while(cin>>r>>n,n){
list<U> u;
double x,y,r_,v,mn;
rep(i,n)cin>>x>>y>>r_>>v, u.push_back(U(P(x,y),r_,v));
int t=1,ans=0;
foreach(i,u){
if(norm(i->p)<=r*r)i=u.erase(i),i--,ans++;
else i->p-=i->dp;
}
while(!u.empty()){
mn=INF; P closest;
foreach(i,u){
P prev=i->p+i->dp;
if(distanceSP(L(i->p,prev),O)<=r)i=u.erase(i),i--,ans++;
else if(norm(i->p)<mn)closest=i->p,mn=norm(i->p);
}
foreach(i,u){
if(distanceSP(L(closest*P(INF,0),O),i->p)<=i->r)i=u.erase(i),i--;
else i->p-=i->dp;
}
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'P crosspoint(const L&, const L&)':
a.cc:91:21: error: 'assert' was not declared in this scope
91 | if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
| ^~~~~~
a.cc:5:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
4 | #include<list>
+++ |+#include <cassert>
5 | #define rep(i,n) for(int i=0;i<n;i++)
|
s527932314 | p00204 | C++ | define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>
using namespace std;
typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-12;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
int R;
double x[200], y[200], r[200], v[200];
double dis[200];
bool used[200];
double dot(const xy_t &a, const xy_t &b){
return real(conj(a) * b);
}
xy_t projection(const line &l, const xy_t &p){
double t = dot(l.second - l.first, p - l.first) / norm(l.second - l.first);
return l.first + t * (l.second - l.first);
}
bool intersectSP(const line &l, const xy_t &p){
return abs(l.first - p) + abs(l.second - p) - abs(l.second - l.first) < EPS;
}
double distanceSP(const line &l, const xy_t &p){
xy_t r = projection(l, p);
if(intersectSP(l, r)) return abs(r - p);
else return min(abs(l.first - p), abs(l.second - p));
}
int main(){
int n, cnt;
while(cin >> R >> n && (R || n)){
cnt = 0;
memset(used, false, sizeof(used));
rep(i, n){
cin >> x[i] >> y[i] >> r[i] >> v[i];
dis[i] = sqrt((double)x[i]*x[i]+y[i]*y[i]);
}
rep(i, n){
rep(j, n){
if(used[j]) continue;
dis[j] -= v[j];
double ang = atan2(y[j], x[j]);
y[j] -= v[j] * sin(ang);
x[j] -= v[j] * cos(ang);
// cout << j << " " << "( " << x[j] << ", " << y[j] << ")" << endl;
}
// cout << cnt << endl;
rep(j, n){
if(!used[j]){
if(dis[j] < R + EPS){
cnt++;
used[j] = true;
}
}
}
int id = 0;
double best = 1e10;
rep(j, n){
if(!used[j] && dis[j] < best){
best = dis[j];
id = j;
}
}
double ang = atan2(y[id], x[id]);
line l = line(xy_t(R * cos(ang), R*sin(ang)), xy_t(cos(ang), sin(ang)) * 1e10);
rep(j, n){
if(!used[j] && distanceSP(l, xy_t(x[j], y[j])) < r[j] + EPS){
used[j] = true;
}
}
}
cout << cnt << endl;
}
return 0;
} | a.cc:1:1: error: 'define' does not name a type
1 | define _USE_MATH_DEFINES
| ^~~~~~
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
In file included from /usr/include/wchar.h:35,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared
140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared
142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:145:52: error: expected primary-expression before 'const'
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:147:54: error: expected primary-expression before 'const'
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive]
155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:156:70: error: expected primary-expression before 'const'
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive]
163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:164:72: error: expected primary-expression before 'const'
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared
171 | void operator delete(void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared
173 | void operator delete[](void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function
179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
179 | _GLI |
s335041013 | p00204 | C++ | import java.util.Scanner;
//UFO Shooting Down Operation
public class Main{
double dot(double[] a, double[] b){
return a[0]*b[0]+a[1]*b[1];
}
void run(){
Scanner sc = new Scanner(System.in);
while(true){
int R = sc.nextInt();
int n = sc.nextInt();
if((R|n)==0)break;
int[][] ufo = new int[n][4];
for(int i=0;i<n;i++)for(int j=0;j<4;j++)ufo[i][j]=sc.nextInt();
double[] dist = new double[n];
for(int i=0;i<n;i++)dist[i]=Math.hypot(ufo[i][0], ufo[i][1])-ufo[i][3];
boolean[] u = new boolean[n];
int c = 0;
while(true){
double min = 1<<20;
int id = -1;
for(int i=0;i<n;i++){
if(u[i])continue;
if(dist[i]<=R){
u[i] = true;
c++;
}
else if(dist[i]<min){
min = dist[i];
id = i;
}
}
if(id==-1)break;
double[] p = {ufo[id][0], ufo[id][1]};
for(int i=0;i<n;i++){
if(u[i])continue;
dist[i]-=ufo[i][3];
double[] ci = {ufo[i][0], ufo[i][1]};
double A = dot(p, p);
double B = -2*dot(p, ci);
double C = dot(ci, ci)-ufo[i][2]*ufo[i][2];
double D = B*B-4*A*C;
if(D>=0){
double t1 = (-B-Math.sqrt(D))/(2*A);
double t2 = (-B+Math.sqrt(D))/(2*A);
if(t1>=0||t2>=0)u[i] = true;
}
}
}
System.out.println(c);
}
}
public static void main(String[] args) {
new Main().run();
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Scanner;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
4 | public class Main{
| ^~~~~~
|
s503336417 | p00204 | C++ | #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
const double EPS = 1.0e-10;
class Point
{
public:
double y, x;
Point(){
y = x = 0.0;
}
Point(double y0, double x0){
y = y0;
x = x0;
}
Point operator+(const Point& p) const{
return Point(y + p.y, x + p.x);
}
Point operator-(const Point& p) const{
return Point(y - p.y, x - p.x);
}
Point operator*(double a) const{
return Point(y * a, x * a);
}
Point operator/(double a) const{
return Point(y / a, x / a);
}
double length() const{
return sqrt(y * y + x * x);
}
double dist(const Point& p) const{
return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
}
double dot(const Point& p) const{
return y * p.y + x * p.x; // |a|*|b|*cosÆ
}
double cross(const Point& p) const{
return x * p.y - y * p.x; // |a|*|b|*sinÆ
}
};
class Line
{
public:
double a, b, c; // a*x + b*y + c = 0
Line(){
a = c = 0.0;
b = 1.0;
}
Line(double a0, double b0, double c0){
a = a0;
b = b0;
c = c0;
}
Line(const Point& p1, const Point& p2){ // 2_ðÔ¼ü
double dy = p2.y - p1.y;
double dx = p2.x - p1.x;
if(abs(dy / dx) < EPS){
a = 0.0;
b = 1.0;
c = -p1.y;
}else if(abs(dx / dy) < EPS){
a = 1.0;
b = 0.0;
c = -p1.x;
}else{
a = - dy / dx;
b = 1.0;
c = dy / dx * p1.x - p1.y;
}
}
};
int circleLineIntersection(const Point& p, double r, const Line& l, vector<Point>& intersection)
{
double s = l.a * p.x + l.b * p.y + l.c;
double t = (l.a*l.a + l.b*l.b) * r*r - s*s;
if(t < -EPS){
intersection.resize(0);
return 0;
}
if(t < EPS){
intersection.assign(1, Point(l.b, l.a) * (-s / (l.a*l.a + l.b*l.b)) + p);
return 1;
}
intersection.assign(2, Point(l.a, -l.b) * sqrt(t));
intersection[1] = intersection[1] * -1;
for(int i=0; i<2; ++i)
intersection[i] = (intersection[i] - Point(l.b, l.a) * s) / (l.a*l.a + l.b*l.b) + p;
return 2;
}
int main()
{
for(;;){
int d, n;
cin >> d >> n;
if(d == 0)
return 0;
vector<Point> p(n);
vector<int> r(n), v(n);
for(int i=0; i<n; ++i)
cin >> p[i].x >> p[i].y >> r[i] >> v[i];
vector<bool> check(n, false);
int ret = 0;
for(;;){
for(int i=0; i<n; ++i){
if(!check[i]){
if(p[i].length() - v[i] < d + EPS){
check[i] = true;
++ ret;
}else{
p[i] = p[i] - p[i] / p[i].length() * v[i];
}
}
}
int j = -1;
double minDist = DBL_MAX;
for(int i=0; i<n; ++i){
if(!check[i] && p[i].length() < minDist){
minDist = p[i].length();
j = i;
}
}
if(j == -1)
break;
Line line(Point(0,0), p[j]);
for(int i=0; i<n; ++i){
if(!check[i] && p[i].dot(p[j]) > 0 && circleLineIntersection(p[i], r[i], line, vector<Point>()) > 0)
check[i] = true;
}
}
cout << ret << endl;
}
} | a.cc: In function 'int main()':
a.cc:151:96: error: cannot bind non-const lvalue reference of type 'std::vector<Point>&' to an rvalue of type 'std::vector<Point>'
151 | if(!check[i] && p[i].dot(p[j]) > 0 && circleLineIntersection(p[i], r[i], line, vector<Point>()) > 0)
| ^~~~~~~~~~~~~~~
a.cc:90:84: note: initializing argument 4 of 'int circleLineIntersection(const Point&, double, const Line&, std::vector<Point>&)'
90 | int circleLineIntersection(const Point& p, double r, const Line& l, vector<Point>& intersection)
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~
|
s443102418 | p00204 | C++ | #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
using namespace std;
const double EPS = 1e-9;
const double M_PI = 3.1415926535897932384626433832795;
class UFO{
public:
double x;
double y;
int r;
double vx;
double vy;
bool dead;
bool invalid;
};
double dist_sq(UFO u){
return (u.x*u.x+u.y*u.y);
}
double Cross(UFO a, UFO b){
return a.x*b.y-b.x*a.y;
}
int main(){
int R, N;
while(cin >> R >> N, N){
vector<UFO> ufo(N);
for(int i = 0; i < N; i++){
int v;
cin >> ufo[i].x >> ufo[i].y >> ufo[i].r >> v;
double theta = atan2(ufo[i].y, ufo[i].x)-M_PI;
ufo[i].vx = v*cos(theta);
ufo[i].vy = v*sin(theta);
}
while(true){
double min = R*R;
int target = -1;
for(int i = 0; i < N; i++){
if(!ufo[i].dead && !ufo[i].invalid){
// 位置更新
double p = ufo[i].x;
ufo[i].x += ufo[i].vx;
ufo[i].y += ufo[i].vy;
if(p*ufo[i].x < 0 || min >= dist_sq(ufo[i])){
ufo[i].invalid = true;
}else{
// ターゲット選定
if(target == -1){
target = i;
}
else if(dist_sq(ufo[i]) < dist_sq(ufo[target])){
target = i;
}
}
}
}
// 続行判定
if(target == -1){
break;
}
// レーザー判定
ufo[target].dead = true;
for(int i = 0; i < N; i++){
if(!ufo[i].dead && !ufo[i].invalid){
double cr = Cross(ufo[target], ufo[i]);
if(cr*cr/dist_sq(ufo[target]) <= ufo[i].r*ufo[i].r){
ufo[i].dead = true;
}
}
}
}
int count = 0;
for(int i = 0; i < N; i++){
if(ufo[i].invalid){
count++;
}
}
cout << count << endl;
}
return 0;
} | In file included from /usr/include/c++/14/cmath:47,
from a.cc:8:
a.cc:16:14: error: expected unqualified-id before numeric constant
16 | const double M_PI = 3.1415926535897932384626433832795;
| ^~~~
|
s161405004 | p00204 | C++ | #include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define EPSILON 1e-9
#define ALL(x) (x).begin(), (x).end()
class point_t;
class vector_t {
public:
double x;
double y;
double z;
public:
vector_t(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {};
vector_t(const point_t& p);
public:
vector_t operator-() const {
return vector_t(-x, -y, -z);
};
double operator*(const vector_t& v) const {
return x * v.x + y * v.y + z * v.z;
};
vector_t operator*(double a) const {
return vector_t(x * a, y * a, z * a);
};
vector_t operator/(double a) const {
return vector_t(x / a, y / a, z / a);
};
vector_t operator^(const vector_t& v) const {
return vector_t(y * v.z - z * v.y,
z * v.x - x * v.z,
x * v.y - y * v.x);
};
public:
double length() const {
return sqrt(*this * *this);
};
vector_t normal() const {
return *this / length();
};
};
class point_t {
public:
double x;
double y;
double z;
double w;
public:
point_t(double x = 0, double y = 0, double z = 0, double w = 1) : x(x), y(y), z(z), w(w) {};
public:
point_t operator+(const vector_t& v) const {
return point_t(x + v.x, y + v.y, z + v.z);
};
vector_t operator-(const point_t& p) const {
return vector_t(x - p.x, y - p.y, z - p.z);
};
};
vector_t::vector_t(const point_t& p) : x(p.x / p.w), y(p.y / p.w), z(p.z / p.w)
{
}
class point_circle_intersect : public std::unary_function<point_t, bool>
{
public:
point_circle_intersect(const point_t& o, double r) : o_(o), rr_(r * r + EPSILON) {};
public:
bool operator()(const point_t& p) const {
vector_t v(p - o_);
return v * v < rr_;
};
private:
point_t o_;
double rr_;
};
class ray_circle_intersect : public std::binary_function<point_t, vector_t, bool>
{
public:
ray_circle_intersect(const point_t& o, double r) : o_(o), rr_(r * r)
{
};
public:
bool operator()(const point_t& o, const vector_t& d) {
vector_t p(o - o_);
double A = d * d;
double B = d * p;
double C = p * p - rr_;
double D = B * B - A * C;
if (D < 0)
return false;
D = sqrt(D);
double t1 = (- B + D) / A;
double t2 = (- B - D) / A;
return ! (std::max(t1, t2) < -EPSILON);
};
private:
point_t o_;
double rr_;
};
class point_point_squared_distance : public std::unary_function<point_t, double>
{
public:
point_point_squared_distance(const point_t& p) : p_(p)
{
};
public:
double operator()(const point_t& p) const {
vector_t v(p - p_);
return v * v;
};
private:
point_t p_;
};
template <class Operator>
class binary_coupler : public std::binary_function<int, int, bool>
{
public:
binary_coupler(Operator op, const std::vector<point_t>& points) :
op_(op), points_(points)
{
};
public:
bool operator()(int a, int b) const {
return op_(points_[a]) < op_(points_[b]);
};
private:
Operator op_;
const std::vector<point_t>& points_;
};
template <class Operator>
binary_coupler<Operator> make_binary_coupler(Operator op, const std::vector<point_t>& points_)
{
return binary_coupler<Operator>(op, points_);
}
int main(int argc, char** argv)
{
while (1) {
int r, n;
std::cin >> r >> n;
if (r == 0 && n == 0)
break;
std::vector<point_t> points(n);
std::vector<double> rs (n);
std::vector<vector_t> vs (n);
std::vector<int> valid (n, true);
for (int i = 0; i < n; i ++) {
double v;
std::cin >> points[i].x >> points[i].y >> rs[i] >> v;
vs[i] = - vector_t(points[i]).normal() * v;
}
std::vector<int> index(n);
for (int i = 0; i < n; i ++)
index[i] = i;
int c = 0;
for (int t = 1; ; t ++) {
std::vector<point_t> pts(n);
std::vector<int> index;
for (int i = 0; i < n; i ++)
if (valid[i]) {
point_t p(points[i] + vs[i] * t);
if (point_circle_intersect(point_t(), r)(p)) {
c ++;
valid[i] = false;
}
else {
pts[i] = p;
index.push_back(i);
}
}
if (index.empty())
break;
int im = std::min_element(ALL(index),
make_binary_coupler(point_point_squared_distance(point_t()),
pts)
) - index.begin();
for (int i = 0; i < n; i ++)
if (valid[i])
if (ray_circle_intersect(pts[i].x, pts[i].y)(point_t(), vector_t(pts[im])))
valid[i] = false;
}
std::cout << c << std::endl;
}
return 0;
} | a.cc:87:44: warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations]
87 | class point_circle_intersect : public std::unary_function<point_t, bool>
| ^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:49,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/iomanip:42,
from a.cc:2:
/usr/include/c++/14/bits/stl_function.h:117:12: note: declared here
117 | struct unary_function
| ^~~~~~~~~~~~~~
a.cc:106:42: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
106 | class ray_circle_intersect : public std::binary_function<point_t, vector_t, bool>
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:131:12: note: declared here
131 | struct binary_function
| ^~~~~~~~~~~~~~~
a.cc:141:50: warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations]
141 | class point_point_squared_distance : public std::unary_function<point_t, double>
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:117:12: note: declared here
117 | struct unary_function
| ^~~~~~~~~~~~~~
a.cc:161:36: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
161 | class binary_coupler : public std::binary_function<int, int, bool>
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:131:12: note: declared here
131 | struct binary_function
| ^~~~~~~~~~~~~~~
a.cc: In function 'int main(int, char**)':
a.cc:241:21: error: 'min_element' is not a member of 'std'; did you mean 'tuple_element'?
241 | int im = std::min_element(ALL(index),
| ^~~~~~~~~~~
| tuple_element
|
s173967389 | p00204 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
vector<string> res;
for(int i=0,s=0;i<SIZE(str);i++){
if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
}
return res;
}
int R,N;
int xs[101];
int ys[101];
int rs[101];
int vs[101];
double times[101];
double dists[101];
bool used[101];
typedef complex<double> P;
// 内積
double dot(const P &a, const P &b) {
return (a.real() * b.real() + a.imag() * b.imag());
}
// 外積
double cross(const P &a, const P &b) {
return (a.real() * b.imag() - a.imag() * b.real());}
// 点a,bを端点とする線分と点cとの距離
double distance_ls_p(const P &a, const P &b, const P &c) {
if ( dot(b-a, c-a) < EPS ) return abs(c-a);
if ( dot(a-b, c-b) < EPS ) return abs(c-b);
return abs(cross(b-a, c-a)) / abs(b-a);
}
int main(){
while(cin>>R>>N&&(R|N)){
for(int i=0;i<N;i++)cin>>xs[i]>>ys[i]>>rs[i]>>vs[i];
// 各UFOがO(0,0)に到達する時間(m)
for(int i=0;i<N;i++)times[i]=sqrt(xs[i]*xs[i]+ys[i]*ys[i])/vs[i];
for(int i=0;i<N;i++)dists[i]=sqrt(xs[i]*xs[i]+ys[i]*ys[i]);
memset(used,0,sizeof(used));
int res=0;
// 1分ごとにレーザを発射し続ける
// すべてのUFOが撃墜されるか原点よりR以内の場所へ到達した時に終了
for(int t=1;;t++){
int idx=-1;
// 生きてるUFOのうち、一番中心間距離が近いものを見つける
for(int i=0;i<N;i++){
if(used[i])continue;
if(EQ(dists[i]-vs[i]*t,R)||dists[i]-vs[i]*t<R)continue;
else if(idx==-1||dists[i]-vs[i]*t<dists[idx]-vs[idx]*t)idx=i;
}
if(idx==-1)break;
// idxのUFOに対してレーザを発射
// そのレーザで他に撃墜できるUFOを探索
used[idx]=true;
double ex=xs[idx]/dists[idx];
double ey=ys[idx]/dists[idx];
double vx=ex*2000;
double vy=ey*2000;
for(int i=0;i<N;i++){
if(used[i])continue;
double eex=-xs[i]/times[i];
double eey=-ys[i]/times[i];
P plc=P(xs[i]+t*eex,ys[i]+t*eey);
if(dists[i]-vs[i]*t<0)
plc=P(0,0);
// レーザの線分と、中心の距離を比較
double dist=distance_ls_p(P(ex*(R),ey*(R))
,P(vx,vy),plc);
// 中心との距離が円の半径以下なら破壊する
if(EQ(dist,rs[i])||dist<rs[i])used[i]=true;
}
}
for(int i=0;i<N;i++)
if(!used[i])res++;
cout<<res<<endl;
}
return 0;
}
< | a.cc:127:1: error: expected unqualified-id before '<' token
127 | <
| ^
|
s007145281 | p00204 | C++ | from sys import stdin
from math import sqrt,fabs
class Game:
class Ufo:
def __init__(self,x,y,r,v):
self.x = x*1.0
self.y = y*1.0
self.r = r*1.0
self.v = v*1.0
self.d = sqrt(x**2+y**2)
self.cs = self.x / self.d
self.si = self.y / self.d
self.vx = -self.v*self.cs
self.vy = -self.v*self.si
def __str__(self):
return "ufo x = " + str(self.x) + ", y = " + str(self.y) + ", r = " + str(self.r) + ", v = " + str(self.v)
def oneMinMove(self):
self.x += self.vx
self.y += self.vy
self.d -= self.v
class Laser:
def __init__(self,cs,si):
self.cs = cs
self.si = si
ufos = []
laser = Laser(0,0)
gameend = False
inrl = 0
def __init__(self,R):
self.R = R
def hit(self,laser,ufo):
temp1 = ufo.r**2 - (laser.si*ufo.x - laser.cs*ufo.y)**2
if temp1 >= 0:
temp2 = laser.cs*ufo.x + laser.si*ufo.y
d1 = temp2 + sqrt(temp1)
d2 = temp2 - sqrt(temp1)
if d1>=0 or d2>=0: return True
else: return False
else: return False
def isInvaded(self,ufo):
return (ufo.d<= self.R)
def gameOneMinMove(self):
curInrs = []
for ufo in self.ufos:
ufo.oneMinMove()
if self.isInvaded(ufo): curInrs.append(ufo)
self.inrl += len(curInrs)
#print str(len(curInrs)) + " ufos invaded!"
for ufo in curInrs:
self.ufos.remove(ufo)
#print ufo
del curInrs
if self.ufos == []:
self.gameend = True
def setLaser(self):
nearestUfo = self.ufos[0]
for ufo in self.ufos:
if nearestUfo.d > ufo.d :
nearestUfo = ufo
self.laser = self.Laser(nearestUfo.cs,nearestUfo.si)
def fireLaser(self):
curDeads = []
for ufo in self.ufos:
if self.hit(self.laser,ufo):
curDeads.append(ufo)
#print str(len(curDeads)) +" ufos burned!"
for ufo in curDeads:
self.ufos.remove(ufo)
#print ufo
del curDeads
def oneLogic(self):
self.gameOneMinMove()
if self.gameend:
pass
else:
self.setLaser()
self.fireLaser()
def allLogic(self):
while not self.gameend:
self.oneLogic()
for inp in stdin:
#for inp in open("input.txt"):
inp = map(int,inp.split())
if len(inp) == 2:
if inp == (0,0): break
game = Game(inp[0])
N = inp[1]
else:
game.ufos.append(game.Ufo(inp[0],inp[1],inp[2],inp[3]))
if len(game.ufos) == N:
game.allLogic()
print game.inrl | a.cc:56:18: error: invalid preprocessing directive #print
56 | #print str(len(curInrs)) + " ufos invaded!"
| ^~~~~
a.cc:59:26: error: invalid preprocessing directive #print
59 | #print ufo
| ^~~~~
a.cc:76:18: error: invalid preprocessing directive #print
76 | #print str(len(curDeads)) +" ufos burned!"
| ^~~~~
a.cc:79:26: error: invalid preprocessing directive #print
79 | #print ufo
| ^~~~~
a.cc:96:2: error: invalid preprocessing directive #for
96 | #for inp in open("input.txt"):
| ^~~
a.cc:1:1: error: 'from' does not name a type
1 | from sys import stdin
| ^~~~
|
s577867713 | p00204 | C++ | from math import sqrt,fabs
class Ufo:
def __init__(self,x,y,r,v):
self.x = x*1.0
self.y = y*1.0
self.r = r*1.0
self.v = v*1.0
self.d = sqrt(x**2+y**2)
self.cs = self.x / self.d
self.si = self.y / self.d
self.vx = -self.v*self.cs
self.vy = -self.v*self.si
def __str__(self):
return "ufo x = " + str(self.x) + ", y = " + str(self.y) + ", r = " + str(self.r) + ", v = " + str(self.v)
def oneMinMove(self):
self.x += self.vx
self.y += self.vy
self.d -= self.v
def isInvaded(self):
return (self.d<= game.R)
class Laser:
def __init__(self,cs,si):
self.cs = cs
self.si = si
def hit(self,ufo):
temp1 = ufo.r**2 - (self.si*ufo.x - self.cs*ufo.y)**2
if temp1 >= 0:
temp2 = self.cs*ufo.x + self.si*ufo.y
d1 = temp2 + sqrt(temp1)
d2 = temp2 - sqrt(temp1)
if d1>=0 or d2>=0: return True
else: return False
else: return False
class Game:
ufos = []
laser = Laser(0,0)
gameend = False
inrl = 0
def __init__(self,R):
self.R = R
def gameOneMinMove(self):
curInrs = []
for ufo in self.ufos:
ufo.oneMinMove()
if ufo.isInvaded(): curInrs.append(ufo)
self.inrl += len(curInrs)
#print str(len(curInrs)) + " ufos invaded!"
for ufo in curInrs:
self.ufos.remove(ufo)
#print ufo
del curInrs
if self.ufos == []:
self.gameend = True
def setLaser(self):
nearestUfo = self.ufos[0]
for ufo in self.ufos:
if nearestUfo.d > ufo.d :
nearestUfo = ufo
self.laser = Laser(nearestUfo.cs,nearestUfo.si)
def fireLaser(self):
curDeads = []
for ufo in self.ufos:
if self.laser.hit(ufo):
curDeads.append(ufo)
#print str(len(curDeads)) +" ufos burned!"
for ufo in curDeads:
self.ufos.remove(ufo)
#print ufo
del curDeads
def oneLogic(self):
self.gameOneMinMove()
if self.gameend:
pass
else:
self.setLaser()
self.fireLaser()
def allLogic(self):
while not self.gameend:
self.oneLogic()
while True:
inp = map(int,raw_input().split())
if len(inp) == 2:
if inp == (0,0): break
game = Game(inp[0])
N = inp[1]
else:
game.ufos.append(Ufo(inp[0],inp[1],inp[2],inp[3]))
if len(game.ufos) == N:
game.allLogic()
print game.inrl | a.cc:57:10: error: invalid preprocessing directive #print
57 | #print str(len(curInrs)) + " ufos invaded!"
| ^~~~~
a.cc:60:14: error: invalid preprocessing directive #print
60 | #print ufo
| ^~~~~
a.cc:77:10: error: invalid preprocessing directive #print
77 | #print str(len(curDeads)) +" ufos burned!"
| ^~~~~
a.cc:80:14: error: invalid preprocessing directive #print
80 | #print ufo
| ^~~~~
a.cc:1:1: error: 'from' does not name a type
1 | from math import sqrt,fabs
| ^~~~
|
s101275372 | p00204 | C++ |
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
template<class T> T sqr(T x){
return x*x;
}
const double eps=1e-9;
int main(){
for(int R,N;cin>>R>>N,R;){
int x0[100],y0[100],r[100],v[100];
vector<int> rem(N);
for(int i=0;i<N;i++){
cin>>x0[i]>>y0[i]>>r[i]>>v[i];
rem[i]=i;
}
int ans=0;
for(int i=1;;i++){
auto d=[&](int x){
return sqrt(sqr(x0[x])+sqr(y0[x]))-i*v[x];
};
auto it=remove_if(begin(rem),end(rem),[&](int x){
return d(x)<=R+eps;
});
ans+=end(rem)-it;
rem.erase(it,end(rem));
if(rem.empty())break;
auto cl=min_element(begin(rem),end(rem),[&](int a,int b){
return d(a)<d(b);
});
rem.erase(remove_if(begin(rem),end(rem),[&](int x){
complex<double> rp=polar(d(x),atan2(y0[x],x0[x])-atan2(y0[*cl],x0[*cl]));
return rp.real()+r[x]>=eps&&(rp.imag()+r[x])*(rp.imag()-r[x])<=eps;
}),end(rem));
}
cout<<ans<<endl;
}
} | a.cc: In function 'int main()':
a.cc:16:15: error: 'cin' was not declared in this scope
16 | for(int R,N;cin>>R>>N,R;){
| ^~~
a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
5 | #include<cmath>
+++ |+#include <iostream>
6 |
a.cc:42:5: error: 'cout' was not declared in this scope
42 | cout<<ans<<endl;
| ^~~~
a.cc:42:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s028765229 | p00205 | Java | import java.util.*;
public class Main1 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
out: while (true) {
int[] x;
x = new int[5];
for (int i = 0; i < 5; i++) {
x[i] = s.nextInt();
if (x[0] == 0)
break out;
}
boolean[] j = { false, false, false };
for (int i = 0; i < 5; i++) {
j[x[i] - 1] = true;
}
if (j[0] && j[1] && j[2])
for (int i = 0; i < 5; i++) {
System.out.println("3");
}
if (j[0] && !j[1] && !j[2])
for (int i = 0; i < 5; i++) {
System.out.println("3");
}
if (!j[0] && !j[1] && j[2])
for (int i = 0; i < 5; i++) {
System.out.println("3");
}
if (!j[0] && j[1] && !j[2])
for (int i = 0; i < 5; i++) {
System.out.println("3");
}
if (!j[0] && j[1] && j[2])
for (int i = 0; i < 5; i++) {
if (x[i] == 2)
System.out.println("1");
else
System.out.println("2");
}
if (j[0] && !j[1] && j[2])
for (int i = 0; i < 5; i++) {
if (x[i] == 3)
System.out.println("1");
else
System.out.println("2");
}
if (j[0] && j[1] && !j[2])
for (int i = 0; i < 5; i++) {
if (x[i] == 1)
System.out.println("1");
else
System.out.println("2");
}
}
}
} | Main.java:3: error: class Main1 is public, should be declared in a file named Main1.java
public class Main1 {
^
1 error
|
s729214150 | p00205 | C | #include<stdio.h>
int main(void)
{
int g = 0, c = 0, p = 0, n, i, a[5];
while (scanf_s("%d", &n))
{
if (n == 0)
{
break;
}
a[0] = n;
if (n == 1)
{
g++;
}
if (n == 2)
{
c++;
}
if (n == 3)
{
p++;
}
for (i = 1;i < 5;i++)
{
scanf_s("%d", &n);
a[i] = n;
if (n == 1)
{
g++;
}
if (n == 2)
{
c++;
}
if (n == 3)
{
p++;
}
}
if (g == 5 || c == 5 || p == 5)
{
for (i = 0;i < 5;i++)
{
a[i] = 3;
printf("%d\n",a[i]);
}
}
else if(g == 0 || c == 0 || p == 0)
{
if (g > 0 && c > 0)
{
for (i = 0;i < 5;i++)
{
printf("%d\n", a[i]);
}
}
else if (c > 0 && p > 0)
{
for (i = 0;i < 5;i++)
{
if (a[i] == 2)
{
printf("1\n");
}
else
{
printf("2\n");
}
}
}
else if (p > 0 && g > 0)
{
for (i = 0;i < 5;i++)
{
if (a[1] == 3)
{
printf("1\n");
}
else
{
printf("2\n");
}
}
}
}
else
{
for (i = 0;i < 5;i++)
{
a[i] = 3;
printf("%d\n", a[i]);
}
}
g = 0;c = 0;p = 0;
}
} | main.c: In function 'main':
main.c:6:16: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
6 | while (scanf_s("%d", &n))
| ^~~~~~~
| scanf
|
s121896595 | p00205 | C | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;} | main.c:1:1: error: return type defaults to 'int' [-Wimplicit-int]
1 | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}
| ^~~~
main.c: In function 'main':
main.c:1:15: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}
main.c:1:15: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}
| ^~~~~
main.c:1:15: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:1:34: error: 'p' undeclared (first use in this function)
1 | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}
| ^
main.c:1:34: note: each undeclared identifier is reported only once for each function it appears in
main.c:1:58: error: 'i' undeclared (first use in this function)
1 | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}
| ^
main.c:1:70: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
1 | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}
| ^~~~
main.c:1:70: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:1:75: error: 'w' undeclared (first use in this function)
1 | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}
| ^
main.c:1:77: error: 'l' undeclared (first use in this function)
1 | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}
| ^
main.c:1:102: error: 'j' undeclared (first use in this function)
1 | main(){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}
| ^
|
s131718280 | p00205 | C | #include<stdio.h>
int main(){
int a[5],g,c,p,i;
while(scanf("%d",&a[0]),a[0]){
g=0;
c=0;
p=0;
if(a[0]==1)
g++;
else if(a[0]==2)
c++;
else if(a[0]==3)
p++;
for(i=1;i<5;i++){
scanf("%d",&a[i]);
if(a[i]==1)
g++;
else if(a[i]==2)
c++;
else if(a[i]==3)
p++;
}
if(g>0&&c>0&&p>0)
for(i=0;i<5;i++)
printf("3\n");
else if(g==5||c==5||p==5)
for(i=0;i<5;i++)
printf("3\n");
else if(g>0&&c>0)
for(i=0;i<5;i++){
if(a[i]==1)
printf("1\n");
else printf("2\n");
}
else if(g>0&&p>0)
for(i=0;i<5;i++){
if(a[i]==1)
printf("2\n");
else printf("1\n");
}
else for(i=0;i<5;i++){
if(a[i]==2)
printf("1\n");
else printf("2\n");
}
} | main.c: In function 'main':
main.c:46:17: error: expected declaration or statement at end of input
46 | }
| ^
|
s917400360 | p00205 | C | #include<stdio.h>
int main(){
int a[500]={0},i,kaisuu,k;
int flg1,flg2,flg3,l;
int j,cnt=0;
cnt=0;
a[500]={0};
kaisuu=0;
for(i=1;i<500;i++){
scanf("%d",&a[i]);
if(a[i]==0)break;
cnt++;
}
kaisuu=cnt/5;
for(i=0;i<kaisuu;i++){
for(l=i*5+1;l<i*5+6;l++){
if(a[l]==1)flg1=1;
if(a[l]==2)flg2=1;
if(a[l]==3)flg3=1;
}
if(flg1==1&&flg2==1&&flg3==1){
for(j=1;j<6;j++){
printf("3\n");
}
goto end;
}
if(flg1==1&&flg2==1){
for(j=1;j<6;j++){
if(a[i*5+j]==1)printf("1\n");
else if(a[i*5+j]==2)printf("2\n");
//printf("gu-");
}
goto end;
}
if(flg2==1&&flg3==1){
for(j=1;j<6;j++){
if(a[i*5+j]==2)printf("1\n");
else if(a[i*5+j]==3)printf("2\n");
//printf("pa-");
}
goto end;
}
if(flg1==1&&flg3==1){
for(j=1;j<6;j++){
if(a[i*5+j]==1)printf("2\n");
else if(a[i*5+j]==3)printf("1\n");
//printf("a-");
}
goto end;
}
end:
flg1=0;
flg2=0;
flg3=0;
}
//printf("kaisuu = %d",kaisuu);
return 0;
} | main.c: In function 'main':
main.c:7:16: error: expected expression before '{' token
7 | a[500]={0};
| ^
|
s998124704 | p00205 | C | #include<stdio.h>
int main(){
int a[500]={0},i,kaisuu,k;
int flg1,flg2,flg3,l;
int j,cnt=0;
cnt=0;
a[500]={0};
kaisuu=0;
for(i=1;i<500;i++){
scanf("%d",&a[i]);
if(a[i]==0)break;
cnt++;
}
kaisuu=cnt/5;
for(i=0;i<kaisuu;i++){
for(l=i*5+1;l<i*5+6;l++){
if(a[l]==1)flg1=1;
if(a[l]==2)flg2=1;
if(a[l]==3)flg3=1;
}
if(flg1==1&&flg2==1&&flg3==1){
for(j=1;j<6;j++){
printf("3\n");
}
goto end;
}
if(flg1==1&&flg2==1){
for(j=1;j<6;j++){
if(a[i*5+j]==1)printf("1\n");
else if(a[i*5+j]==2)printf("2\n");
//printf("gu-");
}
goto end;
}
if(flg2==1&&flg3==1){
for(j=1;j<6;j++){
if(a[i*5+j]==2)printf("1\n");
else if(a[i*5+j]==3)printf("2\n");
//printf("pa-");
}
goto end;
}
if(flg1==1&&flg3==1){
for(j=1;j<6;j++){
if(a[i*5+j]==1)printf("2\n");
else if(a[i*5+j]==3)printf("1\n");
//printf("a-");
}
goto end;
}
end:
flg1=0;
flg2=0;
flg3=0;
}
//printf("kaisuu = %d",kaisuu);
return 0;
} | main.c: In function 'main':
main.c:7:16: error: expected expression before '{' token
7 | a[500]={0};
| ^
|
s668314341 | p00205 | C | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}} | main.c:1:1: error: return type defaults to 'int' [-Wimplicit-int]
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^~~~
main.c: In function 'main':
main.c:1:16: error: 'd' undeclared (first use in this function)
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^
main.c:1:16: note: each undeclared identifier is reported only once for each function it appears in
main.c:1:21: error: 's' undeclared (first use in this function)
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^
main.c:1:25: error: 'i' undeclared (first use in this function)
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^
main.c:1:43: error: 'h' undeclared (first use in this function)
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^
main.c:1:45: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
main.c:1:45: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^~~~~
main.c:1:45: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:1:66: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^~~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
+++ |+#include <stdlib.h>
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
main.c:1:66: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^~~~
main.c:1:66: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:1:105: error: 'k' undeclared (first use in this function)
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^
main.c:1:112: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
1 | main(){for(;;){d[5],s=0,i=0;for(;i<5;i++){h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}
| ^~~~~~
main.c:1:112: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:1:112: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:1:112: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s269798010 | p00205 | C | #include<stdio.h>
int main(){
while(1){
int i,a,b,c,d,e,A,B,C,D,E,x[5]={},X,Y,Z,p;
scanf("%d",&a);
if(a==0){
break;
}
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
scanf("%d",&e);
x[0]=a;
x[1]=b;
x[2]=c;
x[3]=d;
x[4]=e;
X=a;
for(i=0;i<5;i++){
if(X!=x[i]){
if(Y!=x[i]&&Y==0){
Y=x[i];
}
else if(Y!=x[i]){
Z=x[i];
p=1;
}
}
}
if(p==1){
A=3;
B=3;
C=3;
D=3;
E=3;
}
else {
if(a<b && b!=3){
A=1;
B=2;
if(a==c)
C=1;
else
C=2;
if(a==d)
D=1;
else
D=2;
if(a==e)
E=1;
else
E=2;
}
else if(a<b){
B=1;
A=2;
if(a==c)
C=2;
else
C=1;
if(a==d)
D=2;
else
D=1;
if(a==e)
E=2;
else
E=1;
}
}
printf("%d\n%d\n%d\n%d\n%d\n",A,B,C,D,E);
return 0;
} | main.c: In function 'main':
main.c:73:1: error: expected declaration or statement at end of input
73 | }
| ^
|
s786663788 | p00205 | C++ | #include<iostream>
int main(){
int a[5];
bool r,s,p;
bool as,bs,cs,ds;
while(1){
for(int i=0;i<5;i++){
std::cin>>a[i];
if(a[i]==1)
r=true;
else if(a[i]==2)
s=true;
else
p=true;
}
if(r==true && s==true && p==true)ds==true;
if(r==true && s==true){
as==true;
bs==false;
}
if(r==true && p==true){
cs==true;
as==false;
}
if(p==true && s==true){
bs==true;
cs==false;
}
for(int i=0;i<5;i++){
if(ds==true)
std::cout<<3<<std::endl;
if(as==true || bs==true || cs==true)
std::cout<<1<<std::endl;
if(as==false || bs==false || cs==false)
std::cout<<2<<std::endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:38:2: error: expected '}' at end of input
38 | }
| ^
a.cc:2:11: note: to match this '{'
2 | int main(){
| ^
|
s795914151 | p00205 | C++ | #include<iostream>
using namespace std;
int main(){
int X[5];
while(1){
int con1=0,con2=0,con3=0;
cin >> X[0];
if(X[0] == 0) break;
for(int i=1;i<5;i++){
cin >> X[i];
}
for(int i=0;i<5;i++){
if(X[i] == 1) con1++;
if(X[i] == 2) con2++;
if(X[i] == 3) con3++;
}
if(((con1 != 0)&&(con2 != 0)&&(con3 != 0))||((con1 == 0)&&(con2 == 0))||((con2 == 0)&&(con3 == 0))||((con1 == 0)&&(con3 == 0))||){
for(int i=0; i<5; i++){
cout << "3" << "\n";
}
}else if(con1 == 0){
for(int i=0; i<5; i++){
if(X[i] == 2) {
cout << "1";
}else{
cout << "2";
}
cout << endl;
}
}else if(con2 == 0){
for(int i=0; i<5; i++){
if(X[i] == 3) {
cout << "1";
}else{
cout << "2";
}
cout << endl;
}
}else if(con3 == 0){
for(int i=0; i<5; i++){
if(X[i] == 1) {
cout << "1";
}else{
cout << "2";
}
cout << endl;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:23:137: error: expected primary-expression before ')' token
23 | if(((con1 != 0)&&(con2 != 0)&&(con3 != 0))||((con1 == 0)&&(con2 == 0))||((con2 == 0)&&(con3 == 0))||((con1 == 0)&&(con3 == 0))||){
| ^
|
s584234118 | p00205 | C++ | #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;
int main(){
int c[5];
while(cin >> c[0], c[0]){
range(i,1,5)
cin >> c[i];
bool rock, paper, scissors;
rock = paper = scissors = false;
rep(i,5){
if(c[i] == 1){
rock = true;
}else if(c[i] == 2){
scissors = true;
}else{
paper = true;
}
}
int r, p ,s;
if(rock && paper && scissors){
r = p = s = 3;
}else if(rock && paper && !scissors){
p = 1;
r = 2;
}else if(rock && scissors && !paper){
r = 1;
s = 2;
}else if(paper && scissors && !rock){
s = 1;
p = 2;
}else if(rock){
r = 3;
}else if(paper){
p 3;
}else if(scissors){
s = 3;
}
rep(i,5){
if(c[i] == 1)
cout << r << endl;
else if(c[i] == 2)
cout << s << endl;
else if(c[i] == 3)
cout << p << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:47:14: error: expected ';' before numeric constant
47 | p 3;
| ^ ~
| ;
|
s759615439 | p00205 | C++ | type hand = Rock | Paper | Scissors
type result = Win | Lose | Draw
module HandSet = Set.Make (
struct
type t = hand
let compare (a : hand) b = compare a b
end)
let hand_of_int = function
| 1 -> Some Rock
| 2 -> Some Scissors
| 3 -> Some Paper
| _ -> None
let int_of_result = function
| Win -> 1
| Lose -> 2
| Draw -> 3
exception BreakLoop
let read_hands () =
try
let hands = Array.init
5
(fun _ -> match read_int () |> hand_of_int with
| None -> raise BreakLoop
| Some hand -> hand) in
Some (Array.to_list hands)
with BreakLoop -> None
let match_ hands =
let set = HandSet.of_list hands in
if HandSet.cardinal set <> 2 then Array.make 5 Draw |> Array.to_list
else
let defeats a b =
match a, b with
| Rock, Paper -> false
| Rock, Scissors -> true
| Paper, Rock -> true
| Paper, Scissors -> false
| Scissors, Rock -> false
| Scissors, Paper -> true
| _ -> invalid_arg "defeats" in
List.map
(fun hand ->
let match_ = HandSet.remove hand set |> HandSet.choose in
if defeats hand match_ then Win else Lose)
hands
let rec solve () =
match read_hands () with
| None -> ()
| Some hands ->
let results = match_ hands in
List.iter
(fun result ->
int_of_result result |> print_int;
print_newline ())
results;
solve ()
let () = solve () | a.cc:1:1: error: 'type' does not name a type; did you mean 'typeof'?
1 | type hand = Rock | Paper | Scissors
| ^~~~
| typeof
a.cc:61:25: error: expected constructor, destructor, or type conversion before ')' token
61 | print_newline ())
| ^
a.cc:65:1: error: expected constructor, destructor, or type conversion before 'let'
65 | let () = solve ()
| ^~~
|
s299819145 | p00205 | C++ | 3
3
3 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 3
| ^
|
s008426482 | p00205 | C++ | #include<iostream>
using namespace std;
int main(){
int h[5];
int f[4];
while(1){
for(int i=0;i<4;i++) f[i]=0;
for(int i=0;i<5;i++){
cin>>h[i];
if(h[i]==0) break;
f[h[i]]=1;
}
if(h[0]==0) break;
int x[2], cnt=0;
for(int i=1;i<4;i++){
if(f[i]==1)
x[cnt++]=i;
//cout<<i<<" "<<f[i]<<endl;
}
//cout<<" "<<cnt<<" "<<x<<endl;
if(cnt==2){
if(x[0]==1&&x[1]==2){
for(int i=0;i<5;i++){
if(h[i]==1) cout<<1<<endl;
else cout<<2<<endl;
}
}
if(x[0]==1&&x[1]==3){
for(int i=0;i<5;i++){
if(h[i]==1) cout<<2<<endl;
else cout<<1<<endl;
}
}
if(x[0]==2&&x[1]==3){
for(int i=0;i<5;i++){
if(h[i]==2) cout<<1<<endl;
else cout<<2<<endl;
}
}
}else{
for(int i=0;i<5;i++) cout<<3<<endl;
}
}
return 0; | a.cc: In function 'int main()':
a.cc:49:12: error: expected '}' at end of input
49 | return 0;
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s088877619 | p00205 | C++ | i,f,d[5],*p;main(n){for(;i>4||scanf("%d",p=d+i)**d;i=++i%10,f*=!!i)n=((f^f/2^f/4)&1?2:!(d[i%5]*2&f))+49,i<5?f|=(*p=9<<*p-1):puts(&n);} | a.cc:1:1: error: 'i' does not name a type
1 | i,f,d[5],*p;main(n){for(;i>4||scanf("%d",p=d+i)**d;i=++i%10,f*=!!i)n=((f^f/2^f/4)&1?2:!(d[i%5]*2&f))+49,i<5?f|=(*p=9<<*p-1):puts(&n);}
| ^
a.cc:1:17: error: expected constructor, destructor, or type conversion before '(' token
1 | i,f,d[5],*p;main(n){for(;i>4||scanf("%d",p=d+i)**d;i=++i%10,f*=!!i)n=((f^f/2^f/4)&1?2:!(d[i%5]*2&f))+49,i<5?f|=(*p=9<<*p-1):puts(&n);}
| ^
|
s734715125 | p00205 | C++ | #include <iostream>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c), (c)+5
#define Contains(c, x) (find(all(c), (x)) != (c)+5)
using namespace std;
int main()
{
int a[5], b[5];
while (true) {
cin >> a[0]; if (a[0] == 0) break;
REP(i, 1, 5) cin >> a[i];
if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
rep(i, 5) b[i] = 3;
}
else if (count(all(a), a[0]) == 5) {
rep(i, 5) b[i] = 3;
}
else {
if (!Contains(a, 1))
rep(i, 5) b[i] = (a[i] == 2) ? 1 : 2;
else if (!Contains(a, 2))
rep(i, 5) b[i] = (a[i] == 3) ? 1 : 2;
else
rep(i, 5) b[i] = (a[i] == 1) ? 1 : 2;
}
rep(i, 5) cout << b[i] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:5:29: error: no matching function for call to 'find(int [5], int*, int)'
5 | #define Contains(c, x) (find(all(c), (x)) != (c)+5)
| ~~~~^~~~~~~~~~~~~
a.cc:13:13: note: in expansion of macro 'Contains'
13 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:5:29: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
5 | #define Contains(c, x) (find(all(c), (x)) != (c)+5)
| ~~~~^~~~~~~~~~~~~
a.cc:13:13: note: in expansion of macro 'Contains'
13 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
a.cc:5:29: error: no matching function for call to 'find(int [5], int*, int)'
5 | #define Contains(c, x) (find(all(c), (x)) != (c)+5)
| ~~~~^~~~~~~~~~~~~
a.cc:13:31: note: in expansion of macro 'Contains'
13 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:5:29: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
5 | #define Contains(c, x) (find(all(c), (x)) != (c)+5)
| ~~~~^~~~~~~~~~~~~
a.cc:13:31: note: in expansion of macro 'Contains'
13 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
a.cc:5:29: error: no matching function for call to 'find(int [5], int*, int)'
5 | #define Contains(c, x) (find(all(c), (x)) != (c)+5)
| ~~~~^~~~~~~~~~~~~
a.cc:13:49: note: in expansion of macro 'Contains'
13 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:5:29: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
5 | #define Contains(c, x) (find(all(c), (x)) != (c)+5)
| ~~~~^~~~~~~~~~~~~
a.cc:13:49: note: in expansion of macro 'Contains'
13 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
a.cc:16:18: error: 'count' was not declared in this scope
16 | else if (count(all(a), a[0]) == 5) {
| ^~~~~
a.cc:5:29: error: no matching function for call to 'find(int [5], int*, int)'
5 | #define Contains(c, x) (find(all(c), (x)) != (c)+5)
| ~~~~^~~~~~~~~~~~~
a.cc:20:18: note: in expansion of macro 'Contains'
20 | if (!Contains(a, 1))
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:5:29: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
5 | #define Contains(c, x) (find(all(c), (x)) != (c)+5)
| ~~~~^~~~~~~~~~~~~
a.cc:20:18: note: in expansion of macro 'Contains'
20 | if (!Contains(a, 1))
| ^~~~~~~~
a.cc:5:29: error: no matching function for call to 'find(int [5], int*, int)'
5 | #define Contains(c, x) (find(all(c), (x)) != (c)+5)
| ~~~~^~~~~~~~~~~~~
a.cc:22:23: note: in expansion of macro 'Contains'
22 | else if (!Contains(a, 2))
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:5:29: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
5 | #define Contains(c, x) (find(all(c), (x)) != (c)+5)
| ~~~~^~~~~~~~~~~~~
a.cc:22:23: note: in expansion of macro 'Contains'
22 | else if (!Contains(a, 2))
| ^~~~~~~~
|
s556779970 | p00205 | C++ | #include <iostream>
#include <vector>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()
#define Contains(c, x) (find(all(c), (x)) != (c).end())
using namespace std;
int main()
{
vector<int> a(5), b(5);
while (true) {
cin >> a[0]; if (a[0] == 0) break;
REP(i, 1, 5) cin >> a[i];
if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
rep(i, 5) b[i] = 3;
}
else if (count(all(a), a[0]) == 5) {
rep(i, 5) b[i] = 3;
}
else {
if (!Contains(a, 1))
rep(i, 5) b[i] = (a[i] == 2) ? 1 : 2;
else if (!Contains(a, 2))
rep(i, 5) b[i] = (a[i] == 3) ? 1 : 2;
else
rep(i, 5) b[i] = (a[i] == 1) ? 1 : 2;
}
rep(i, 5) cout << b[i] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:6:29: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)'
6 | #define Contains(c, x) (find(all(c), (x)) != (c).end())
| ~~~~^~~~~~~~~~~~~
a.cc:14:13: note: in expansion of macro 'Contains'
14 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:6:29: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
6 | #define Contains(c, x) (find(all(c), (x)) != (c).end())
| ~~~~^~~~~~~~~~~~~
a.cc:14:13: note: in expansion of macro 'Contains'
14 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
a.cc:6:29: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)'
6 | #define Contains(c, x) (find(all(c), (x)) != (c).end())
| ~~~~^~~~~~~~~~~~~
a.cc:14:31: note: in expansion of macro 'Contains'
14 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:6:29: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
6 | #define Contains(c, x) (find(all(c), (x)) != (c).end())
| ~~~~^~~~~~~~~~~~~
a.cc:14:31: note: in expansion of macro 'Contains'
14 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
a.cc:6:29: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)'
6 | #define Contains(c, x) (find(all(c), (x)) != (c).end())
| ~~~~^~~~~~~~~~~~~
a.cc:14:49: note: in expansion of macro 'Contains'
14 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:6:29: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
6 | #define Contains(c, x) (find(all(c), (x)) != (c).end())
| ~~~~^~~~~~~~~~~~~
a.cc:14:49: note: in expansion of macro 'Contains'
14 | if (Contains(a, 1) && Contains(a, 2) && Contains(a, 3)) {
| ^~~~~~~~
a.cc:17:18: error: 'count' was not declared in this scope
17 | else if (count(all(a), a[0]) == 5) {
| ^~~~~
a.cc:6:29: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)'
6 | #define Contains(c, x) (find(all(c), (x)) != (c).end())
| ~~~~^~~~~~~~~~~~~
a.cc:21:18: note: in expansion of macro 'Contains'
21 | if (!Contains(a, 1))
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:6:29: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
6 | #define Contains(c, x) (find(all(c), (x)) != (c).end())
| ~~~~^~~~~~~~~~~~~
a.cc:21:18: note: in expansion of macro 'Contains'
21 | if (!Contains(a, 1))
| ^~~~~~~~
a.cc:6:29: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)'
6 | #define Contains(c, x) (find(all(c), (x)) != (c).end())
| ~~~~^~~~~~~~~~~~~
a.cc:23:23: note: in expansion of macro 'Contains'
23 | else if (!Contains(a, 2))
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:6:29: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
6 | #define Contains(c, x) (find(all(c), (x)) != (c).end())
| ~~~~^~~~~~~~~~~~~
a.cc:23:23: note: in expansion of macro 'Contains'
23 | else if (!Contains(a, 2))
| ^~~~~~~~
|
s591960064 | p00205 | C++ | #include <iostream>
using namespace std;
int main(){
int human[5];
while(cin>>human[0],human[0]){
bool hand[3]={};
for(int i=1;i<5;i++){
cin>>human[i];
if(human[i]==1) hand[0]++;
else if(human[i]==2) hand[1]++;
else hand[2]++;
}
if((hand[0]==true&&hand[0]==hand[1]&&hand[0]==hand[2])||(hand[0]==false&&hand[0]==hand[1]))||(hand[0]==false&&hand[0]==hand[2]))||(hand[1]==false&&hand[1]==hand[2])) for(int i=0;i<5;i++)cout<<'3'<<endl;
else if(hand[0]==)
else if(hand[0]==true&&hand[0]==hand[1]){
for(int i=0;i<5;i++){
if(human[i]==1)cout<<'1'<<endl;
else cout<<'2'<<endl;
}
}
else if(hand[0]==true&&hand[0]==hand[2]){
for(int i=0;i<5;i++){
if(human[i]==3)cout<<'1'<<endl;
else cout<<'2'<<endl;
}
}
else if(hand[1]==true&&hand[1]==hand[2]){
for(int i=0;i<5;i++){
if(human[i]==2)cout<<'1'<<endl;
else cout<<'2'<<endl;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:47: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
10 | if(human[i]==1) hand[0]++;
| ~~~~~~^
a.cc:11:52: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
11 | else if(human[i]==2) hand[1]++;
| ~~~~~~^
a.cc:12:36: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
12 | else hand[2]++;
| ~~~~~~^
a.cc:14:108: error: expected primary-expression before '||' token
14 | if((hand[0]==true&&hand[0]==hand[1]&&hand[0]==hand[2])||(hand[0]==false&&hand[0]==hand[1]))||(hand[0]==false&&hand[0]==hand[2]))||(hand[1]==false&&hand[1]==hand[2])) for(int i=0;i<5;i++)cout<<'3'<<endl;
| ^~
a.cc:14:195: error: 'i' was not declared in this scope
14 | if((hand[0]==true&&hand[0]==hand[1]&&hand[0]==hand[2])||(hand[0]==false&&hand[0]==hand[1]))||(hand[0]==false&&hand[0]==hand[2]))||(hand[1]==false&&hand[1]==hand[2])) for(int i=0;i<5;i++)cout<<'3'<<endl;
| ^
a.cc:15:17: error: 'else' without a previous 'if'
15 | else if(hand[0]==)
| ^~~~
a.cc:15:34: error: expected primary-expression before ')' token
15 | else if(hand[0]==)
| ^
a.cc:16:17: error: expected primary-expression before 'else'
16 | else if(hand[0]==true&&hand[0]==hand[1]){
| ^~~~
|
s699995676 | p00205 | C++ |
#include <iostream>
using namespace std;
int main(){
int human[5];
while(cin>>human[0],human[0]){
if(human[0]==1) hand[0]++;
else if(human[0]==2) hand[1]++;
else hand[2]++;
bool hand[3]={0,0,0};
for(int i=1;i<5;i++){
cin>>human[i];
if(human[i]==1) hand[0]++;
else if(human[i]==2) hand[1]++;
else hand[2]++;
}
if((hand[0]==true&&hand[0]==hand[1]&&hand[0]==hand[2])||(hand[0]==false&&hand[0]==hand[1])||(hand[0]==false&&hand[0]==hand[2])||(hand[1]==false&&hand[1]==hand[2])){
for(int i=0;i<5;i++)cout<<'3'<<endl;
}
else if(hand[0]==true&&hand[0]==hand[1]){
for(int i=0;i<5;i++){
if(human[i]==1)cout<<'1'<<endl;
else cout<<'2'<<endl;
}
}
else if(hand[0]==true&&hand[0]==hand[2]){
for(int i=0;i<5;i++){
if(human[i]==3)cout<<'1'<<endl;
else cout<<'2'<<endl;
}
}
else if(hand[1]==true&&hand[1]==hand[2]){
for(int i=0;i<5;i++){
if(human[i]==2)cout<<'1'<<endl;
else cout<<'2'<<endl;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:8:33: error: 'hand' was not declared in this scope; did you mean 'rand'?
8 | if(human[0]==1) hand[0]++;
| ^~~~
| rand
a.cc:9:38: error: 'hand' was not declared in this scope; did you mean 'rand'?
9 | else if(human[0]==2) hand[1]++;
| ^~~~
| rand
a.cc:10:22: error: 'hand' was not declared in this scope; did you mean 'rand'?
10 | else hand[2]++;
| ^~~~
| rand
a.cc:14:47: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
14 | if(human[i]==1) hand[0]++;
| ~~~~~~^
a.cc:15:52: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
15 | else if(human[i]==2) hand[1]++;
| ~~~~~~^
a.cc:16:36: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
16 | else hand[2]++;
| ~~~~~~^
|
s659345384 | p00205 | C++ | int i,n,d=0b10110001000000;main(c,v){for(;;){for(v=c=i=0;i-5;++i){scanf("%d",&n);if(!n)exit(0);v|=n<<i*2;c|=1<<n;}for(n=((d>>c)&3),i=0;i-5;++i){printf("%d\n",v>>i*2&3-n?(n?2:3):1);}}} | a.cc:1:32: error: expected constructor, destructor, or type conversion before '(' token
1 | int i,n,d=0b10110001000000;main(c,v){for(;;){for(v=c=i=0;i-5;++i){scanf("%d",&n);if(!n)exit(0);v|=n<<i*2;c|=1<<n;}for(n=((d>>c)&3),i=0;i-5;++i){printf("%d\n",v>>i*2&3-n?(n?2:3):1);}}}
| ^
|
s993941342 | p00205 | C++ | #include<iostream>
#include<vector>
int main(){
while(1){
std::vector<int> vec(5);
std::vector<int> vec2(5);
int a;
std::cin>>a;
if(a==0)break;
vec[0]=a;
int d,e,f;
if(a==1)d++;
if(a==2)e++;
if(a==3)f++;
for(int i=1;i<5;i++){
int b;
if(b==1)d++;
if(b==2)e++;
if(b==3)f++;
std::cin>>b;
}
std::vector<int> vec2(5);
if(d>=1&&e>=1&&f>=1||d==5||f==5||e==5){
for(int i=0;i<5;i++){
vec2[i]=3;
}
}else if(d>=1&&e>=1&&f==0){
for(int i=0;i<5;i++){
if(vec[i]==1)vec2[i]=1;
if(vec[i]==2)vec2[i]=2;
}
}else if(d>=0&&e>=1&&f==1){
for(int i=0;i<5;i++){
if(vec[i]==2)vec2[i]=1;
if(vec[i]==3)vec2[i]=2;
}
}else if(d>=1&&e>=0&&f==1){
for(int i=0;i<5;i++){
if(vec[i]==1)vec2[i]=2;
if(vec[i]==3)vec2[i]=1;
}
}
for(int i=0;i<5;i++){
std::cout<<vec2[i]<<std::endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:22:34: error: redeclaration of 'std::vector<int> vec2'
22 | std::vector<int> vec2(5);
| ^~~~
a.cc:6:34: note: 'std::vector<int> vec2' previously declared here
6 | std::vector<int> vec2(5);
| ^~~~
|
s122954845 | p00205 | C++ | #include<iostream>
using namespace std;
int main(){
long x[5],h[4],i;
while(cin>>x[0]){
if(x[0]==0)break;
for(i=1;i<=3;i++)h[i]=0;
h[x[0]]++;
for(i=1;i<5;i++){cin>>x[i];h[x[i]]++;}
for(j=0,i=1;i<=3;i++)if(h[i]==0)j++;
if(j==2||j==0){
for(i=0;i<5;i++)cout<<"3"<<endl;
else if(j==1){
for(i=1;i<=3;i++)if(h[i]==0)break;
if(i==1){
for(i=0;i<5;i++)cout<<x[i]-1<<endl;
}else if(i==2){
for(i=0;i<5;i++)cout<<(x[i]+1)%3<<endl;
}else if(i==3){
for(i=0;i<5;i++)cout<<x[i]<<endl;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:5: error: 'j' was not declared in this scope
10 | for(j=0,i=1;i<=3;i++)if(h[i]==0)j++;
| ^
a.cc:11:4: error: 'j' was not declared in this scope
11 | if(j==2||j==0){
| ^
a.cc:13:1: error: expected '}' before 'else'
13 | else if(j==1){
| ^~~~
a.cc:11:15: note: to match this '{'
11 | if(j==2||j==0){
| ^
|
s645418011 | p00205 | C++ | #include<stdio.h>
int main(void)
{
int t[5]={0},t2=0,t3=0,t1=0,k,i;
while(scanf("%d",&k)!=0){
t2=0; t3=0; t1=0;
for(i=0;i<5;i++){
scnaf("%d",&t[i]);
if(t[i]==1)
t1++;
else if(t[i]==2)
t2++;
else if(t[i]==3)
t3++;
}
if(t1==0){
if(t2==0 or t3==0)
for(i=0;i<5;i++) t[i]=3;
else
for(i=0;i<5;i++){
if(t[i]==2) t[i]=1;
else if(t[i]==3) t[i]=2;
}
}
else if(t2==0){
if(t1==0 or t3==0)
for(i=0;i<5;i++) t[i]=3;
else
for(i=0;i<5;i++){
if(t[i]==1) t[i]=2;
else if(t[i]==3) t[i]=1;
}
}
else if(t3==0){
if(t2==0 or t1==0)
for(i=0;i<5;i++) t[i]=3;
else
for(i=0;i<5;i++){
if(t[i]==2) t[i]=2;
else if(t[i]==1) t[i]=1;
}
}
else
for(i=0;i<5;i++) t[i]=3;
for(i=0;i<5;i++)
printf("%d\n",t[i]);
}
return 0
} | a.cc: In function 'int main()':
a.cc:12:1: error: 'scnaf' was not declared in this scope; did you mean 'scanf'?
12 | scnaf("%d",&t[i]);
| ^~~~~
| scanf
a.cc:54:9: error: expected ';' before '}' token
54 | return 0
| ^
| ;
55 | }
| ~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.