submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s764935737 | p00440 | C++ | #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
int x=1;
int main()
{
while(x!=0){
int n,k,a[10^5];
cin >> n >> k;
if(n==0&&k==0)return 0;
for(int i=0;i<n;i++){
cin >> a[i];
a[i]=a[i]-i;
}
sort(a,a+n);
int b[10^5+2];
memset(b,0,sizeof(b));
for(int i=0;i<n;i++){
b[a[i]]++;
}
int ans=0;
for(int i=0;i<=100000;i++){
ans=max(ans,b[i]+b[i+1]);
}
printf("%d\n",ans);
}
} | a.cc: In function 'int main()':
a.cc:12:17: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
12 | int n,k,a[10^5];
| ^
| ---
| 1e
a.cc:12:15: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
12 | int n,k,a[10^5];
| ^~
| 0xa
a.cc:21:9: error: 'memset' was not declared in this scope
21 | memset(b,0,sizeof(b));
| ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include<algorithm>
+++ |+#include <cstring>
6 | using namespace std;
|
s624957548 | p00440 | C++ | #include "stdio.h"
#include <queue>
using namespace std;
int main()
{
int n,k;
scanf("%d %d",&n,&k);
priority_queue q;
for(int i = 0; i < k; i++)
{
int w;
scanf("%d",&w);
q.push(w);
}
int dp[2] = {0,0};
int flg = 0;
int max = 0;
if(q.top() == 0)
{
flg = 1;
q.pop();
}
for(int i = 0; i < n; i++)
{
if(q.empty() == true)
{
if(flg == 1)
{
if(max < dp[0] + 1)
{
max = dp[0] + 1;
}
}
if(max < dp[0])
{
max = dp[0];
}
if(max < dp[1])
{
max = dp[1];
}
break;
}
if(q.top() == i)
{
dp[0]++;
dp[1]++;
}
else
{
if(flg == 1)
{
if(max < dp[1])
{
max = dp[1];
}
dp[1] = dp[0] + 1;
}
if(max < dp[0])
{
max = dp[0];
}
dp[0] = 0;
}
}
printf("%d\n",max);
return 0;
} | a.cc:61:12: error: extended character is not valid in an identifier
61 | if(max < dp[0])
| ^
a.cc: In function 'int main()':
a.cc:10:17: error: class template argument deduction failed:
10 | priority_queue q;
| ^
a.cc:10:17: error: no matching function for call to 'priority_queue()'
In file included from /usr/include/c++/14/queue:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class _Alloc, class _Requires> priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
691 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate expects 5 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class _Alloc, class, class _Requires> priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
679 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate expects 5 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class _Alloc, class, class _Requires> priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
671 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class _Alloc, class, class _Requires> priority_queue(_InputIterator, _InputIterator, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
663 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class> priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
649 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class> priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
638 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class> priority_queue(_InputIterator, _InputIterator, const _Compare&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
629 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
594 | priority_queue(priority_queue&& __q, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
590 | priority_queue(const priority_queue& __q, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(const _Compare&, _Sequence&&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
585 | priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(const _Compare&, const _Sequence&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
579 | priority_queue(const _Compare& __x, const _Sequence& __c,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(const _Compare&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
573 | priority_queue(const _Compare& __x, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
569 | priority_queue(const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> priority_queue(const _Compare&, _Sequence&&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
563 | priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> priority_queue(const _Compare&, const _Sequence&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
558 | priority_queue(const _Compare& __x, const _Sequence& __s)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:554:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Seq, class _Requires> priority_queue()-> std::priority_queue<_Tp, _Sequence, _Compare>'
554 | priority_queue()
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:554:9: note: template argument deduction/substitution failed:
a.cc:10:17: note: couldn't deduce template parameter '_Tp'
10 | priority_queue q;
| ^
/usr/include/c++/14/bits/stl_queue.h:496:11: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>)-> std::priority_queue<_Tp, _Sequence, _Compare>'
496 | class priority_queue
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:496:11: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:818:5: note: candidate: 'template<class _Compare, class _Container, class _Allocator, class, class> std::priority_queue(_Compare, _Container, _Allocator)-> priority_queue<typename _Container::value_type, _Container, _Compare>'
818 | priority_queue(_Compare, _Container, _Allocator)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:818:5: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:811:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Compare, class _Container, class, class, class> std::priority_queue(_InputIterator, _InputIterator, _Compare, _Container)-> priority_queue<_ValT, _Container, _Compare>'
811 | priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(),
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:811:5: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:801:5: note: candidate: 'template<class _Compare, class _Container, class, class> std::priority_queue(_Compare, _Container)-> priority_queue<typename _Container::value_type, _Container, _Compare>'
801 | priority_queue(_Compare, _Container)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:801:5: note: candidate expects 2 arguments, 0 provided
a.cc:61:12: error: '\U00003000dp' was not declared in this scope
61 | if(max < dp[0])
| ^~~~
|
s224258063 | p00440 | C++ | #include "stdio.h"
#include <queue>
using namespace std;
int main()
{
int n,k;
scanf("%d %d",&n,&k);
priority_queue<int> q;
for(int i = 0; i < k; i++)
{
int w;
scanf("%d",&w);
q.push(w);
}
int dp[2] = {0,0};
int flg = 0;
int max = 0;
if(q.top() == 0)
{
flg = 1;
q.pop();
}
for(int i = 0; i < n; i++)
{
if(q.empty() == true)
{
if(flg == 1)
{
if(max < dp[0] + 1)
{
max = dp[0] + 1;
}
}
if(max < dp[0])
{
max = dp[0];
}
if(max < dp[1])
{
max = dp[1];
}
break;
}
if(q.top() == i)
{
dp[0]++;
dp[1]++;
}
else
{
if(flg == 1)
{
if(max < dp[1])
{
max = dp[1];
}
dp[1] = dp[0] + 1;
}
if(max < dp[0])
{
max = dp[0];
}
dp[0] = 0;
}
}
printf("%d\n",max);
return 0;
} | a.cc:61:12: error: extended character is not valid in an identifier
61 | if(max < dp[0])
| ^
a.cc: In function 'int main()':
a.cc:61:12: error: '\U00003000dp' was not declared in this scope
61 | if(max < dp[0])
| ^~~~
|
s234856570 | p00440 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
while(1){
int ans=0,p=0,n,k,x,a[100001]={},flag=0,sflag=0;
vector<int> V;
cin>>n>>k;
if(n==0 && k==0)
break;
for(int i=0;i<k;i++){
cin>>x;
if(x==0)
flag=1;
a[x]=1;
}
for(int i=1;i<=n;i++){
if(sflag==0 && a[i])
sflag=1;
if(sflag){
if(a[i])
p++;
else{
sflag=0;
V.push_back(p);
p=0;
}
}
}
V.push_back(p);
if(flag){
for(int i=0;i<V.size()-1;i++)
ans=max(V[i]+V[i+1]+1,ans);
}else{
for(int i=0;i<V.size();i++)
ans=max(V[i],ans);
}
endl<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:39:21: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator<<'
39 | endl<<ans<<endl;
| ~~~~^~~~~
|
s316071255 | p00440 | C++ | #include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define MAX 100000
int main(){
int N, K, in;
while(scanf("%d%d" ,&N ,&K), (N | K)){
bool found = false, used[MAX+2];
vector<int> vec;
int start = MAX;
memset(used,false,sizeof(used));
for(int i = 0 ; i < K ; i++){
scanf("%d" ,&in);
if(in){
start = min(start, in);
used[in] = true;
vec.push_back(in);
}else{
found = true;
}
}
int res = 1;
if(found){
start--;
int cnt = 0, pos, p = 0;
for(int i = start ; i <= N+1 ; i++){
if(used[i]){
cnt++;
}else{
p++;
if(p == 1){
pos = i + 1;
if(i != 0 || i != N+1){
cnt++;
}
}
if(i == 0) continue;
if(p == 2){
res = max(res,cnt);
p = 1;
cnt = i - pos + 1;
pos = i + 1;
}
}
}
}else{
sort(vec.begin(),vec.end());
int cnt = 0;
for(int i = 1 ; i < K ; i++){
if(vec[i] - vec[i-1] == 1){
cnt++;
res = max(res,cnt);
}else{
cnt = 1;
}
}
}
printf("%d\n" ,res);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:17:5: error: 'memset' was not declared in this scope
17 | memset(used,false,sizeof(used));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <vector>
+++ |+#include <cstring>
4 |
|
s317804137 | p00441 | C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct pole{
struct pole* next;
int y;
} Pole;
Pole* table[5001];
int search(int x,int y)
{
if(x < 0 || y < 0)return 0;
if(table[x] != NULL)
{
Pole* pt = table[x];
while(pt->next != NULL)
{
if(pt->y == y)
return 1;
pt = pt->next;
}
if(pt->y == y)
return 1;
}
return 0;
}
int main()
{
int** poleList;
int n;
int i,j,k,l,m,o;
while(scanf("%d",&n),n)
{
for(i = 0;i <= 5000;i++)
{
table[i] = NULL;
}
poleList = (int**)malloc(sizeof(int*)*n);
for(i = 0;i < n;i++)
{
int x,y;
scanf("%d %d",&x,&y);
poleList[i] = (int*)malloc(sizeof(int)*2);
poleList[i][0] = x;
poleList[i][1] = y;
if(table[x] == NULL)
{
table[x] = (Pole*)malloc(sizeof(Pole));
table[x]->next = NULL;
table[x]->y = y;
}
else
{
Pole* tmp = table[x];
table[x] = (Pole*)malloc(sizeof(Pole));
table[x]->next = tmp;
table[x]->y = y;
}
}
int maxsq = 0;
for(i = 0;i < n;i++)
{
for(j = (i+1);j < n;j++)
{
double posx[6] = {
poleList[i][0]+poleList[i][1]-poleList[j][1],
poleList[j][0]+poleList[i][1]-poleList[j][1],
poleList[i][0]-poleList[i][1]+poleList[j][1],
poleList[j][0]-poleList[i][1]+poleList[j][1],
(poleList[i][0]+poleList[j][0]+poleList[i][1]-poleList[j][1])/2,
(poleList[i][0]+poleList[j][0]-poleList[i][1]+poleList[j][1])/2
};
double posy[6] = {
poleList[i][1]-poleList[i][0]+poleList[j][0],
poleList[j][1]-poleList[i][0]+poleList[j][0],
poleList[i][1]+poleList[i][0]-poleList[j][0],
poleList[j][1]+poleList[i][0]-poleList[j][0],
(poleList[i][1]+poleList[j][1]-poleList[i][0]+poleList[j][0])/2,
(poleList[i][1]+poleList[j][1]+poleList[i][0]-poleList[j][0])/2
};
int sq = (poleList[i][0]-poleList[j][0])*(poleList[i][0]-poleList[j][0])
+(poleList[i][1]-poleList[j][1])*(poleList[i][1]-poleList[j][1]);
if(search(posx[0],posy[0]) && search(posx[1],posy[1]) || search(posx[2],posy[2]) && search(posx[3],posy[3]))
if(sq < maxsq)continue;
else maxsq = sq;
}
else if(search(posx[4],posy[4]) && search(posx[5],posy[5]))
{
if(sq < maxsq*2)continue;
else maxsq = sq/2;
}
}
}
printf("%d\n",maxsq);
}
return 0;
} | main.c: In function 'main':
main.c:90:33: error: 'else' without a previous 'if'
90 | else if(search(posx[4],posy[4]) && search(posx[5],posy[5]))
| ^~~~
main.c:90:48: error: 'posx' undeclared (first use in this function)
90 | else if(search(posx[4],posy[4]) && search(posx[5],posy[5]))
| ^~~~
main.c:90:48: note: each undeclared identifier is reported only once for each function it appears in
main.c:90:56: error: 'posy' undeclared (first use in this function)
90 | else if(search(posx[4],posy[4]) && search(posx[5],posy[5]))
| ^~~~
main.c:92:44: error: 'sq' undeclared (first use in this function)
92 | if(sq < maxsq*2)continue;
| ^~
main.c:97:31: error: 'maxsq' undeclared (first use in this function)
97 | printf("%d\n",maxsq);
| ^~~~~
main.c: At top level:
main.c:99:9: error: expected identifier or '(' before 'return'
99 | return 0;
| ^~~~~~
main.c:100:1: error: expected identifier or '(' before '}' token
100 | }
| ^
|
s556410699 | p00441 | C++ | #include<iostream>
#include<cstdio>
#include<fstream>
using namespace std;
int main()
{
int n,x[3000],y[3000];
bool f[5001][5001];
while(true){
int ans=0;
cin >> n;
if(n==0)return 0;
memset(f,false,sizeof(f));
for(int i=0;i<n;i++){
cin >> x[i] >> y[i];
f[x[i]][y[i]]=true;
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
int a,b,c,d;
a=x[j]+y[i]-y[j];
b=y[j]+x[j]-x[i];
c=x[i]+y[i]-y[j];
d=y[i]+x[j]-x[i];
bool f1=false,f2=false;
if(a>=0&&a<=5000&&b>=0&&b<=5000&&f[a][b])f1=true;
if(c>=0&&c<=5000&&d>=0&&d<=5000&&f[c][d])f2=true;
if(f1&&f2)ans=max(ans,(a-c)*(a-c)+(b-d)*(b-d));
}
}
cout << ans << "\n";
}
} | a.cc: In function 'int main()':
a.cc:13:17: error: 'memset' was not declared in this scope
13 | memset(f,false,sizeof(f));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<fstream>
+++ |+#include <cstring>
4 | using namespace std;
|
s735154244 | p00441 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int grid[6000][6000];
struct cord{
int x,y;
cord operator+(const cord& a)const{
cord res;
res.x=a.x+x;
res.y=a.y+y;
return res;
}
cord operator-(const cord& a)const{
cord res;
res.x=a.x-x;
res.y=a.y-y;
return res;
}
bool operator<=(const cord& a)const{
if(a.x<=x && a.y<=y)return true;
return false;
}
};
void rev(cord& a){
int tmp;
tmp=a.x;
a.x=a.y;
a.y=-tmp;
}
int main(){
int n;
while(cin>>n,n){
memset(grid,0,sizeof(grid));
cord *x;
x=new cord[n];
for (int i = 0; i < n; i++){
cin>>x[i].x>>x[i].y;
grid[x[i].y][x[i].x]=1;
}
int ans=0;
for (int i = 0; i < n; i++){
cord a=x[i];
for (int j = 0; j < n && j != i; j++){
cord b=x[j];
cord d;
cord emp;
emp.x=0;emp.y=0;
d=a-b;
rev(d);
//cout << "d.x:" << d.x << " d.y:" << d.y<< endl;
//cout << "i:" << i << " j:" << j << endl;
if(emp<=a+d && emp<=b+d &&
grid[a.y+d.y][a.x+d.x]==1 &&
grid[b.y+d.y][b.x+d.x]==1){
cord tmp=a-b;
ans=max(ans,tmp.x*tmp.x+tmp.y*tmp.y);
// cout << "ans:" << ans<< endl;
}
if(emp<=a-d && emp<=b-d &&
grid[a.y-d.y][a.x-d.x]==1 &&
grid[b.y-d.y][b.x-d.x]==1){
cord tmp=a-b;
ans=max(ans,tmp.x*tmp.x+tmp.y*tmp.y);
// cout << "ans:" << ans<< endl;
}
}
}
cout << ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:37:5: error: 'memset' was not declared in this scope
37 | memset(grid,0,sizeof(grid));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 | using namespace std;
|
s412184301 | p00441 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int grid[6000][6000];
struct cord{
int x,y;
cord operator+(const cord& a)const{
cord res;
res.x=a.x+x;
res.y=a.y+y;
return res;
}
cord operator-(const cord& a)const{
cord res;
res.x=a.x-x;
res.y=a.y-y;
return res;
}
bool operator<=(const cord& a)const{
if(a.x<=x && a.y<=y)return true;
return false;
}
};
void rev(cord& a){
int tmp;
tmp=a.x;
a.x=a.y;
a.y=-tmp;
}
int main(){
int n;
while(cin>>n,n){
memset(grid,0,sizeof(grid));
cord *x;
x=new cord[n];
for (int i = 0; i < n; i++){
cin>>x[i].x>>x[i].y;
grid[x[i].y][x[i].x]=1;
}
int ans=0;
for (int i = 0; i < n; i++){
cord a=x[i];
for (int j = 0; j < n && j != i; j++){
cord b=x[j];
cord d;
cord emp;
emp.x=0;emp.y=0;
d=a-b;
rev(d);
//cout << "d.x:" << d.x << " d.y:" << d.y<< endl;
//cout << "i:" << i << " j:" << j << endl;
if(emp<=a+d && emp<=b+d &&
grid[a.y+d.y][a.x+d.x]==1 &&
grid[b.y+d.y][b.x+d.x]==1){
cord tmp=a-b;
ans=max(ans,tmp.x*tmp.x+tmp.y*tmp.y);
// cout << "ans:" << ans<< endl;
}
if(emp<=a-d && emp<=b-d &&
grid[a.y-d.y][a.x-d.x]==1 &&
grid[b.y-d.y][b.x-d.x]==1){
cord tmp=a-b;
ans=max(ans,tmp.x*tmp.x+tmp.y*tmp.y);
// cout << "ans:" << ans<< endl;
}
}
}
cout << ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:37:5: error: 'memset' was not declared in this scope
37 | memset(grid,0,sizeof(grid));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 | using namespace std;
|
s353846041 | p00441 | C++ | #include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
int grid[6000][6000];
struct cord{
int x,y;
cord operator+(const cord& a)const{
cord res;
res.x=a.x+x;
res.y=a.y+y;
return res;
}
cord operator-(const cord& a)const{
cord res;
res.x=a.x-x;
res.y=a.y-y;
return res;
}
bool operator<=(const cord& a)const{
if(a.x<=x && a.y<=y)return true;
return false;
}
};
void rev(cord& a){
int tmp;
tmp=a.x;
a.x=a.y;
a.y=-tmp;
}
int main(){
int n;
while(cin>>n,n){
memset(grid,0,sizeof(grid));
cord *x;
x=new cord[n];
for (int i = 0; i < n; i++){
cin>>x[i].x>>x[i].y;
grid[x[i].y][x[i].x]=1;
}
int ans=0;
for (int i = 0; i < n; i++){
cord a=x[i];
for (int j = 0; j < n && j != i; j++){
cord b=x[j];
cord d;
cord emp;
emp.x=0;emp.y=0;
d=a-b;
rev(d);
//cout << "d.x:" << d.x << " d.y:" << d.y<< endl;
//cout << "i:" << i << " j:" << j << endl;
if(emp<=a+d && emp<=b+d &&
grid[a.y+d.y][a.x+d.x]==1 &&
grid[b.y+d.y][b.x+d.x]==1){
cord tmp=a-b;
ans=max(ans,tmp.x*tmp.x+tmp.y*tmp.y);
// cout << "ans:" << ans<< endl;
}
if(emp<=a-d && emp<=b-d &&
grid[a.y-d.y][a.x-d.x]==1 &&
grid[b.y-d.y][b.x-d.x]==1){
cord tmp=a-b;
ans=max(ans,tmp.x*tmp.x+tmp.y*tmp.y);
// cout << "ans:" << ans<< endl;
}
}
}
cout << ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:38:5: error: 'memset' was not declared in this scope
38 | memset(grid,0,sizeof(grid));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<utility>
+++ |+#include <cstring>
4 | using namespace std;
|
s714199198 | p00441 | C++ | #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#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 all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
/*namespace std {
bool operator < (const int& a, const int& b) {
return
//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 in[5001][5001];
int main(){
int n;
while(cin>>n,n){
memset(in,0,sizeof(in));
vector<int>x(n);
vector<int>y(n);
rep(i,n){
cin>>x[i]>>y[i];
in[x[i]][y[i]]=true;
}
rep(i,n)rep(j,n)if(x[i]<x[j]){swap(x[i],x[j]);swap(y[i],y[j]);}
else if(x[i]==x[j]&&y[i]<y[j])swap(y[i],y[j]);
int out=0;
rep(i,n){
loop(j,i+1,n){
if(x[i]+y[j]-y[i]<5001&&x[j]+y[j]-y[i]<5001&&
y[i]+x[i]-x[j]<5001&&y[j]+x[i]-x[j]<5001&&
x[i]+y[j]-y[i]>=0&&x[j]+y[j]-y[i]>=0&&
y[i]+x[i]-x[j]>=0&&y[j]+x[i]-x[j]>=0&& in[x[i]+y[j]-y[i]][y[i]+x[i]-x[j]]&&
in[x[j]+y[j]-y[i]][y[j]+x[i]-x[j]])
out=max(out,(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}
}
cout<<out<<endl;
}
//rep(i,n)cout<<x[i]<<" "<<y[i]<<endl;
} | a.cc: In function 'int main()':
a.cc:32:17: error: 'memset' was not declared in this scope
32 | memset(in,0,sizeof(in));
| ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
9 | #include<cstdio>
+++ |+#include <cstring>
10 | #define loop(i,a,b) for(int i=a;i<b;i++)
|
s422691761 | p00441 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int N;
int X[3000], Y[3000];
bool F[5001][5001];
int solve(int P, int Q){
int xp = X[P];
int yp = Y[P];
int xq = X[Q];
int yq = Y[Q];
int xs = xp + (yp - yq);
int ys = yp + (xq - xp);
int xr = xq + (yp - yq);
int yr = yq + (xq - xp);
if ((xs>=0&&xs<=5000)&&(ys>=0&&ys<=5000)&&(xr>=0&&xr<=5000)&&(yr>=0&&yr<=5000)&&F[xs][ys]&&F[xr][yr])return (xq - xp)*(xq - xp) + (yq - yp)*(yq - yp);
xs = xp - (yp - yq);
ys = yp - (xq - xp);
xr = xq - (yp - yq);
yr = yq - (xq - xp);
if ((xs >= 0 && xs<=5000) && (ys >= 0 && ys<=5000) && (xr >= 0 && xr<=5000) && (yr >= 0 && yr<=5000) && F[xs][ys] && F[xr][yr])return (xq - xp)*(xq - xp) + (yq - yp)*(yq - yp);
return 0;
}
int main()
{
while (true){
scanf_s("%d", &N);
if (N == 0)return 0;
for (int i = 0; i < N; i++){
scanf_s("%d%d", &X[i], &Y[i]);
F[X[i]][Y[i]] = true;
}
int ans = 0;
for (int i = 0; i < N; i++){
for (int j = i + 1; j < N; j++){
ans = max(ans, solve(i, j));
}
}
printf("%d\n", ans);
for (int i = 0; i < N; i++)F[X[i]][Y[i]] = false;
}
} | a.cc: In function 'int main()':
a.cc:28:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
28 | scanf_s("%d", &N);
| ^~~~~~~
| scanf
|
s369573415 | p00441 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;
#define x first
#define y second
int main() {
int n;
while (cin >> n, n) {
map<int, bool> has;
vector<pair<int,int> > co(n);
for (int i=0; i<n; ++i) {
cin >> co[i].x >> co[i].y;
has[x+10000*y] = true;
}
sort(co.begin(), co.end());
int area = 0;
for (int i=0; i<(int)co.size(); ++i) {
for (int j=i+1; j<(int)co.size(); ++j) {
int x1, y1, x2, y2, x3, y3, x4, y4, dx, dy;
x1 = co[i].x; y1 = co[i].y;
x2 = co[j].x; y2 = co[j].y;
dx = x2 - x1; dy = y2 - y1;
x3 = co[j].x - dy; y3 = co[j].y + dx;
x4 = co[i].x - dy; y4 = co[i].y + dx;
if (has[x3+10000*y3] && has[x4+10000*y4]) {
area = max(area, abs((x1-x2)*(y3-y2)-(x3-x2)*(y1-y2)));
}
}
}
cout << area << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:11:11: error: 'first' was not declared in this scope
11 | #define x first
| ^~~~~
a.cc:21:17: note: in expansion of macro 'x'
21 | has[x+10000*y] = true;
| ^
a.cc:12:11: error: 'second' was not declared in this scope
12 | #define y second
| ^~~~~~
a.cc:21:25: note: in expansion of macro 'y'
21 | has[x+10000*y] = true;
| ^
|
s569443045 | p00441 | C++ | #include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 511;
using namespace std;
int x[MAX],y[MAX];
void solve(){
int n;
for(;;){
cin>>n;
if(!n) break;
FOR(i,n) cin>>x[i]>>y[i];
set<pii> st;
FOR(i,n) st.insert(mp(x[i],y[i]));
int ma=0;
FOR(i,n){
FORR(j,i+1,n){
pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
if((st.find(p)!=st.end()&&st.find(q)!=st.end())||(st.find(r)!=st.end()&&st.find(s)!=st.end())){
ma=max(ma,abs(2*v.first*v.second));
}
}
}
cout<<ma<<endl;
}
}
int main(){
solve();
return 0;
} | a.cc:11:16: error: expected ']' before ';' token
11 | #define MAX 511;
| ^
a.cc:14:7: note: in expansion of macro 'MAX'
14 | int x[MAX],y[MAX];
| ^~~
a.cc:14:10: error: expected unqualified-id before ']' token
14 | int x[MAX],y[MAX];
| ^
a.cc:14:17: error: expected unqualified-id before ']' token
14 | int x[MAX],y[MAX];
| ^
a.cc: In function 'void solve()':
a.cc:21:17: error: 'x' was not declared in this scope
21 | FOR(i,n) cin>>x[i]>>y[i];
| ^
a.cc:21:23: error: 'y' was not declared in this scope
21 | FOR(i,n) cin>>x[i]>>y[i];
| ^
a.cc:23:25: error: 'x' was not declared in this scope
23 | FOR(i,n) st.insert(mp(x[i],y[i]));
| ^
a.cc:5:27: note: in definition of macro 'mp'
5 | #define mp(x,y) make_pair(x,y)
| ^
a.cc:23:30: error: 'y' was not declared in this scope
23 | FOR(i,n) st.insert(mp(x[i],y[i]));
| ^
a.cc:5:29: note: in definition of macro 'mp'
5 | #define mp(x,y) make_pair(x,y)
| ^
a.cc:27:11: error: 'x' was not declared in this scope
27 | pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
| ^
a.cc:27:21: error: 'y' was not declared in this scope
27 | pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
| ^
|
s431431615 | p00441 | C++ | #include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 511;
using namespace std;
int x[MAX],y[MAX];
void solve(){
int n;
for(;;){
cin>>n;
if(!n) break;
FOR(i,n) cin>>x[i]>>y[i];
set<pii> st;
FOR(i,n) st.insert(mp(x[i],y[i]));
int ma=0;
FOR(i,n){
FORR(j,i+1,n){
pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
if((st.find(p)!=st.end()&&st.find(q)!=st.end())||(st.find(r)!=st.end()&&st.find(s)!=st.end())){
ma=max(ma,abs(2*v.first*v.second));
}
}
}
cout<<ma<<endl;
}
}
int main(){
solve();
return 0;
} | a.cc:11:16: error: expected ']' before ';' token
11 | #define MAX 511;
| ^
a.cc:14:7: note: in expansion of macro 'MAX'
14 | int x[MAX],y[MAX];
| ^~~
a.cc:14:10: error: expected unqualified-id before ']' token
14 | int x[MAX],y[MAX];
| ^
a.cc:14:17: error: expected unqualified-id before ']' token
14 | int x[MAX],y[MAX];
| ^
a.cc: In function 'void solve()':
a.cc:21:17: error: 'x' was not declared in this scope
21 | FOR(i,n) cin>>x[i]>>y[i];
| ^
a.cc:21:23: error: 'y' was not declared in this scope
21 | FOR(i,n) cin>>x[i]>>y[i];
| ^
a.cc:23:25: error: 'x' was not declared in this scope
23 | FOR(i,n) st.insert(mp(x[i],y[i]));
| ^
a.cc:5:27: note: in definition of macro 'mp'
5 | #define mp(a,b) make_pair(a,b)
| ^
a.cc:23:30: error: 'y' was not declared in this scope
23 | FOR(i,n) st.insert(mp(x[i],y[i]));
| ^
a.cc:5:29: note: in definition of macro 'mp'
5 | #define mp(a,b) make_pair(a,b)
| ^
a.cc:27:11: error: 'x' was not declared in this scope
27 | pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
| ^
a.cc:27:21: error: 'y' was not declared in this scope
27 | pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
| ^
|
s580139884 | p00441 | C++ | #include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 511;
using namespace std;
int x[MAX],y[MAX];
void solve(){
int n;
for(;;){
cin>>n;
if(!n) break;
FOR(i,n) cin>>x[i]>>y[i];
set<pii> st;
FOR(i,n) st.insert(mp(x[i],y[i]));
int ma=0;
FOR(i,n){
FORR(j,i+1,n){
pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
if((st.find(p)!=st.end()&&st.find(q)!=st.end())||(st.find(r)!=st.end()&&st.find(s)!=st.end())){
ma=max(ma,abs(2*v.first*v.second));
}
}
}
cout<<ma<<endl;
}
}
int main(){
solve();
return 0;
} | a.cc:11:16: error: expected ']' before ';' token
11 | #define MAX 511;
| ^
a.cc:14:7: note: in expansion of macro 'MAX'
14 | int x[MAX],y[MAX];
| ^~~
a.cc:14:10: error: expected unqualified-id before ']' token
14 | int x[MAX],y[MAX];
| ^
a.cc:14:17: error: expected unqualified-id before ']' token
14 | int x[MAX],y[MAX];
| ^
a.cc: In function 'void solve()':
a.cc:21:17: error: 'x' was not declared in this scope
21 | FOR(i,n) cin>>x[i]>>y[i];
| ^
a.cc:21:23: error: 'y' was not declared in this scope
21 | FOR(i,n) cin>>x[i]>>y[i];
| ^
a.cc:23:25: error: 'x' was not declared in this scope
23 | FOR(i,n) st.insert(mp(x[i],y[i]));
| ^
a.cc:5:27: note: in definition of macro 'mp'
5 | #define mp(a,b) make_pair(a,b)
| ^
a.cc:23:30: error: 'y' was not declared in this scope
23 | FOR(i,n) st.insert(mp(x[i],y[i]));
| ^
a.cc:5:29: note: in definition of macro 'mp'
5 | #define mp(a,b) make_pair(a,b)
| ^
a.cc:27:11: error: 'x' was not declared in this scope
27 | pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
| ^
a.cc:27:21: error: 'y' was not declared in this scope
27 | pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
| ^
|
s919311568 | p00441 | C++ | #include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 3333
using namespace std;
int x[MAX],y[MAX];
void solve(){
int n;
for(;;){
cin>>n;
if(!n) break;
FOR(i,n) cin>>x[i]>>y[i];
set<pii> st;
FOR(i,n) st.insert(mp(x[i],y[i]));
int ma=0;
FOR(i,n){
FORR(j,i+1,n){
pii v(x[j]-x[i],y[j]-y[i]),p(x[i]+v.second,y[i]-v.first),q(x[j]+v.second,y[j]-v.first),r(x[i]-v.second,y[i]+v.first),s(x[j]-v.second,y[j]+v.first);
if((st.find(p)!=st.end()&&st.find(q)!=st.end())||(st.find(r)!=st.end()&&st.find(s)!=st.end())){
ma=max(ma,v.first*v.first+v.second*v.second));
}
}
}
cout<<ma<<endl;
}
}
int main(){
solve();
return 0;
} | a.cc: In function 'void solve()':
a.cc:29:50: error: expected ';' before ')' token
29 | ma=max(ma,v.first*v.first+v.second*v.second));
| ^
| ;
|
s163437580 | p00441 | C++ | #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#define INF_LL 9000000000000000000
#define INF 2000000000
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;
class Union_find{
private:
vector<int> par;
vector<int> rank;
int n;
public:
Union_find(int a){
n = a;
for(int i = 0;i < n;i++){
par.push_back(i);
rank.push_back(0);
}
}
int find(int x){
if(par[x] == x){
return x;
}else{
return par[x] = find(par[x]);
}
}
void unite(int x, int y){
x = find(x);
y = find(y);
if(x == y) return;
if(rank[x] < rank[y]){
par[x] = y;
}else{
par[y] = x;
if(rank[x] == rank[y]) rank[x]++;
}
}
bool same(int x, int y){
return find(x) == find(y);
}
};
bool fld[5010][5010];
int main(void){
int n;
while(cin >> n && n){
vector<PII> p;
int res = 0;
memset(fld, 0, sizeof(fld));
REP(i, n){
int x, y;
cin >> x >> y;
p.push_back({x, y});
fld[x][y] = true;
}
REP(i, n){
REP(j, n){
if(i == j) continue;
int x = p[j].first-p[i].first;
int y = p[j].second-p[i].second;
int dx[4] = {x, -y, -x, y};
int dy[4] = {y, x, -y, -x};
bool flag = true;
int bx = p[i].first, by = p[i].second;
REP(k, 4){
if((bx < 0 || 5000 < bx || by < 0 || 5000 < by) || !fld[bx][by]){
flag = false;
break;
}
bx += dx[k];
by += dy[k];
}
if(flag) res = max(res, x*x+y*y);
}
}
cout << res << endl;
}
} | a.cc: In function 'int main()':
a.cc:70:9: error: 'memset' was not declared in this scope
70 | memset(fld, 0, sizeof(fld));
| ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
8 | #include <cmath>
+++ |+#include <cstring>
9 |
|
s052375599 | p00441 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b) ((a >> b) & 1)
#define bitset(a,b) ( a |= (1 << b))
#define bitunset(a,b) (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
if (b == 0) return a;
return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
{ 1,0 },{ 0,1 }
};
signed main() {
int n;
while (scanf("%d", &n)) {
if (!n)
break;
vector<vector<int>> m(5001,vector<int>(5001));
vector<pii> st;
REP(i, n) {
int x, y;
scanf("%d %d", &x, &y);
m[x][y] = 1;
st.push_back({ x,y });
}
sort(ALL(st));
int ans = 0;
REP(i, n) {
rep(j, i + 1, n) {
pii sa = { st[j].first - st[i].first, st[j].second - st[i].second };
bool f = 0;
pii nex = { st[j].first+sa.second, st[j].second-sa.first };
pii nexx = { cur.first - sa.first, cur.second - sa.second };
if (RANGE(nex.first, 0, 5000) && RANGE(nex.second, 0, 5000) && RANGE(nexx.first, 0, 5000) & RANGE(nexx.second, 0, 5000)) {
if (m[nex.first][nex.second] && m[nexx.first][nexx.second]) {
ans = max(ans, PW(sa.first)+ PW(sa.second));
}
}
}
}
printf("%d\n", ans);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:73:46: error: 'cur' was not declared in this scope
73 | pii nexx = { cur.first - sa.first, cur.second - sa.second };
| ^~~
a.cc:73:91: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'pii' {aka 'std::pair<int, int>'}
73 | pii nexx = { cur.first - sa.first, cur.second - sa.second };
| ^
| |
| <brace-enclosed initializer list>
|
s000967312 | p00441 | C++ | #include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
struct P{
int x,y;
};
int main() {
int n;
while(cin>>n&&n!=0){
P a[3000];
for(int i=0;i<n;i++){
cin>>a[i].x>>a[i].y;
}
int sum=0;
for(int i=0;i<n;i++){
int x1=a[i].x,y1=a[i].y;
for(int j=0;j<n;j++){
if(i!=j&&a[j].x>=x1&&a[j].y>=y1){
int x2=a[j].x,y2=a[j].y;
int x3=x2-x1,y3=y2-y1;
int x4=x2-y3,y4=y2+x3;
for(int j=0;j<n;j++){
if(a[j].x==x4&&a[j].y==y4){
goto sto;
}
}
goto stop;
sto:;
int x5=(x4-x3),y5=(y4-y3);
for(int j=0;j<n;j++){
if(a[j].x==x5&&a[j].y==y5){
goto stp;
}
}
goto stop;
stp:;
int sum2=(x2-x5)*(y4-y1);
sum2-=((x3*y3)*2);
sum=max(sum,sum2);
stop:;
}
}
}
}
cout<<sum<<endl;
} | a.cc: In function 'int main()':
a.cc:46:35: error: jump to label 'stop'
46 | stop:;
| ^~~~
a.cc:41:40: note: from here
41 | goto stop;
| ^~~~
a.cc:43:39: note: crosses initialization of 'int sum2'
43 | int sum2=(x2-x5)*(y4-y1);
| ^~~~
a.cc:46:35: error: jump to label 'stop'
46 | stop:;
| ^~~~
a.cc:33:40: note: from here
33 | goto stop;
| ^~~~
a.cc:43:39: note: crosses initialization of 'int sum2'
43 | int sum2=(x2-x5)*(y4-y1);
| ^~~~
a.cc:35:50: note: crosses initialization of 'int y5'
35 | int x5=(x4-x3),y5=(y4-y3);
| ^~
a.cc:35:39: note: crosses initialization of 'int x5'
35 | int x5=(x4-x3),y5=(y4-y3);
| ^~
a.cc:51:15: error: 'sum' was not declared in this scope
51 | cout<<sum<<endl;
| ^~~
|
s020657234 | p00441 | C++ | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
set<P> SET;
vector<P> point;
int main()
{
int n;
while(cin>>n,n) {
CLR(isp);
FOR(i,0,n) {
int y, x; cin >> y >> x;
SET.insert(P(y, x));
point.push_back(P(y, x));
}
int ans = 0;
FOR(i,0,n) {
int y = point[i].first;
int x = point[i].second;
FOR(j,0,n) {
if(i == j) continue;
int yy = point[j].first;
int xx = point[j].second;
int dy = yy - y;
int dx = xx - x;
if(dy >= 0 && dx >= 0) {
int Y = yy - dx;
int X = xx + dy;
if(Y > 5000 || X > 5000 || SET.count(P(Y, X)) == 0) continue;
Y = Y - dy;
X = X - dx;
if(Y > 5000 || X > 5000 || SET.count(P(Y, X)) == 0) continue;
Y = Y + dx;
X = X - dy;
if(y == Y && x == X) {
ans = max(ans, (dy+dx)*(dy+dx)-dy*dx*2);
}
}
}
}
cout << ans << '\n';
}
return 0;
} | a.cc: In function 'int main()':
a.cc:27:9: error: 'isp' was not declared in this scope
27 | CLR(isp);
| ^~~
a.cc:18:25: note: in definition of macro 'CLR'
18 | #define CLR(mat) memset(mat, 0, sizeof(mat))
| ^~~
|
s118320622 | p00441 | C++ | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
using namespace std;
int n;
typedef pair<int, int> P;
P pole[3005];
bool field[5005][5005];
int main(){
while(1){
scanf("%d", &n);
if(n == 0){
break;
}
int ans = 0;
fill(pole, pole+3005, P(0, 0));
for(int i = 0; i < 5005; i++){
for(int j = 0; j < 5005; j++){
field[i][j] = false;
}
}
for(int i = 0; i < n; i++){
scanf("%d%d", &pole[i].first, &pole[i].second);
field[pole[i].first][pole[i].second] = true;
}
sort(pole, pole+n);
/*for(int i = 0 ; i < n; i++){
printf("%d %d ", pole[i].first, pole[i].second);
}
printf("\n");
for(int y = 9; y >= 0; y--){
for(int x = 0; x < 9; x++){
if(field[x][y]){
printf("P ");
}else{
printf(". ");
}
}
printf("\n");
}*/
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
if(i == j){
continue;
}
P p1 = pole[i];
P p2 = pole[j];
P p3 = P(p1.first - (p2.second - p1.second), p1.second + (p2.first - p1.first));//3???????????????
P p4 = P(p2.first - (p2.second - p1.second), p2.second + (p2.first - p1.first));//4???????????????
if(p3.first >= 0 && p3.first < 5000 && p3.second >= 0 && p3.second < 5000 && p4.first >= 0 && p4.first < 5000 && p4.second >= 0 p4.second < 5000 && field[p3.first][p3.second] && field[p4.first][p4.second]){//3, 4????????????????????????????????§??????????????¨???????????????????????§??????
ans = max(ans, ((p2.second - p1.second) * (p2.second - p1.second) + (p2.first - p1.first) * (p2.first - p1.first)));
}
p3 = P(p1.first + (p2.second - p1.second), p1.second - (p2.first - p1.first));//??????(p1,p2)????????????????????´???????????????????????§???
p4 = P(p2.first + (p2.second - p1.second), p2.second - (p2.first - p1.first));
if(p3.first >= 0 && p3.first < 5000 && p3.second >= 0 && p3.second < 5000 && p4.first >= 0 && p4.first < 5000 && p4.second >= 0 p4.second < 5000 && field[p3.first][p3.second] && field[p4.first][p4.second]){
ans = max(ans, ((p2.second - p1.second) * (p2.second - p1.second) + (p2.first - p1.first) * (p2.first - p1.first)));
}
}
}
printf("%d\n", ans);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:61:160: error: expected ')' before 'p4'
61 | if(p3.first >= 0 && p3.first < 5000 && p3.second >= 0 && p3.second < 5000 && p4.first >= 0 && p4.first < 5000 && p4.second >= 0 p4.second < 5000 && field[p3.first][p3.second] && field[p4.first][p4.second]){//3, 4????????????????????????????????§??????????????¨???????????????????????§??????
| ~ ^~~
| )
a.cc:66:160: error: expected ')' before 'p4'
66 | if(p3.first >= 0 && p3.first < 5000 && p3.second >= 0 && p3.second < 5000 && p4.first >= 0 && p4.first < 5000 && p4.second >= 0 p4.second < 5000 && field[p3.first][p3.second] && field[p4.first][p4.second]){
| ~ ^~~
| )
|
s710880496 | p00441 | C++ | #include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#define INT_MAX 2000000000
#define MOD 1000000007
#define rep(i,aa,bb) for(i = (aa); i < (bb); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vsort(x) sort(x.begin(),x.end())
using int64 = long long int;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
std::fill((T*)array, (T*)(array + N), val);
}
using namespace std;
bool h[5001][5001] = {};
int main() {
int n;
int a[3000], b[3000];
int c;
int i, j, k;
int ans[10] = {};
int e;
int dx, dy;
rep(e, 0, 10) {
memset(h, sizeof(h), 0);
n = 1;
cin >> n;
if (n == 0) {
c = e;
break;
}
rep(i, 0, n) {
cin >> a[i] >> b[i];
h[a[i]][b[i]] = 1;
}
rep(i, 0, n) {
rep(j, 0, n) {
if (i != j) {
dy = a[i] - a[j];
dx = b[j] - b[i];
if ((0 <= a[i] + dx)&(a[i] + dx <= 5000) & (0 <= b[i] + dy)&(b[i] + dy <= 5000) & (0 <= a[j] + dx)&(a[j] + dx <= 5000) & (0 <= b[j] + dy)&(b[j] + dy <= 5000)) {
if (h[a[i] + dx][b[i] + dy] == 1 & h[a[j] + dx][b[j] + dy] == 1) {
ans[e] = max(dx*dx + dy*dy, ans[e]);
}
}
}
}
}
}
rep(k, 0, c) {
cout << ans[k] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:36:17: error: 'memset' was not declared in this scope
36 | memset(h, sizeof(h), 0);
| ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
8 | #include <vector>
+++ |+#include <cstring>
9 |
|
s536317260 | p00441 | C++ | #include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#define INT_MAX 2000000000
#define MOD 1000000007
#define rep(i,aa,bb) for(i = (aa); i < (bb); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vsort(x) sort(x.begin(),x.end())
using int64 = long long int;
using namespace std;
bool h[5001][5001] = {};
int main() {
int n;
int a[3000], b[3000];
int c;
int i, j, k;
int ans[10] = {};
int e;
int dx, dy;
rep(e, 0, 10) {
memset(h, sizeof(h), 0);
n = 1;
cin >> n;
if (n == 0) {
c = e;
break;
}
rep(i, 0, n) {
cin >> a[i] >> b[i];
h[a[i]][b[i]] = 1;
}
rep(i, 0, n) {
rep(j, 0, n) {
if (i != j) {
dy = a[i] - a[j];
dx = b[j] - b[i];
if ((0 <= a[i] + dx)&(a[i] + dx <= 5000) & (0 <= b[i] + dy)&(b[i] + dy <= 5000) & (0 <= a[j] + dx)&(a[j] + dx <= 5000) & (0 <= b[j] + dy)&(b[j] + dy <= 5000)) {
if (h[a[i] + dx][b[i] + dy] == 1 & h[a[j] + dx][b[j] + dy] == 1) {
ans[e] = max(dx*dx + dy*dy, ans[e]);
}
}
}
}
}
}
rep(k, 0, c) {
cout << ans[k] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:32:17: error: 'memset' was not declared in this scope
32 | memset(h, sizeof(h), 0);
| ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
8 | #include <vector>
+++ |+#include <cstring>
9 |
|
s015269648 | p00441 | C++ | #include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<double,double>P;
int n,x[3001],y[3001];
set<P>st;
int main(){
while(cin>>n,n){
st.clear();
r(i,n){
cin>>x[i]>>y[i];
st.insert(P(x[i],y[i]));
}
int ans=0;
r(i,n)r(j,n)if(i!=j){
int tx1=x[i]-x[j],ty1=y[i]-y[j];
int tx2=x[i]+ty1,ty2=y[i]-tx1;
int tx3=x[j]+ty1,ty3=y[j]-tx1;
int tx4=x[i]-ty1,ty4=y[i]+tx1;
int tx5=x[j]+ty1,ty5=y[j]+tx1;
if(st.count(P(tx2,ty2))&&st.count(P(tx3,ty3))||
st.count(P(tx4,ty4))&&st.count(P(tx5,ty5))){
ans=max(ans,tx1*tx1+ty1*ty1);
}
}
cout<<ans<<endl;
}
} | cc1plus: error: '::main' must return 'int'
|
s183005589 | p00441 | C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<bits/stdc++.h>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a){
return 0<=a&&a<=5000;
}
int main(){
while(cin>>n&&n){
int x[5000],y[5001],an=0;
for(int i=0;i<n;i++)cin>>x[i]>>y[i],p[x[i]][y[i]]=1;
for(int i=0;i<n;i++)
for(int j=i;j<n;j++){
int dx=x[i]-x[j],dy=y[i]-y[j];
int x1=x[i]-dy,y1=y[i]+dx,x2=x[j]-dy,y2=y[j]+dx;
int x3=x[i]-dy,y3=y[i]+dx,x4=x[j]+dy,y4=y[j]-dx;
if(c(x1)&&c(y1)&&p[x1][y1]&&c(x2)&&c(y2)&&p[x2][y2])
an=max(an,dx*dx+dy*dy);
if(c(x3)&&c(y3)&&p[x3][y3]&&c(x4)&&c(y4)&&p[x4][y4])
an=max(an,dx*dx+dy*dy);
}
cout<<an<<endl;
}
return 0;
} | a.cc:2:1: error: expected unqualified-id before numeric constant
2 | 1
| ^
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:27:
/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++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| |
s626049003 | p00441 | C++ | int main(){
while(1){
int n;
cin >> n;
if(n==0) break;
int X[1001],Y[1001];
bool exi[1001][1001];
for(int i=1; i<=n; i++){
cin >> X[i] >> Y[i];
exi[X[i]][Y[i]] = true;
}
bool sik=false;
priority_queue<int> PQ;
for(int i=1; i<n; i++){
for(int j=1; j<=n; j++){
int dx = X[j]-X[i];
int dy = Y[j]-Y[i];
if(exi[X[i]+dy][Y[i]-dx]==true && exi[X[j]+dy][Y[j]-dx]==true){
PQ.push(dx*dx + dy*dy);
sik = true;
}
if(exi[X[i]-dy][Y[i]+dx]==true && exi[X[j]-dy][Y[j]+dx]==true){
PQ.push(dx*dx + dy*dy);
sik = true;
}
}
}
if(sik) cout << PQ.top() << endl;
else cout << 0 << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
4 | cin >> n;
| ^~~
a.cc:13:5: error: 'priority_queue' was not declared in this scope
13 | priority_queue<int> PQ;
| ^~~~~~~~~~~~~~
a.cc:13:20: error: expected primary-expression before 'int'
13 | priority_queue<int> PQ;
| ^~~
a.cc:19:17: error: 'PQ' was not declared in this scope
19 | PQ.push(dx*dx + dy*dy);
| ^~
a.cc:23:17: error: 'PQ' was not declared in this scope
23 | PQ.push(dx*dx + dy*dy);
| ^~
a.cc:28:17: error: 'cout' was not declared in this scope
28 | if(sik) cout << PQ.top() << endl;
| ^~~~
a.cc:28:25: error: 'PQ' was not declared in this scope
28 | if(sik) cout << PQ.top() << endl;
| ^~
a.cc:28:37: error: 'endl' was not declared in this scope
28 | if(sik) cout << PQ.top() << endl;
| ^~~~
a.cc:29:14: error: 'cout' was not declared in this scope
29 | else cout << 0 << endl;
| ^~~~
a.cc:29:27: error: 'endl' was not declared in this scope
29 | else cout << 0 << endl;
| ^~~~
|
s290304681 | p00441 | C++ | #include <iostream>
using namespace std;
bool exi[5005][5005];
bool c(int a){
return 0<=a&&a<=5000;
}
int main(){
while(1){
int X[5005],Y[5005];
int n,au = 0;
cin >> n;
if(n==0) break;
for(int i=0; i<n; i++) cin >> X[i] >> Y[i]; exi[X[i]][Y[i]] = true;
for(int i=0; i<n; i++){
for(int j=i; j<n; j++){
int dx = X[i]-X[j];
int dy = Y[i]-Y[j];
int x1 = X[i]+dy; int x2 = X[j]-dy;
int y1 = Y[i]-dx; int y2 = Y[j]+dx;
if(exi[x1][y1]&&exi[x2][y2]&&c(x1)&&c(y1)&&c(x2)&&c(y2))
au = max(au, dx*dx+dy*dy);
if(exi[x2][y2]&&exi[x1][y1]&&c(x2)&&c(y2)&&c(x1)&&c(y1))
au = max(au, dx*dx+dy*dy);
}
}
cout << au << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:59: error: 'i' was not declared in this scope
15 | for(int i=0; i<n; i++) cin >> X[i] >> Y[i]; exi[X[i]][Y[i]] = true;
| ^
|
s607145746 | p00441 | C++ | #include <iostream>
using namespace std;
int n;
bool exi[5001][5001];
bool c(int a){
return 0<=a&&a<=5000;
}
int main(){
while(cin>>n&&n){
int X[5001],Y[5001];
int an = 0;
for(int i=0; i<n; i++) {
cin >> X[i] >> Y[i];
exi[X[i]][Y[i]] = 1;
}
for(int i=0; i<n; i++)
for(int j=i; j<n; j++){
int dx = X[i]-X[j];
int dy = Y[i]-Y[j];
int x1 = X[i]-dy; int x2 = X[j]-dy;
int y1 = Y[i]+dx; int y2 = Y[j]+dx;
int x3 = X[i]-dy,y3 = Y[i]+dx,x4=X[j]+dy,y4=Y[j]-dx;
if(exi[x1][y1]&&exi[x2][y2]&&c(x1)&&c(y1)&&c(x2)&&c(y2))
au = max(an, dx*dx+dy*dy);
if(exi[x3][y3]&&exi[x4][y4]&&c(x3)&&c(y3)&&c(x4)&&c(y4))
au = max(an, dx*dx+dy*dy);
}
cout<<an<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:21: error: 'au' was not declared in this scope; did you mean 'an'?
24 | au = max(an, dx*dx+dy*dy);
| ^~
| an
a.cc:26:21: error: 'au' was not declared in this scope; did you mean 'an'?
26 | au = max(an, dx*dx+dy*dy);
| ^~
| an
|
s527498905 | p00441 | C++ | #include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a){
return 0<=a&&a<=5000;
}
int main(){
while(cin>>n&&n){
int x[5001],y[5001];
int an = 0;
for(int i=0; i<n; i++) {
cin >> x[i] >> y[i];
exi[x[i]][y[i]] = 1;
}
for(int i=0; i<n; i++)
for(int j=i; j<n; j++){
int dx = x[i]-y[j];
int dy = x[i]-y[j];
int x1 = x[i]-dy; int x2 = x[j]-dy;
int y1 = y[i]+dx; int y2 = y[j]+dx;
int x3 = x[i]-dy,y3 = y[i]+dx,x4=x[j]+dy,y4=y[j]-dx;
if(exi[x1][y1]&&exi[x2][y2]&&c(x1)&&c(y1)&&c(x2)&&c(y2))
an = max(an, dx*dx+dy*dy);
if(exi[x3][y3]&&exi[x4][y4]&&c(x3)&&c(y3)&&c(x4)&&c(y4))
an = max(an, dx*dx+dy*dy);
}
cout<<an<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:14:13: error: 'exi' was not declared in this scope; did you mean 'exit'?
14 | exi[x[i]][y[i]] = 1;
| ^~~
| exit
a.cc:23:20: error: 'exi' was not declared in this scope; did you mean 'exit'?
23 | if(exi[x1][y1]&&exi[x2][y2]&&c(x1)&&c(y1)&&c(x2)&&c(y2))
| ^~~
| exit
a.cc:25:20: error: 'exi' was not declared in this scope; did you mean 'exit'?
25 | if(exi[x3][y3]&&exi[x4][y4]&&c(x3)&&c(y3)&&c(x4)&&c(y4))
| ^~~
| exit
|
s943558444 | p00441 | C++ | #include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a){
return 0<=a&&a<=5000;
}
int main(){
while(cin>>n&&n){
int x[5000],y[5001],an=0;
for(int i=0;i<n;i++)cin>>x[i]>>y[i],p[x[i]][y[i]]=1;
for(int i=0;i<n;i++)
for(int j=i;j<n;j++){
int dx = x[i]-x[j];
int dy = y[i]-y[j];
int x1 = x[i]-dy; int x2 = x[j]-dy;
int y1 = y[i]+dx; int y2 = y[j]+dx;
int x3 = x[i]-dy, y3 = y[i]+dx,x4 = x[j]+dy,y4 = y[j]-dx;
if(exi[x1][y1]&&exi[x2][y2]&&c(x1)&&c(y1)&&c(x2)&&c(y2))
an = max(an, dx*dx+dy*dy);
if(exi[x3][y3]&&exi[x4][y4]&&c(x3)&&c(y3)&&c(x4)&&c(y4))
an = max(an, dx*dx+dy*dy);
}
cout<<an<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:19:20: error: 'exi' was not declared in this scope; did you mean 'exit'?
19 | if(exi[x1][y1]&&exi[x2][y2]&&c(x1)&&c(y1)&&c(x2)&&c(y2))
| ^~~
| exit
a.cc:21:20: error: 'exi' was not declared in this scope; did you mean 'exit'?
21 | if(exi[x3][y3]&&exi[x4][y4]&&c(x3)&&c(y3)&&c(x4)&&c(y4))
| ^~~
| exit
|
s030723517 | p00441 | C++ | #include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a){
return 0<=a&&a<=5000;
}
int main(){
while(cin>>n&&n){
int x[5001],y[5001],an = 0;
for(int i=0; i<n; i++) cin >> x[i] >> y[i],p[x[i]][y[i]] = 1;
for(int i=0; i<n; i++)
for(int j=i; j<n; j++){
int dx = x[i]-x[j];
int dy = y[i]-y[j];
int x1 = x[i]-dy; int x2 = x[j]-dy;
int y1 = y[i]+dx; int y2 = y[j]+dx;
int x3 = x[i]-dy,y3 = y[i]+dx,x4=x[j]+dy,y4=y[j]-dx;
if(c(x1)&&c(y1)&&p[x1][y1]&&c(x2)&&c(y2)&&p[x2][y2])
an = max(an, dx*dx+dy*dy);
if((x3)&&c(y3)&&p[x3][y3]&&cc(x4)&&c(y4)&&p[x4][y4])
an = max(an, dx*dx+dy*dy);
}
cout<<an<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:21:44: error: 'cc' was not declared in this scope; did you mean 'c'?
21 | if((x3)&&c(y3)&&p[x3][y3]&&cc(x4)&&c(y4)&&p[x4][y4])
| ^~
| c
|
s934803822 | p00441 | C++ | #include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>
#define ll __int64
int n;
int x[4000],y[4000];
map<P,bool>table;
inline bool isRect(P t1,P t2){
int x1,x2,y1,y2,dx,dy,vx,vy;
if(t1.first>t2.first)swap(t1,t2);
x1=t1.first;
x2=t2.first;
y1=t1.second;
y2=t2.second;
dx=x2-x1;
dy=y2-y1;
vx=dy;
vy=-dx;
//cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<dx<<" "<<dy<<endl;
return (table[mp(x1+vx,y1+vy)])&&(table[mp(x2+vx,y2+vy)]);
}
int main(){
while(cin>>n,n){
table.clear();
memset(x,0,sizeof x);
memset(y,0,sizeof y);
rep(i,n){
cin>>x[i]>>y[i];
table[mp(x[i],y[i])]=1;
}
int ans=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(isRect(mp(x[i],y[i]),mp(x[j],y[j]))){
ans=max(ans,((x[i]-x[j])*(x[i]-x[j]))+((y[i]-y[j])*(y[i]-y[j])));
//cout<<x[i]<<" "<<y[i]<<" "<<x[j]<<" "<<y[j]<<endl;
}
}
}
cout<<ans<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:41:1: error: 'memset' was not declared in this scope
41 | memset(x,0,sizeof x);
| ^~~~~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
11 | #include<fstream>
+++ |+#include <cstring>
12 | using namespace std;
|
s604396222 | p00441 | C++ | #include<cstdio>
#include<vector>
#include<algorithm>
#include<set>
#define men(d) (((d.vx*d.vx)+(d.vy*d.vy))/2)
using namespace std;
struct Data{
unsigned short vx : 13;
signed short vy : 14;
unsigned short cx : 13;
unsigned short cy : 13;
Data(unsigned short a,signed short b,unsigned short c,unsigned short d){
vx=a;
vy=b;
cx=c;
cy=d;
}
Data(){}
};
inline bool operator<(const Data &a,const Data &b){
if(a.vx<b.vx)return true;
if(a.vx==b.vx&&a.vy<b.vy)return true;
if(a.vx==b.vx&a.vy==b.vy&&a.cx<b.cx)return true;
if(a.vx==b.vx&&a.vy==b.vy&&a.cx==b.cx&&a.cy<b.cy)return true;
return false;
}
inline bool operator==(const Data &a,const Data &b){
return a.vx==b.vx&&a.vy==b.vy&&a.cx==b.cx&&a.cy==b.cy;
}
int main(){
int n;
for(;;){
scanf("%d",&n);
if(n==0)break;
vector<pair<int,int> > ins(n);
for(int i=0;i<n;i++){
int x,y;
scanf("%d%d",&x,&y);
ins[i]=make_pair(x,y);
}
vector<Data> high,mid,low;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
int tx=ins[i].fisrt-ins[j].first,ty=ins[i].second-ins[j].second;
Data d;
if(tx>=0){
d.vx=tx;
d.vy=ty;
}else{
d.vx=-tx;
d.vy=-ty;
}
d.cx=(ins[i].first+ins[j].first)/2;
d.cy=(ins[i].second+ins[j].second)/2;
if(d.vy==0)mid.push_back(d);
else if(d.vy>0)high.push_back(d);
else low.push_back(d);
}
}
sort(&high[0],&high[0]+high.size());
sort(&mid[0],&mid[0]+mid.size());
sort(&low[0],&low[0]+low.size());
int ma=0;
for(int i=0;i<mid.size();i++){
if(binary_search(high.begin(),high.end(),Data(0,mid[i].vx,mid[i].cx,mid[i].cy))||binary_search(low.begin(),low.end(),Data(0,-mid[i].vx,mid[i].cx,mid[i].cy)))ma=max(ma,men(mid[i]));
}
for(int i=0;i<high.size();i++){
if(binary_search(low.begin(),low.end(),Data(high[i].vy,-high[i].vx,high[i].cx,high[i].cy)))ma=max(ma,men(high[i]));
}
printf("%d\n",ma);
}
} | a.cc: In function 'int main()':
a.cc:44:31: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fisrt'; did you mean 'first'?
44 | int tx=ins[i].fisrt-ins[j].first,ty=ins[i].second-ins[j].second;
| ^~~~~
| first
a.cc:48:26: error: 'ty' was not declared in this scope; did you mean 'tx'?
48 | d.vy=ty;
| ^~
| tx
a.cc:51:27: error: 'ty' was not declared in this scope; did you mean 'tx'?
51 | d.vy=-ty;
| ^~
| tx
|
s004758988 | p00441 | C++ | #include <stdio.h>
#include <iostream>
#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 <sstream>
using namespace std;
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))
typedef complex<double> P;
typedef long long ll;
const int MAX_SIZE = 10000;
int main(){
int n;
while(cin>>n&&n!=0){
int S = 0;
// _ÌÀWði[
pair<int,int> dots[3001];
// _ª éÀWɶݷé©Ç¤©
bool points[5001][5001];
//for(int i = 0; i < 5001; i++)
// fill(points[i],points[i]+5001,false);
memset(points,0,sizeof(points));
for(int i = 0; i < n; i++){
cin>>dots[i].second>>dots[i].first;
points[dots[i].first][dots[i].second]=true;
}
// ñ_ðIñÅA»Ìñ_ųû`ªìêé©Ç¤©
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
if(i==j)
continue;
// ñ_ÌìéxNg
P v(dots[i].second-dots[j].second,dots[i].first-dots[j].first);
// »Ì@üxNg
P nv(-v.imag(),v.real());
// @üxNgÌPÊxNg
if(EQ(abs(nv),0.0))
continue;
P nve(nv.real()/abs(nv),nv.imag()/abs(nv));
// ãLÌPÊxNgðabs(v){·é
P nveABSV(nve.real()*abs(v),nve.imag()*abs(v));
// ãÌxNgðgÁijû`ð\¬µ»¤È_ð©Â¯é
P p1[2];
P p2[2];
p1[0] = P(nveABSV.real()+dots[i].second,nveABSV.imag()+dots[i].first);
p1[1] = P(-nveABSV.real()+dots[i].second,-nveABSV.imag()+dots[i].first);
p2[0] = P(nveABSV.real()+dots[j].second,nveABSV.imag()+dots[j].first);
p2[1] = P(-nveABSV.real()+dots[j].second,-nveABSV.imag()+dots[j].first);
// _ÌyAðìé
pair<P,P> rec1,rec2;
if(EQ(abs(p1[0]-p2[0]),abs(v))){
rec1.first = p1[0];
rec1.second = p2[0];
rec2.first = p1[1];
rec2.second = p2[1];
}
else{
rec1.first = p1[0];
rec1.second = p2[1];
rec2.first = p1[1];
rec2.second = p2[0];
}
// ±±Åmèµ½_ª¶Ý·êÎAÊÏðvZ
if((int)(rec1.first.imag()+EPS)>=0&&(int)(rec1.first.imag()+EPS)<=5000
&&(int)(rec1.second.imag()+EPS)>=0&&(int)(rec1.second.imag()+EPS)<=5000
&&(int)(rec1.first.real()+EPS)>=0&&(int)(rec1.first.real()+EPS)<=5000
&&(int)(rec1.second.real()+EPS)>=0&&(int)(rec1.second.real()+EPS)<=5000){
if(points[(int)(rec1.first.imag()+EPS)][(int)(rec1.first.real()+EPS)]
&&points[(int)(rec1.second.imag()+EPS)][(int)(rec1.second.real()+EPS)]){
S = max(S,(int)(abs(v)*abs(v)));
}
}
if((int)(rec2.first.imag()+EPS)>=0&&(int)(rec2.first.imag()+EPS)<=5000
&&(int)(rec2.second.imag()+EPS)>=0&&(int)(rec2.second.imag()+EPS)<=5000
&&(int)(rec2.first.real()+EPS)>=0&&(int)(rec2.first.real()+EPS)<=5000
&&(int)(rec2.second.real()+EPS)>=0&&(int)(rec2.second.real()+EPS)<=5000){
if(points[(int)(rec2.first.imag()+EPS)][(int)(rec2.first.real()+EPS)]
&&points[(int)(rec2.second.imag()+EPS)][(int)(rec2.second.real()+EPS)]){
S = max(S,(int)(abs(v)*abs(v)));
}
}
}
}
cout<<S<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:41:17: error: 'memset' was not declared in this scope
41 | memset(points,0,sizeof(points));
| ^~~~~~
a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
14 | #include <cstdlib>
+++ |+#include <cstring>
15 | #include <sstream>
|
s734867211 | p00441 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<P> points;
bool checkSqr(P, P);
double distance(P, P);
int main()
{
ifstream ifs("data.txt");
int N;
while(ifs>>N && N){
points.clear();
for(int i = 0; i < N; i++){
P p;
ifs>>p.first>>p.second;
points.push_back(p);
}
sort(points.begin(), points.end());
int res = 0;
for(int i = 0; i < N; i++){
for(int j = i+1; j < N; j++){
P a = make_pair(points[i].first, points[i].second);
P b = make_pair(points[j].first, points[j].second);
if(checkSqr(a, b)){
res = max(res, (int)(pow(distance(a,b), 2.0) / 2));
}
}
}
cout<<res<<endl;
}
cin.sync(); cin.get();
}
template<class T> T abs(T a)
{
a < 0 ? -a : a;
}
double distance(P a, P b)
{
return sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0));
}
bool checkSqr(P a, P b)
{
P c, d;
c.first = a.first + abs(b.second - a.second);
c.second = a.second + abs(a.first - b.first);
d.first = b.first + abs(a.second - a.second);
d.second = b.second + abs(a.first - b.first);
if(count(points.begin(), points.end(), c) && count(points.begin(), points.end(), d)) return true;
else return true;
} | a.cc: In function 'int main()':
a.cc:40:62: error: 'pow' was not declared in this scope
40 | res = max(res, (int)(pow(distance(a,b), 2.0) / 2));
| ^~~
a.cc: In function 'double distance(P, P)':
a.cc:54:21: error: 'pow' was not declared in this scope
54 | return sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0));
| ^~~
a.cc:54:16: error: 'sqrt' was not declared in this scope
54 | return sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0));
| ^~~~
|
s239702098 | p00441 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<P> points;
bool checkSqr(P, P);
double dist(P, P);
int main()
{
int N;
while(cin>>N && N){
points.clear();
for(int i = 0; i < N; i++){
P p;
cin>>p.first>>p.second;
points.push_back(p);
}
sort(points.begin(), points.end());
int res = 0;
for(int i = 0; i < N; i++){
for(int j = i+1; j < N; j++){
P a = points[i];
P b = points[j];
if(checkSqr(a, b)) res = max(res, (int)(pow(dist(a,b), 2.0)));
}
}
cout<<res<<endl;
}
}
double dist(P a, P b)
{
return (double)(sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0)));
}
bool checkSqr(P a, P b)
{
P c, d;
c.first = a.first + abs(b.second - a.second);
c.second = a.second + abs(a.first - b.first);
d.first = b.first + abs(a.second - a.second);
d.second = b.second + abs(a.first - b.first);
if(count(points.begin(), points.end(), c) && count(points.begin(), points.end(), d)) return true;
else return false;
} | a.cc: In function 'int main()':
a.cc:38:78: error: 'pow' was not declared in this scope
38 | if(checkSqr(a, b)) res = max(res, (int)(pow(dist(a,b), 2.0)));
| ^~~
a.cc: In function 'double dist(P, P)':
a.cc:46:30: error: 'pow' was not declared in this scope
46 | return (double)(sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0)));
| ^~~
a.cc:46:25: error: 'sqrt' was not declared in this scope
46 | return (double)(sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0)));
| ^~~~
|
s293109955 | p00441 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<P> points;
bool checkSqr(P, P);
double dist(P, P);
int main()
{
int N;
while(cin>>N && N){
points.clear();
for(int i = 0; i < N; i++){
P p;
cin>>p.first>>p.second;
points.push_back(p);
}
sort(points.begin(), points.end());
int res = 0;
for(int i = 0; i < N; i++){
for(int j = i+1; j < N; j++){
P a = points[i];
P b = points[j];
if(checkSqr(a, b)) res = max(res, (int)(pow(dist(a,b), 2.0)));
}
}
cout<<res<<endl;
}
}
int abs(int a)
{
return a < 0 ? -a : a;
}
double dist(P a, P b)
{
return (double)(sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0)));
}
bool checkSqr(P a, P b)
{
P c, d;
c.first = a.first + abs(b.second - a.second);
c.second = a.second + abs(a.first - b.first);
d.first = b.first + abs(a.second - a.second);
d.second = b.second + abs(a.first - b.first);
if(count(points.begin(), points.end(), c) && count(points.begin(), points.end(), d)) return true;
else return false;
} | a.cc: In function 'int main()':
a.cc:38:78: error: 'pow' was not declared in this scope
38 | if(checkSqr(a, b)) res = max(res, (int)(pow(dist(a,b), 2.0)));
| ^~~
a.cc: In function 'double dist(P, P)':
a.cc:50:30: error: 'pow' was not declared in this scope
50 | return (double)(sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0)));
| ^~~
a.cc:50:25: error: 'sqrt' was not declared in this scope
50 | return (double)(sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0)));
| ^~~~
|
s045430899 | p00441 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<P> points;
bool checkSqr(P, P);
double dist(P, P);
int main()
{
int N;
while(cin>>N && N){
points.clear();
for(int i = 0; i < N; i++){
P p;
cin>>p.first>>p.second;
points.push_back(p);
}
sort(points.begin(), points.end());
int res = 0;
for(int i = 0; i < N; i++){
for(int j = i+1; j < N; j++){
P a = points[i];
P b = points[j];
if(checkSqr(a, b)) res = max(res, (int)(pow(dist(a,b), 2.0)));
}
}
cout<<res<<endl;
}
}
template<class T> T abs(T a)
{
return a < 0 ? -a : a;
}
double dist(P a, P b)
{
return (double)(sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0)));
}
bool checkSqr(P a, P b)
{
P c, d;
c.first = a.first + abs(b.second - a.second);
c.second = a.second + abs(a.first - b.first);
d.first = b.first + abs(a.second - a.second);
d.second = b.second + abs(a.first - b.first);
if(count(points.begin(), points.end(), c) && count(points.begin(), points.end(), d)) return true;
else return false;
} | a.cc: In function 'int main()':
a.cc:38:78: error: 'pow' was not declared in this scope
38 | if(checkSqr(a, b)) res = max(res, (int)(pow(dist(a,b), 2.0)));
| ^~~
a.cc: In function 'double dist(P, P)':
a.cc:50:30: error: 'pow' was not declared in this scope
50 | return (double)(sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0)));
| ^~~
a.cc:50:25: error: 'sqrt' was not declared in this scope
50 | return (double)(sqrt(pow(abs(a.first-b.first),2.0)+pow(abs(a.second-b.second),2.0)));
| ^~~~
|
s611212607 | p00441 | C++ | #include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#define max(a,b) (a>b?a:b)
using namespcae std;
vector< pair<int,int> > points;
int table[5001][5001];
int main(){
int a;
while(scanf("%d",&a),a){
memset(table,0,sizeof(table));
points.clear();
while(a--){
int j,k;
scanf("%d%d",&j,&k);
points.push_back(make_pair(j,k));
table[j][k]=1;
}
int res=0;
for(int i=0;i<points.size();i++){
for(int j=0;j<points.size();j++){
int x1=points[i][0],x2=points[j][0],y1=points[i][1],y2=points[j][1];
if(table[x1+y2-y1][y1+x1-x2]==1 && table[x2+y2-y1][y2-x2+x1]){
res=max(res,(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
}
}
printf("%d\n",res);
}
} | a.cc:6:7: error: expected nested-name-specifier before 'namespcae'
6 | using namespcae std;
| ^~~~~~~~~
a.cc:7:1: error: 'vector' does not name a type
7 | vector< pair<int,int> > points;
| ^~~~~~
a.cc: In function 'int main()':
a.cc:13:9: error: 'points' was not declared in this scope; did you mean 'printf'?
13 | points.clear();
| ^~~~~~
| printf
a.cc:17:26: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
17 | points.push_back(make_pair(j,k));
| ^~~~~~~~~
| std::make_pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/vector:62,
from a.cc:3:
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
1132 | make_pair(_T1&& __x, _T2&& __y)
| ^~~~~~~~~
a.cc:24:37: error: 'y2' was not declared in this scope
24 | if(table[x1+y2-y1][y1+x1-x2]==1 && table[x2+y2-y1][y2-x2+x1]){
| ^~
a.cc:24:40: error: 'y1' was not declared in this scope; did you mean 'x1'?
24 | if(table[x1+y2-y1][y1+x1-x2]==1 && table[x2+y2-y1][y2-x2+x1]){
| ^~
| x1
a.cc:24:50: error: 'x2' was not declared in this scope; did you mean 'x1'?
24 | if(table[x1+y2-y1][y1+x1-x2]==1 && table[x2+y2-y1][y2-x2+x1]){
| ^~
| x1
|
s680274214 | p00441 | C++ | #include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#define max(a,b) (a>b?a:b)
using namespace std;
vector< pair<int,int> > points;
int table[5001][5001];
int main(){
int a;
while(scanf("%d",&a),a){
memset(table,0,sizeof(table));
points.clear();
while(a--){
int j,k;
scanf("%d%d",&j,&k);
points.push_back(make_pair(j,k));
table[j][k]=1;
}
int res=0;
for(int i=0;i<points.size();i++){
for(int j=0;j<points.size();j++){
int x1=points[i][0],x2=points[j][0],y1=points[i][1],y2=points[j][1];
if(table[x1+y2-y1][y1+x1-x2]==1 && table[x2+y2-y1][y2-x2+x1]){
res=max(res,(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
}
}
printf("%d\n",res);
}
} | a.cc: In function 'int main()':
a.cc:23:41: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
23 | int x1=points[i][0],x2=points[j][0],y1=points[i][1],y2=points[j][1];
| ^
a.cc:24:37: error: 'y2' was not declared in this scope
24 | if(table[x1+y2-y1][y1+x1-x2]==1 && table[x2+y2-y1][y2-x2+x1]){
| ^~
a.cc:24:40: error: 'y1' was not declared in this scope; did you mean 'x1'?
24 | if(table[x1+y2-y1][y1+x1-x2]==1 && table[x2+y2-y1][y2-x2+x1]){
| ^~
| x1
a.cc:24:50: error: 'x2' was not declared in this scope; did you mean 'x1'?
24 | if(table[x1+y2-y1][y1+x1-x2]==1 && table[x2+y2-y1][y2-x2+x1]){
| ^~
| x1
|
s495547199 | p00441 | C++ | #include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#define max(a,b) (a>b?a:b)
using namespace std;
vector< pair<int,int> > points;
int table[5001][5001];
bool Check(int x,int y){
return (0<=x&&x<=5000&&0<=y&&y<=5000)?(bool)table[x][y]:false;
}
int main(){
int a;
while(scanf("%d",&a),a){
memset(table,0,sizeof(table));
points.clear();
while(a--){
int j,k;
scanf("%d%d",&j,&k);
points.push_back(make_pair(j,k));
table[j][k]=1
}
int res=0;
for(int i=0;(unsigned)i<points.size();i++){
for(int j=0;(unsigned)j<points.size();j++){
if(i==j)continue;
int x1=points[i].first,
x2=points[j].first,
y1=points[i].second,
y2=points[j].second;
int dx=x1-x2, dy=y1-y2;
if(
Check(x1+dy,y1-dx)&&Check(x2-dy,y2+dx)||
Check(x1-dy,y1+dx)&&Check(x2+dy,y2-dx)
){
res=max(res,dx*dx+dy*dy);
}
}
}
printf("%d\n",res);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:21:30: error: expected ';' before '}' token
21 | table[j][k]=1
| ^
| ;
22 | }
| ~
|
s869440463 | p00441 | C++ | #include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#define max(a,b) (a>b?a:b)
using namespace std;
vector< pair<int,int> > points;
vector<int> table[5001];
bool Check(int x,int y){
return (0<=x&&x<=5000&&0<=y&&y<=5000)?(bool)table[x][y]:false;
}
int main(){
int a;
while(scanf("%d",&a),a){
memset(table,0,sizeof(table));
points.clear();
for(int i=0; i<=5000; i++){
for(int j=0; j<=5000; j++)table[i].push_back();
}
while(a--){
int j,k;
scanf("%d%d",&j,&k);
points.push_back(make_pair(j,k));
table[j][k]=1;
}
int res=0;
for(int i=0;(unsigned)i<points.size();i++){
for(int j=0;(unsigned)j<points.size();j++){
if(i==j)continue;
int x1=points[i].first,
x2=points[j].first,
y1=points[i].second,
y2=points[j].second;
int dx=x1-x2, dy=y1-y2;
if(
Check(x1+dy,y1-dx)&&Check(x2-dy,y2+dx)||
Check(x1-dy,y1+dx)&&Check(x2+dy,y2-dx)
){
res=max(res,dx*dx+dy*dy);
}
}
}
printf("%d\n",res);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:18:61: error: no matching function for call to 'std::vector<int>::push_back()'
18 | for(int j=0; j<=5000; j++)table[i].push_back();
| ~~~~~~~~~~~~~~~~~~^~
In file included from /usr/include/c++/14/vector:66,
from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 0 provided
|
s631874846 | p00441 | C++ |
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class Main {
int INF = 1 << 28;
final int MAX = 5001;
boolean[][] map;
HashSet<P> ps;
void run() {
Scanner sc = new Scanner(System.in);
for(;;) {
int n = sc.nextInt();
if( n==0 ) break;
map = new boolean[MAX][MAX];
ps = new HashSet<P>();
for(int i=0;i<n;i++) {
P p = new P(sc.nextInt(), sc.nextInt());
ps.add(p);
map[p.y][p.x] = true;
}
int max = 0;
// for(P p: ps)
// debug(p.x, p.y);
for(P p: ps) {
for(P q: ps) {
max = max(max, isExist(p, q));
}
}
System.out.println(max);
}
}
int isExist(P p, P q) {
int dx = p.x-q.x;
int dy = p.y-q.y;
// debug(dx, dy);
if( isAllow(p,q, dx, dy) && (map[p.y+dx][p.x-dy] & map[q.y+dx][q.x-dy]) )return dx*dx+dy*dy;
if( isAllow(p,q,-dx,-dy) && (map[p.y-dx][p.x+dy] & map[q.y-dx][q.x+dy]) )return dx*dx+dy*dy;
return -1;
}
boolean isAllow(P p, P q, int dx, int dy) {
if( p.x-dy>=0 && p.x-dy<MAX && p.y+dx>=0 && p.y+dx<MAX &&
q.x-dy>=0 && q.x-dy<MAX && q.y+dx>=0 && q.y+dx<MAX )
return true;
return false;
}
class P {
int x, y;
P(int x, int y) {
this.x = x;
this.y = y;
}
}
public static void main(String[] args) {
new Main().run();
}
void debug(Object... os) {
System.err.println(Arrays.deepToString(os));
}
} | a.cc:2:1: error: 'import' does not name a type
2 | import java.util.*;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import static java.lang.Math.*;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import static java.util.Arrays.*;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
7 | public class Main {
| ^~~~~~
|
s004578311 | p00441 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
struct P{
int x,y;
P(int x_, int y_){
x = x_; y = y_;
}
P(){}
};
bool exist[5001][5001];
int x[3001], y[3001];
int main(){
int n;
while( cin >> n , n ){
for(int i=0 ; i < 5001 ; i++ ){
for(int j=0 ; j < 5001 ; j++ ){
exist[i][j] = false;
}
}
for(int i=0 ; i < n ; i++ ){
cin >> x[i] >> y[i];
exist[y][x] = true;
}
int ans = 0;
for(int i=0 ; i < n ; i++ ){
for(int j=i+1 ; j < n ; j++ ){
P p1 = P( x[i] , y[i] );
P p2 = P( x[j] , y[j] );
int dx = abs(p1.x - p2.x);
int dy = abs(p1.y - p2.y);
P p3( p2.x - dy , p2.y + dx );
P p4( p1.x - dy , p1.y + dx );
if( p3.x < 0 || p3.x > 5000 || p3.y < 0 || p3.y > 5000 ) continue;
if( p4.x < 0 || p4.x > 5000 || p4.y < 0 || p4.y > 5000 ) continue;
if( exist[p3.y][p3.x] && exist[p4.y][p4.x] ){
ans = max( ans , dx*dx + dy*dy );
}
p3 = P( p1.x + dy , p1.y - dx );
p4 = P( p2.x + dy , p2.y - dx );
if( p3.x < 0 || p3.x > 5000 || p3.y < 0 || p3.y > 5000 ) continue;
if( p4.x < 0 || p4.x > 5000 || p4.y < 0 || p4.y > 5000 ) continue;
if( exist[p3.y][p3.x] && exist[p4.y][p4.x] ){
ans = max( ans , dx*dx + dy*dy );
}
}
}
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:29:30: error: invalid types 'bool [5001][5001][int [3001]]' for array subscript
29 | exist[y][x] = true;
| ^
|
s359248207 | p00441 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
struct P{
int x,y;
P(int x_, int y_){
x = x_; y = y_;
}
P(){}
};
char exist[5001][5001];
int x[3001], y[3001];
int main(){
int n;
while( cin >> n , n ){
for(int i=0 ; i < 5001 ; i++ ){
for(int j=0 ; j < 5001 ; j++ ){
exist[i][j] = false;
}
}
for(int i=0 ; i < n ; i++ ){
cin >> x[i] >> y[i];
exist[y][x] = true;
}
int ans = 0;
for(int i=0 ; i < n ; i++ ){
for(int j=i+1 ; j < n ; j++ ){
P p1 = P( x[i] , y[i] );
P p2 = P( x[j] , y[j] );
int dx = abs(p1.x - p2.x);
int dy = abs(p1.y - p2.y);
P p3( p2.x - dy , p2.y + dx );
P p4( p1.x - dy , p1.y + dx );
if( p3.x < 0 || p3.x > 5000 || p3.y < 0 || p3.y > 5000 ) continue;
if( p4.x < 0 || p4.x > 5000 || p4.y < 0 || p4.y > 5000 ) continue;
if( exist[p3.y][p3.x] && exist[p4.y][p4.x] ){
ans = max( ans , dx*dx + dy*dy );
}
p3 = P( p1.x + dy , p1.y - dx );
p4 = P( p2.x + dy , p2.y - dx );
if( p3.x < 0 || p3.x > 5000 || p3.y < 0 || p3.y > 5000 ) continue;
if( p4.x < 0 || p4.x > 5000 || p4.y < 0 || p4.y > 5000 ) continue;
if( exist[p3.y][p3.x] && exist[p4.y][p4.x] ){
ans = max( ans , dx*dx + dy*dy );
}
}
}
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:29:30: error: invalid types 'char [5001][5001][int [3001]]' for array subscript
29 | exist[y][x] = true;
| ^
|
s003560366 | p00441 | C++ | #include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
using namespace std;
#define all(c) c.begin(),c.end()
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
typedef long long ll;
typedef vector<int> vi;
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& val){
os << "[ ";
for(typename vector<T>::const_iterator it=val.begin();
it != val.end();++it){
os << *it << " ";
}
os << "]";
return os;
}
const double EPS = 1e-6;
const int BOARD_SIZE = 5000;
typedef complex<double> point;
bool is_ok(const point& p){
double rr = round(p.real()),ri = round(p.imag());
bool on_line = abs(p.real()-rr) < EPS and abs(p.imag() - ri) < EPS;
bool on_board = 0 <= (int)rr and (int)rr <= BOARD_SIZE and 0 <= (int)ri and (int)ri <= BOARD_SIZE;
return on_line and on_board;
}
int main(){
while(true){
int n;
cin >> n;
if(n == 0) break;
vector<vector<char> > board(BOARD_SIZE+1,vector<char>(BOARD_SIZE+1,false));
vector<point> ps(n);
for(int i=0;i<n;i++){
int x,y;
cin >> x >> y;
board[y][x] = true;
ps[i].real(y);
ps[i].imag(x);
}
int ret = 0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
point a = ps[i];
point b = ps[j];
for(int k=-1;k<=1;k+=2){
point c = a + (b-a) * point(0,1*k);
point d = b + (a-b) * point(0,-1*k);
int cy = (int)round(c.imag());
int cx = (int)round(c.real());
int dy = (int)round(d.imag());
int dx = (int)round(d.real());
if(is_ok(c) and is_ok(d) and board[cy][cx] and board[dy][dx])
ret = max(ret,(int)(round(abs(a-b)*abs(a-b))));
}
}
}
}
cout << ret << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:87:17: error: 'ret' was not declared in this scope; did you mean 'rep'?
87 | cout << ret << endl;
| ^~~
| rep
a.cc: At global scope:
a.cc:89:5: error: expected unqualified-id before 'return'
89 | return 0;
| ^~~~~~
a.cc:90:1: error: expected declaration before '}' token
90 | }
| ^
|
s865284520 | p00441 | C++ | #include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
bool mem[5001][5001];
const int H = 5000, W = 5000;
vector<pair<int, int>> points;
bool check(int x, int y, int dx, int dy)
{
return x + dx <= W && x + dx >= 0 && y + dy <= H && y + dy >=0 && mem[x + dx][y + dy] &&
x - dy <= W && x - dy >= 0 && y + dx <= H && y + dx >= 0 && mem[x - dy][y + dx] &&
x + dx - dy <= W && x + dx - dy >= 0 && y + dy - dx <= H && y + dy + dx >= 0 && mem[x + dx - dy][y + dy + dx];
}
int main()
{
loop:
int n, ans = 0;
cin >> n;
if(!n)
return 0;
for(int i = 0; i < n; i++)
{
int x, y;
cin >> x >> y;
points.push_back(make_pair(x, y));
mem[x][y] = true;
}
for(auto st : points)
{
for(auto ed: points)
{
if(st == ed)
continue;
auto sx = st.first, sy = st.second,
ex = ed.first, ey = ed.second;
auto dx = ex - sx, dy = ey - sy;
if(check(sx, sy, dx, dy))
ans = max(ans, (int)(pow(dx, 2) + pow(dy, 2)));
}
}
cout << ans << endl;
goto loop;
} | a.cc: In function 'int main()':
a.cc:43:30: error: 'pow' was not declared in this scope
43 | ans = max(ans, (int)(pow(dx, 2) + pow(dy, 2)));
| ^~~
|
s931548963 | p00441 | C++ | #include<iostream>
using namespace std;
bool a[3002][3002];
bool f(int x,int y){
if(x<0||x>=3002||y<0||y>=3002)return false;
return a[x][y];
}
int main(){
while(1){
for(int i=0;i<3002;i++)for(int j=0;j<3002;j++)a[i][j]=false;
int n,x[3002],y[3002];
scanf("%d",&n); if(n==0)braek;
for(int i=0;i<n;i++){ scanf("%d%d",&x[i],&y[i]); a[x[i]][y[i]]=true; }
int ret=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
int sx=y[i]-y[j],sy=x[j]-x[i];
if(f(x[i]+sx,y[i]+sy)&&f(x[j]+sx,y[j]+sy))ret=max(ret,sx*sx+sy*sy);
else if(f(x[i]-sx,y[i]-sy)&&f(x[j]-sx,y[j]-sy))ret=max(ret,sx*sx+sy*sy);
}
}
printf("%d\n",ret);
}
} | a.cc: In function 'int main()':
a.cc:15:33: error: 'braek' was not declared in this scope
15 | scanf("%d",&n); if(n==0)braek;
| ^~~~~
|
s677538103 | p00442 | C++ | #include <stdio.h>
#include <algorithm>
#include <stack>
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,b) FOR(i,0,b)
using namespace std;
int data[5000];
stack<int> wn[5000];
int main(){
int n;
int m;
scanf_s("%d%d", &n, &m);
fill(data, data + 5000, 0);
int a, b;
REP(i, m){
scanf_s("%d%d", &a, &b);
++(data[--b]);
wn[--a].push(b);
}
int t = -1;
bool ex = false;
REP(i, n){
REP(j, n){
if (data[j] == 0){
if (t != -1)
ex = true;
t = j;
}
}
printf("%d\n", t+1);
while (!wn[t].empty()){
--(data[wn[t].top()]);
wn[t].pop();
}
data[t] = INT_MAX;
t = -1;
}
if (ex)
printf("1\n");
else
printf("0\n");
} | a.cc: In function 'int main()':
a.cc:17:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
17 | scanf_s("%d%d", &n, &m);
| ^~~~~~~
| scanf
a.cc:18:14: error: reference to 'data' is ambiguous
18 | fill(data, data + 5000, 0);
| ^~~~
In file included from /usr/include/c++/14/deque:68,
from /usr/include/c++/14/stack:62,
from a.cc:3:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:18:20: error: reference to 'data' is ambiguous
18 | fill(data, data + 5000, 0);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:22:20: error: reference to 'data' is ambiguous
22 | ++(data[--b]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:29:29: error: reference to 'data' is ambiguous
29 | if (data[j] == 0){
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:37:28: error: reference to 'data' is ambiguous
37 | --(data[wn[t].top()]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:40:17: error: reference to 'data' is ambiguous
40 | data[t] = INT_MAX;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:40:27: error: 'INT_MAX' was not declared in this scope
40 | data[t] = INT_MAX;
| ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <stack>
+++ |+#include <climits>
4 |
|
s777971854 | p00442 | C++ | #include <stdio.h>
#include <algorithm>
#include <stack>
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,b) FOR(i,0,b)
using namespace std;
int data[5000];
stack<int> wn[5000];
int main(){
int n;
int m;
scanf_s("%d%d", &n, &m);
fill(data, data + 5000, 0);
int a, b;
REP(i, m){
scanf_s("%d%d", &a, &b);
++(data[--b]);
wn[--a].push(b);
}
int t = -1;
bool ex = false;
REP(i, n){
REP(j, n){
if (data[j] == 0){
if (t != -1)
ex = true;
t = j;
}
}
printf("%d\n", t+1);
while (!wn[t].empty()){
--(data[wn[t].top()]);
wn[t].pop();
}
data[t] = INT_MAX;
t = -1;
}
if (ex)
printf("1\n");
else
printf("0\n");
} | a.cc: In function 'int main()':
a.cc:17:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
17 | scanf_s("%d%d", &n, &m);
| ^~~~~~~
| scanf
a.cc:18:14: error: reference to 'data' is ambiguous
18 | fill(data, data + 5000, 0);
| ^~~~
In file included from /usr/include/c++/14/deque:68,
from /usr/include/c++/14/stack:62,
from a.cc:3:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:18:20: error: reference to 'data' is ambiguous
18 | fill(data, data + 5000, 0);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:22:20: error: reference to 'data' is ambiguous
22 | ++(data[--b]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:29:29: error: reference to 'data' is ambiguous
29 | if (data[j] == 0){
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:37:28: error: reference to 'data' is ambiguous
37 | --(data[wn[t].top()]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:40:17: error: reference to 'data' is ambiguous
40 | data[t] = INT_MAX;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:5: note: 'int data [5000]'
11 | int data[5000];
| ^~~~
a.cc:40:27: error: 'INT_MAX' was not declared in this scope
40 | data[t] = INT_MAX;
| ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <stack>
+++ |+#include <climits>
4 |
|
s832516337 | p00442 | C++ | #include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int V, E, A, B;
vector<vector<int> > G;
vector<int> T;
vector<bool> used;
void rec(int u)
{
used[u] = true;
for (int i = 0; i < G[u].size(); i++)
{
int v = G[u][i];
if (!used[v]) { rec(v); }
}
T.push_back(u);
}
int main()
{
scanf("%d", &V);
scanf("%d", &E);
G = vector<vector<int> >(V);
for (int i = 0; i < E; i++)
{
scanf("%d", &A);
scanf("%d", &B);
G[A - 1].push_back(B - 1);
}
used = vector<bool>(V, false);
for (int i = 0; i < V; i++)
{
if (!used[i])
{
rec(i);
}
}
reverse(T.begin(), T.end());
for (int i = 0; i < T.size(); i++)
{
printf("%d\n", T[i] + 1);
}
bool ok = true;
for (int i = 1; i < V; i++)
{
if (!binary_search(G[T[i - 1]].begin(), G[T[i - 1]].end(), G[T[i]]))
{
ok = false;
}
}
return 0;
} | In file included from /usr/include/c++/14/algorithm:61,
from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of 'bool std::binary_search(_FIter, _FIter, const _Tp&) [with _FIter = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Tp = vector<int>]':
a.cc:65:21: required from here
65 | if (!binary_search(G[T[i - 1]].begin(), G[T[i - 1]].end(), G[T[i]]))
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2207:39: error: no match for 'operator<' (operand types are 'const std::vector<int>' and 'int')
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/vector:62,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: 'const std::vector<int>' is not derived from 'const std::pair<_T1, _T2>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: 'const std::vector<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: 'const std::vector<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: 'const std::vector<int>' is not derived from 'const std::move_iterator<_IteratorL>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: 'const std::vector<int>' is not derived from 'const std::move_iterator<_IteratorL>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:2089:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)'
2089 | operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:2089:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: mismatched types 'const std::vector<_Tp, _Alloc>' and 'int'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/vector:87:
/usr/include/c++/14/tuple:2600:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2600 | operator<(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2600:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: 'const std::vector<int>' is not derived from 'const std::tuple<_UTypes ...>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: 'std::vector<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: 'std::vector<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: 'const std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: 'const std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3901 | operator<(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:2207:39: note: mismatched types 'const _CharT*' and 'std::vector<int>'
2207 | return __i != __last && !(__val < *__i);
| ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/ios_base.h:46:
/usr/include/c++/14/system_error:324:3: note: candidate: 'bool std::operator<(const error_code&, const error_code&)'
324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept
| ^~~~~~~~
/usr/include/c++/14/system_error:324:31: note: no known conversion for argument 1 from 'const std::vector<int>' to 'cons |
s728260432 | p00442 | C++ | //???????????????????????¨??????????????????A????????????B????????£?????¨??????A -> B??¨?????????????????????
//????????¨???????????°???????????§???????????°???????????§s??????t????????????????????¨????????¨??????
//????????????????????????s -> s1 -> s2 -> ??? -> t??¨???????????¨?????§?????????????????¨???????????????s < s1 < s2 < ??? < t??¨?????????
//s-t??????????????????L?????£?????¨??????t????????? >= s????????? + L??§???????????¨????¢??????????????????????s??????t?????????????????????ML??¨????????°???
//t????????? >= s????????? + ML?????¨???????????????????????\????????????????????????1?????\?????§?????????????????????1????????????????§?????????????
//?????????t???????????????t????????? = s????????? + ML??¨?????????????????????
//?????±????¨????????????????????????´????????????????????±????±????????????¨?????§??????????????±????±?????????°????????????????????????
//??¨?????????????????±2????????????????????????????????????????????§???1????????????1???k????????´?????????????????????????\?????????????
//??????????????????1?????????????????????{1, 2, 4}?????£?????¨???????????????3?????????????????????????????£???????????????????????????
//
//????????¨????????°?????¨???????????????????????????????????????????????°???????????°?????\??????????????????????????°??§????????????
//????????????????????¨????????¨??????????????????????????????????????°???????????????DAG????????????DAG?????§??????????????????????§£??????????°????????????§?????????????????????
//???????????????????????????????????°?????????????????????????????§????????¢???????????????????????????????????????????????¨????????????
//??¶?????????????????????, 1?????????????????¢)??§?????????????????????????????§??????????????§???BFS??§??????
//????£?????????????????????????0???n-1????????????????????????
//
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef pair<int, int> P;
bool table[5000][5000] = {false};
int dp[5000]; //dp[i] = ?????????i(>=0)?????????
int n, m;
queue<P> que;
void bfs(){
while( !que.empty() ){
int dist = que.front().first;
int team = que.front().second;
que.pop();
if( dp[team] >= dist )
continue;
dp[team] = dist;
for( int i = 0; i < n; i++ ){
if( table[team][i] )
que.push(P(dist + 1, i));
}
}
}
int main()
{
int i, j;
cin >> n >> m;
for( i = 0; i < m; i++ ){
int s, t;
cin >> s >> t;
table[s-1][t-1] = true;
}
for( i = 0; i < n; i++ ){
for( j = 0; j < n; j++ )
if( table[j][i] ) break;
if( j == n ){ //i?????\???????????????
que.push(P(1, i)); //?§?????????????(dp[i]???????????????0????????§??£?????°????????????????????????)
}
}
bfs(); //???????????¢?´¢??§dp??¨????????????
static P perm[5000]; //perm[i] = (??????dp[i], ???????????????i)
for( i = 0; i < n; i++ )
perm[i] = P(dp[i], i);
sort(perm, perm + n); //????????§?????????
bool flag = false;
for( i = 0; i < n; i++ ){
cout << perm[i].second + 1 << endl;
if( i + 1 < n && perm[i].first == perm[i+1].first ){
flag = true;
}
}
if( flag ) cout << 1 << endl;
else cout << 0 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:69:9: error: 'sort' was not declared in this scope; did you mean 'short'?
69 | sort(perm, perm + n); //????????§?????????
| ^~~~
| short
|
s955551866 | p00442 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <time.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#define FOR(i, a) for(i = 0; i < (a); i++)
#define FORM(i, a) for(i = (a) i >= 0; i--)
using namespace std;
vector<int> E[5050];
int indeg[5050];
queue<int> q;
void bfs(int s){
int i, j;
FOR(i, E[s].size()){
indeg[E[s][i]]--;
if(indeg[E[s][i]] == 0){
q.push(E[s][i]);
}
}
}
void ranking(int N){
int i, j, k, l, flag = 0;
FOR(i, N){
if(indeg[i+1] == 0){
q.push(i+1);
indeg[i+1]--;
}
}
if(q.size() > 1)
flag = 1;
while(q.size() != 0){
cout << q.front() << endl;
bfs(q.front());
q.pop();
if(q.size() > 1){
flag = 1;
}
}
cout << flag << endl;
}
int main(){
int i, j, N, K, m, n;
cin >> n >> m;
FOR(K, m){
cin >> i >> j;
E[i].push_back(j);
indeg[j]++;
}
ranking(n);
return 0;
}
/*
7 4 | a.cc:77:1: error: unterminated comment
77 | /*
| ^
|
s174168130 | p00442 | C++ |
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
#define REP(i,x) for(int i = 0;i < x;++i)
int n, m;
vector<int>graph[5678];
vector<int>ans;
int dev[5678];//in
int main()
{
scanf("%d", &n);
scanf("%d", &m);
REP(i, m)
{
int win,lose;
scanf("%d %d", &win, &lose);
--win; --lose;
graph[win].push_back(lose);
dev[lose]++;
}
queue<int>que;
REP(i, n)
{
if (!dev[i])
{
que.push(i);
ans.push_back(i);
}
}
while (!que.empty())
{
int q = que.front(); que.pop();
for (auto to : graph[q])
{
--dev[to];
if (!dev[to])
{
que.push(to);
ans.push_back(to);
}
}
}
bool flag = true;
REP(i, n - 1)
{
if (find(graph[i].begin(), graph[i].end(), i + 1) == graph[i].end())
{
flag = false;
}
}
for (int v : ans)
{
printf("%d\n", v + 1);
}
printf("%d\n", flag ? 0 : 1);
return 0;
} | a.cc: In function 'int main()':
a.cc:53:21: error: 'find' was not declared in this scope
53 | if (find(graph[i].begin(), graph[i].end(), i + 1) == graph[i].end())
| ^~~~
|
s091117695 | p00442 | C++ | #include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
ll n,m;
P a[100000];
vector<ll> G[5000];
ll into[5000];
ll rank[5000];
bool zero[5000];
queue<ll> q;
ll x=0;
ll now=0;
int main()
{
scanf("%lld%lld",&n,&m);
rep(i,m){
scanf("%lld%lld",&a[i].fr,&a[i].sc);
G[--a[i].fr].pb(--a[i].sc);
into[a[i].sc]++;
}
rep(i,n){
if(!into[i]){
q.push(i);
zero[i]=1;
}
}
while(!q.empty()){
if(q.size()>1) x=1;
ll team=q.front();
rank[now]=team;
now++;
q.pop();
rep(i,G[team].size()){
if(into[G[team][i]]==0) continue;
into[G[team][i]]--;
if(into[G[team][i]]==0){
q.push(G[team][i]);
}
}
}
rep(i,n) cout<<rank[i]+1<<endl;
cout<<x<<endl;
} | a.cc: In function 'int main()':
a.cc:50:17: error: reference to 'rank' is ambiguous
50 | rank[now]=team;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/vector:62,
from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:28:4: note: 'll rank [5000]'
28 | ll rank[5000];
| ^~~~
a.cc:61:24: error: reference to 'rank' is ambiguous
61 | rep(i,n) cout<<rank[i]+1<<endl;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:28:4: note: 'll rank [5000]'
28 | ll rank[5000];
| ^~~~
|
s009273102 | p00442 | C++ | #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF_LL 1e18
#define INF 1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
using namespace std;
using ll = long long;
using PII = pair<int, int>;
int table[5005][5005] = {};
int stand[5005];
PII wl[5005] = {};
int win[5005] = {};
bool comp(int x, int y){
if(table[x][y]) return true;
if(table[y][x]) return false;
return win[x] > win[y];
}
int main(void){
int n, m;
cin >> n >> m;
REP(i, n){
wl[i].first = 0; wl[i].second = 0;
stand[i] = i;
REP(j, m){
table[i][j] = -1;
}
}
REP(i, m){
int a, b;
cin >> a >> b;
a--;b--;
table[a][b] = 1;
table[b][a] = 0;
wl[a].first++;
wl[b].second++;
uf.unite(a, b);
}
int f = 0;
REP(i, n){
REP(j, n){
if(i == j) continue;
if(table[i][j])
win[i] += wl[j].first;
}
}
sort(stand, stand+n, comp);
REP(i, n){
cout << stand[i]+1 << endl;
}
REP(i, n-1){
if(table[stand[i]][stand[i+1]] == -1)
f++;
}
if(f)
cout << 1 << endl;
else
cout << 0 << endl;
} | a.cc: In function 'int main()':
a.cc:61:17: error: 'uf' was not declared in this scope
61 | uf.unite(a, b);
| ^~
|
s183138669 | p00442 | C++ |
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#define in std::cin
#define out std::cout
int32_t N;
int32_t M;
int32_t win[100000] = {};
int32_t undefined[100000];
int32_t win_max_index[100000];//??????
int32_t win_min_index[100000];//??????
int32_t indegrees[100000] = {};
std::vector<int32_t> graph[100000];
int32_t tp_sorted_index[100000] = {};
template<typename T>
void show_all(T b, T e) {
#ifdef _DEBUG
out << "-------------------\n";
while (b != e) {
out << *(b++) << ' ';
}
out << "\n-------------------\n";
#endif
}
int main()
{
using std::endl;
in.sync_with_stdio(false);
out.sync_with_stdio(false);
in >> N >> M;
std::for_each(undefined, undefined + N, [](auto& i) {i = N - 1; });
for (int32_t i = 0; i < M; ++i)
{
int32_t w, l;
in >> w >> l; --w; --l;
++win[w]; --undefined[w]; --undefined[l];
graph[w].push_back(l); ++indegrees[l];
}
#ifdef _DEBUG
out << "-------------------\n";
for (int32_t i = 0; i < N; ++i)
{
for (auto& e : graph[i]) {
out << e<< ' ';
}
out << '(' << indegrees[i] << ')';
out << win[i] << ' ' << undefined[i];
out << endl;
}
out << "-------------------\n";
#endif
show_all(indegrees, indegrees + N);
//?????§/????°?????????°
auto max_win_comp = [](int32_t i, int32_t j){return (win[i] + undefined[i]) > (win[j] + undefined[j]); };
std::iota(win_max_index, win_max_index + N, 0i32);
std::sort(win_max_index, win_max_index + N, max_win_comp);
show_all(win_max_index, win_max_index + N);
auto min_win_comp = [](int32_t i, int32_t j) {return win[i] > win[j]; };
std::iota(win_min_index, win_min_index + N, 0i32);
std::sort(win_min_index, win_min_index + N, min_win_comp);
show_all(win_min_index, win_min_index + N);
//?¢???????????????????????????£?????????
for (auto iter = win_min_index, iter_ALL_end = win_min_index + N; iter != iter_ALL_end;)
{
auto iter_end = std::upper_bound(iter + 1, iter_ALL_end, *iter, min_win_comp);
auto win_max_iter_b = std::upper_bound(win_max_index, win_max_index + N, *iter,
[](int32_t value, int32_t index) {return value > (win[index] + undefined[index]); });
auto winmin_max = win[*win_max_iter_b];
show_all(iter, iter_end);
#ifdef _DEBUG
out << "-------------------\n";
#endif
for (;iter != iter_end; ++iter)
{
for (auto win_max_iter = win_max_iter_b;
(win_max_iter != win_max_index + N)&& winmin_max <= win[*win_max_iter] + undefined[*win_max_iter];++win_max_iter)
{
#ifdef _DEBUG
out << *win_max_iter << ' ';
#endif
winmin_max = std::max(winmin_max, win[*win_max_iter]);
graph[*iter].push_back(*win_max_iter); ++indegrees[*win_max_iter];
}
}
#ifdef _DEBUG
out << "\n-------------------\n";
#endif
}
show_all(indegrees, indegrees + N);
//???????????????????????????
bool is_double = false;
{
int32_t count = 0;
std::queue<int32_t> que;
for (int32_t i = 0; i < N; ++i)
{
if (indegrees[i] <= 0) { que.push(i); }
}
#ifdef _DEBUG
out << endl << "quesize" << que.size() << endl;
#endif
while (!que.empty())
{
if (que.size() >= 2) { is_double = true; }
auto v = que.front(); que.pop();
#ifdef _DEBUG
out << "v:" << v << endl;
#endif
tp_sorted_index[v] = count++;
for (auto& e : graph[v]) {
if ((--indegrees[e]) <= 0) { que.push(e); }
#ifdef _DEBUG
out <<e << " " << indegrees[e]<<endl;
#endif
}
#ifdef _DEBUG
out << "quesize" << que.size() << endl;
#endif
}
}
#ifdef _DEBUG
out << "-------------------\n";
#endif
for (int32_t i = 0; i < N; ++i)
{
out << tp_sorted_index[i]+1<<endl;
}
out << (is_double ? 1 : 0) << endl;
return 0;
}
#endif | a.cc: In function 'int main()':
a.cc:80:53: error: unable to find numeric literal operator 'operator""i32'
80 | std::iota(win_max_index, win_max_index + N, 0i32);
| ^~~~
a.cc:84:53: error: unable to find numeric literal operator 'operator""i32'
84 | std::iota(win_min_index, win_min_index + N, 0i32);
| ^~~~
|
s648691418 | p00442 | C++ |
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#define in std::cin
#define out std::cout
int32_t N;
int32_t M;
int32_t win[100000] = {};
int32_t undefined[100000];
int32_t win_max_index[100000];//??????
int32_t win_min_index[100000];//??????
int32_t indegrees[100000] = {};
std::vector<int32_t> graph[100000];
int32_t tp_sorted_index[100000] = {};
template<typename T>
void show_all(T b, T e) {
#ifdef _DEBUG
out << "-------------------\n";
while (b != e) {
out << *(b++) << ' ';
}
out << "\n-------------------\n";
#endif
}
int main()
{
using std::endl;
in.sync_with_stdio(false);
out.sync_with_stdio(false);
in >> N >> M;
std::for_each(undefined, undefined + N, [](int32_t& i) {i = N - 1; });
for (int32_t i = 0; i < M; ++i)
{
int32_t w, l;
in >> w >> l; --w; --l;
++win[w]; --undefined[w]; --undefined[l];
graph[w].push_back(l); ++indegrees[l];
}
#ifdef _DEBUG
out << "-------------------\n";
for (int32_t i = 0; i < N; ++i)
{
for (auto& e : graph[i]) {
out << e<< ' ';
}
out << '(' << indegrees[i] << ')';
out << win[i] << ' ' << undefined[i];
out << endl;
}
out << "-------------------\n";
#endif
show_all(indegrees, indegrees + N);
//?????§/????°?????????°
auto max_win_comp = [](int32_t i, int32_t j){return (win[i] + undefined[i]) > (win[j] + undefined[j]); };
std::iota(win_max_index, win_max_index + N, 0i32);
std::sort(win_max_index, win_max_index + N, max_win_comp);
show_all(win_max_index, win_max_index + N);
auto min_win_comp = [](int32_t i, int32_t j) {return win[i] > win[j]; };
std::iota(win_min_index, win_min_index + N, 0i32);
std::sort(win_min_index, win_min_index + N, min_win_comp);
show_all(win_min_index, win_min_index + N);
//?¢???????????????????????????£?????????
for (auto iter = win_min_index, iter_ALL_end = win_min_index + N; iter != iter_ALL_end;)
{
auto iter_end = std::upper_bound(iter + 1, iter_ALL_end, *iter, min_win_comp);
auto win_max_iter_b = std::upper_bound(win_max_index, win_max_index + N, *iter,
[](int32_t value, int32_t index) {return value > (win[index] + undefined[index]); });
auto winmin_max = win[*win_max_iter_b];
show_all(iter, iter_end);
#ifdef _DEBUG
out << "-------------------\n";
#endif
for (;iter != iter_end; ++iter)
{
for (auto win_max_iter = win_max_iter_b;
(win_max_iter != win_max_index + N)&& winmin_max <= win[*win_max_iter] + undefined[*win_max_iter];++win_max_iter)
{
#ifdef _DEBUG
out << *win_max_iter << ' ';
#endif
winmin_max = std::max(winmin_max, win[*win_max_iter]);
graph[*iter].push_back(*win_max_iter); ++indegrees[*win_max_iter];
}
}
#ifdef _DEBUG
out << "\n-------------------\n";
#endif
}
show_all(indegrees, indegrees + N);
//???????????????????????????
bool is_double = false;
{
int32_t count = 0;
std::queue<int32_t> que;
for (int32_t i = 0; i < N; ++i)
{
if (indegrees[i] <= 0) { que.push(i); }
}
#ifdef _DEBUG
out << endl << "quesize" << que.size() << endl;
#endif
while (!que.empty())
{
if (que.size() >= 2) { is_double = true; }
auto v = que.front(); que.pop();
#ifdef _DEBUG
out << "v:" << v << endl;
#endif
tp_sorted_index[v] = count++;
for (auto& e : graph[v]) {
if ((--indegrees[e]) <= 0) { que.push(e); }
#ifdef _DEBUG
out <<e << " " << indegrees[e]<<endl;
#endif
}
#ifdef _DEBUG
out << "quesize" << que.size() << endl;
#endif
}
}
#ifdef _DEBUG
out << "-------------------\n";
#endif
for (int32_t i = 0; i < N; ++i)
{
out << tp_sorted_index[i]+1<<endl;
}
out << (is_double ? 1 : 0) << endl;
return 0;
}
#endif | a.cc: In function 'int main()':
a.cc:80:53: error: unable to find numeric literal operator 'operator""i32'
80 | std::iota(win_max_index, win_max_index + N, 0i32);
| ^~~~
a.cc:84:53: error: unable to find numeric literal operator 'operator""i32'
84 | std::iota(win_min_index, win_min_index + N, 0i32);
| ^~~~
|
s239937115 | p00442 | C++ | #include <iostream>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <string>
#include <cmath>
using namespace std;
#define F first
#define S second
const int INF=100000000;
struct Node{
vector<int> to,from;
};
bool e[5000][5000];
int main(){
int n,m;
cin >> n >> m;
memset(e,0,sizeof(e));
//vector<vector<int> > e(n,vector<int>(n));
vector<Node> node(n);
for(int i=0; i<m; ++i){
int a,b;
cin >> a >> b;
e[--a][--b]=1;
node[a].to.push_back(b);
node[b].from.push_back(a);
}
queue<int> S;
vector<int> L;
for(int i=0; i<n; ++i){
//cout << node[i].from.size() << endl;
if(node[i].from.size()==0) S.push(i);
}
/*
for(int i=0; i<S.size(); ++i){
cout << S[i] << endl;
}
*/
bool other=false;
while(!S.empty()){
if(S.size()>1) other=true;
L.push_back(S.front());
int ls=S.front();
S.pop();
for(int i=0; i<node[ls].to.size(); ++i){
int nn=node[ls].to[i];
e[ls][nn]=0;
bool flag=true;
for(int j=0; j<node[nn].from.size(); ++j){
if(e[node[nn].from[j]][nn]==1){
flag=false;
break;
}
}
if(flag) S.push(nn);
//if(node[node[ls].to[i]].from.size()==0) S.push_back(node[ls].to[i]);
}
}
for(int i=0; i<L.size(); ++i){
cout << L[i]+1 << endl;
}
if(other) cout << 1 << endl;
else cout << 0 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:23:9: error: 'memset' was not declared in this scope
23 | memset(e,0,sizeof(e));
| ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
8 | #include <cmath>
+++ |+#include <cstring>
9 | using namespace std;
|
s329661226 | p00443 | Java | import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
public class Main{
static PrintWriter out;
static InputReader ir;
static int[] p=new int[101],q=new int[101],r=new int[101],b=new int[101],par=new int[101];
static void solve(){
int n;
while((n=ir.nextInt())!=0){
for(int i=0;i<n;i++){
p[i]=ir.nextInt();
q[i]=ir.nextInt();
r[i]=ir.nextInt();
b[i]=ir.nextInt();
par[r[i]]=par[b[i]]=i+1;
long g=gcd(p[i],q[i]);
p[i]/=(int)g;
q[i]/=(int)g;
}
int now=1;
while(par[now]!=0) now=par[now];
out.println(dfs(now));
Arrays.fill(par,0);
}
}
public static int dfs(int m){
int now=m-1;
if(r[now]==0&&b[now]==0) return (long)p[now]+q[now];
if(r[now]==0){
long bb=dfs(b[now]);
return bb/gcd(q[now],bb)*(p[now]+q[now]);
}
if(b[now]==0){
long rr=dfs(r[now]);
return rr/gcd(p[now],rr)*(p[now]+q[now]);
}
long bb=dfs(b[now]),rr=dfs(r[now]);
int g=gcd(bb*p[now],rr*q[now]);
return rr*q[now]/g*bb+bb*p[now]/g*rr;
}
public static long gcd(long a,long b){
if(b==0) return a;
return gcd(b,a%b);
}
public static void main(String[] args) throws Exception{
ir=new InputReader(System.in);
out=new PrintWriter(System.out);
solve();
out.flush();
}
static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;
public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
public boolean hasNextByte() {
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}catch(IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0) return false;
}
return true;
}
private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
public boolean hasNext(){skip(); return hasNextByte();}
public String next(){
if(!hasNext()) throw new NoSuchElementException();
StringBuilder sb=new StringBuilder();
int b=readByte();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
public int nextInt() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public long nextLong() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public double nextDouble(){return Double.parseDouble(next());}
public int[] nextIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
public long[] nextLongArray(int n){
long[] a=new long[n];
for(int i=0;i<n;i++) a[i]=nextLong();
return a;
}
public char[][] nextCharMap(int n,int m){
char[][] map=new char[n][m];
for(int i=0;i<n;i++) map[i]=next().toCharArray();
return map;
}
}
} | Main.java:39: error: incompatible types: possible lossy conversion from long to int
if(r[now]==0&&b[now]==0) return (long)p[now]+q[now];
^
Main.java:42: error: incompatible types: possible lossy conversion from long to int
return bb/gcd(q[now],bb)*(p[now]+q[now]);
^
Main.java:46: error: incompatible types: possible lossy conversion from long to int
return rr/gcd(p[now],rr)*(p[now]+q[now]);
^
Main.java:49: error: incompatible types: possible lossy conversion from long to int
int g=gcd(bb*p[now],rr*q[now]);
^
Main.java:50: error: incompatible types: possible lossy conversion from long to int
return rr*q[now]/g*bb+bb*p[now]/g*rr;
^
5 errors
|
s743002620 | p00443 | Java | import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
public class Main{
static PrintWriter out;
static InputReader ir;
static int[] p=new int[101],q=new int[101],r=new int[101],b=new int[101],par=new int[101];
static void solve(){
int n;
while((n=ir.nextInt())!=0){
for(int i=0;i<n;i++){
p[i]=ir.nextInt();
q[i]=ir.nextInt();
r[i]=ir.nextInt();
b[i]=ir.nextInt();
par[r[i]]=par[b[i]]=i+1;
long g=gcd(p[i],q[i]);
p[i]/=(int)g;
q[i]/=(int)g;
}
int now=1;
while(par[now]!=0) now=par[now];
out.println(dfs(now));
Arrays.fill(par,0);
}
}
public static int dfs(int m){
int now=m-1;
if(r[now]==0&&b[now]==0) return (long)p[now]+(long)q[now];
if(r[now]==0){
long bb=dfs(b[now]);
return bb/gcd(q[now],bb)*(p[now]+q[now]);
}
if(b[now]==0){
long rr=dfs(r[now]);
return rr/gcd(p[now],rr)*(p[now]+q[now]);
}
long bb=dfs(b[now]),rr=dfs(r[now]);
int g=gcd(bb*p[now],rr*q[now]);
return rr*(long)q[now]/g*bb+bb*(long)p[now]/g*rr;
}
public static long gcd(long a,long b){
if(b==0) return a;
return gcd(b,a%b);
}
public static void main(String[] args) throws Exception{
ir=new InputReader(System.in);
out=new PrintWriter(System.out);
solve();
out.flush();
}
static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;
public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
public boolean hasNextByte() {
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}catch(IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0) return false;
}
return true;
}
private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
public boolean hasNext(){skip(); return hasNextByte();}
public String next(){
if(!hasNext()) throw new NoSuchElementException();
StringBuilder sb=new StringBuilder();
int b=readByte();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
public int nextInt() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public long nextLong() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public double nextDouble(){return Double.parseDouble(next());}
public int[] nextIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
public long[] nextLongArray(int n){
long[] a=new long[n];
for(int i=0;i<n;i++) a[i]=nextLong();
return a;
}
public char[][] nextCharMap(int n,int m){
char[][] map=new char[n][m];
for(int i=0;i<n;i++) map[i]=next().toCharArray();
return map;
}
}
} | Main.java:39: error: incompatible types: possible lossy conversion from long to int
if(r[now]==0&&b[now]==0) return (long)p[now]+(long)q[now];
^
Main.java:42: error: incompatible types: possible lossy conversion from long to int
return bb/gcd(q[now],bb)*(p[now]+q[now]);
^
Main.java:46: error: incompatible types: possible lossy conversion from long to int
return rr/gcd(p[now],rr)*(p[now]+q[now]);
^
Main.java:49: error: incompatible types: possible lossy conversion from long to int
int g=gcd(bb*p[now],rr*q[now]);
^
Main.java:50: error: incompatible types: possible lossy conversion from long to int
return rr*(long)q[now]/g*bb+bb*(long)p[now]/g*rr;
^
5 errors
|
s028717418 | p00443 | Java | import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
public class Main{
static PrintWriter out;
static InputReader ir;
static int[] p=new int[101],q=new int[101],r=new int[101],b=new int[101],par=new int[101];
static void solve(){
int n;
while((n=ir.nextInt())!=0){
for(int i=0;i<n;i++){
p[i]=ir.nextInt();
q[i]=ir.nextInt();
r[i]=ir.nextInt();
b[i]=ir.nextInt();
par[r[i]]=par[b[i]]=i+1;
long g=gcd(p[i],q[i]);
p[i]/=(int)g;
q[i]/=(int)g;
}
int now=1;
while(par[now]!=0) now=par[now];
out.println(dfs(now));
Arrays.fill(par,0);
}
}
public static long dfs(int m){
int now=m-1;
if(r[now]==0&&b[now]==0) return (long)p[now]+(long)q[now];
if(r[now]==0){
long bb=dfs(b[now]);
return bb/gcd(q[now],bb)*(p[now]+q[now]);
}
if(b[now]==0){
long rr=dfs(r[now]);
return rr/gcd(p[now],rr)*(p[now]+q[now]);
}
long bb=dfs(b[now]),rr=dfs(r[now]);
int g=gcd(bb*p[now],rr*q[now]);
return rr*(long)q[now]/g*bb+bb*(long)p[now]/g*rr;
}
public static long gcd(long a,long b){
if(b==0) return a;
return gcd(b,a%b);
}
public static void main(String[] args) throws Exception{
ir=new InputReader(System.in);
out=new PrintWriter(System.out);
solve();
out.flush();
}
static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;
public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
public boolean hasNextByte() {
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}catch(IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0) return false;
}
return true;
}
private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
public boolean hasNext(){skip(); return hasNextByte();}
public String next(){
if(!hasNext()) throw new NoSuchElementException();
StringBuilder sb=new StringBuilder();
int b=readByte();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
public int nextInt() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public long nextLong() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public double nextDouble(){return Double.parseDouble(next());}
public int[] nextIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
public long[] nextLongArray(int n){
long[] a=new long[n];
for(int i=0;i<n;i++) a[i]=nextLong();
return a;
}
public char[][] nextCharMap(int n,int m){
char[][] map=new char[n][m];
for(int i=0;i<n;i++) map[i]=next().toCharArray();
return map;
}
}
} | Main.java:49: error: incompatible types: possible lossy conversion from long to int
int g=gcd(bb*p[now],rr*q[now]);
^
1 error
|
s649592492 | p00443 | Java | gimport java.io.*;
import java.util.*;
class Node {
public int p, q, r, b, parent;
Node(int p, int q, int r, int b) {
this.p = p;
this.q = q;
this.r = r;
this.b = b;
this.parent = -1;
}
}
public class Main {
Scanner sc;
int n;
int root;
Node[] tree;
long gcd(long a, long b) {
if (a > b) {
long tmp = a;
a = b;
b = tmp;
}
if (a == 0) return b;
return gcd(b % a, a);
}
long lcm(long a, long b) {
return a / gcd(a, b) * b;
}
Main() {
sc = new Scanner(System.in);
}
long lightest(int index) {
int p = tree[index].p;
int q = tree[index].q;
int r = tree[index].r;
int b = tree[index].b;
if (r == -1 && b == -1) {
return (p + q) / gcd(p, q);
} else if (r == -1) {
long b_weight = lcm(lightest(b), p);
long r_weight = b_weight * q / p;
return r_weight + b_weight;
} else if (b == -1) {
long r_weight = lcm(lightest(r), q);
long b_weight = r_weight * p / q;
return r_weight + b_weight;
}
long lcm_rb = lcm(lightest(r)*p, lightest(b)*q);
long r_weight = lcm_rb / p;
long b_weight = lcm_rb / q;
return r_weight + b_weight;
}
boolean init() {
n = sc.nextInt();
if (n == 0) return false;
tree = new Node[n];
for (int i = 0; i < n; i++) {
int p = sc.nextInt();
int q = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
long gcd_pq = gcd(p, q);
p /= gcd_pq;
q /= gcd_pq;
tree[i] = new Node(p, q, r-1, b-1); // 0-originに
}
// 親を探す
for (int i = 0; i < n; i++) {
if (tree[i].r >= 0) tree[tree[i].r].parent = i;
if (tree[i].b >= 0) tree[tree[i].b].parent = i;
}
// rootを探す
for (int i = 0; i < n; i++)
if (tree[i].parent == -1) {
root = i;
break;
}
return true;
}
void debug() {
for (int i = 0; i < n; i++) {
System.out.printf("%d %d %d %d %d\n", tree[i].p, tree[i].q, tree[i].r, tree[i].b, tree[i].parent);
}
}
void run() {
while (init()) {
System.out.printf("%d\n", lightest(root));
}
}
public static void main(String[] args) {
new Main().run();
}
} | Main.java:1: error: class, interface, enum, or record expected
gimport java.io.*;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.*;
^
2 errors
|
s803731420 | p00443 | C | #include<stdio.h>
#include<string.h>
#include<climits>
#define min(a,b) (a<b?a:b)
struct x{int p,q,r,b;}B[105];
int N,i,j,h[105],r,t;
int gcd(int a,int b)
{
int c;
for(;b!=0;)
{
c=a%b;a=b;b=c;
}
return a;
}
int dfs(int p)
{
int r,b,i,j,ta,tb,i,rj,t1,t2;
if(p==-1)return 1;
if(h[p]>=0)return h[p];
r=dfs(B[p].r);
b=dfs(B[p].b);
t1=10000000/(r*B[p].p),t2=10000000/(b*B[p].q);
i=j=-1;
ri=t1;
rj=t2;
for(i=1;i<=min(t1,t2);i++)
{
if((r*i*B[p].p)%(b*B[p].q))continue;
j=(r*i*B[p].p)/(b*B[p].q);
ta=r*i/B[p].q;
tb=b*j/B[p].p;
if(ta&&tb&&ta==tb)
{
if(ri*r+rj*b>i*r+j*b)
{
ri=i;
rj=j;
}
}
}
if(j==-1)ri=rj=(r*b)/gcd(r,b);
//printf("%d %d:%d %d:%d %d:%d\n",p,r,b,B[p].p,B[p].q,r*ri,b*rj);
return h[p]=r*ri+b*rj;
}
int main()
{
for(;scanf("%d",&N),N;)
{
memset(h,-1,sizeof(h));
for(i=0;i<N;i++)
{
scanf("%d%d%d%d",&B[i].p,&B[i].q,&B[i].r,&B[i].b);
t=gcd(B[i].p,B[i].q);
B[i].p/=t;B[i].q/=t;
B[i].r--;B[i].b--;
}
for(i=r=0;i<N;i++)
{
t=dfs(i);
r=r>t?r:t;
}
printf("%d\n",r);
}
return 0;
} | main.c:3:9: fatal error: climits: No such file or directory
3 | #include<climits>
| ^~~~~~~~~
compilation terminated.
|
s493909108 | p00443 | C | #include<stdio.h>
#include<string.h>
#include<climits>
#define min(a,b) (a<b?a:b)
struct x{int p,q,r,b;}B[105];
int N,i,j,h[105],r,t;
int gcd(int a,int b)
{
int c;
for(;b!=0;)
{
c=a%b;a=b;b=c;
}
return a;
}
int dfs(int p)
{
int r,b,i,j,ta,tb,ri,rj,t1,t2;
if(p==-1)return 1;
if(h[p]>=0)return h[p];
r=dfs(B[p].r);
b=dfs(B[p].b);
t1=10000000/(r*B[p].p),t2=10000000/(b*B[p].q);
i=j=-1;
ri=t1;
rj=t2;
for(i=1;i<=min(t1,t2);i++)
{
if((r*i*B[p].p)%(b*B[p].q))continue;
j=(r*i*B[p].p)/(b*B[p].q);
ta=r*i/B[p].q;
tb=b*j/B[p].p;
if(ta&&tb&&ta==tb)
{
if(ri*r+rj*b>i*r+j*b)
{
ri=i;
rj=j;
}
}
}
if(j==-1)ri=rj=(r*b)/gcd(r,b);
//printf("%d %d:%d %d:%d %d:%d\n",p,r,b,B[p].p,B[p].q,r*ri,b*rj);
return h[p]=r*ri+b*rj;
}
int main()
{
for(;scanf("%d",&N),N;)
{
memset(h,-1,sizeof(h));
for(i=0;i<N;i++)
{
scanf("%d%d%d%d",&B[i].p,&B[i].q,&B[i].r,&B[i].b);
t=gcd(B[i].p,B[i].q);
B[i].p/=t;B[i].q/=t;
B[i].r--;B[i].b--;
}
for(i=r=0;i<N;i++)
{
t=dfs(i);
r=r>t?r:t;
}
printf("%d\n",r);
}
return 0;
} | main.c:3:9: fatal error: climits: No such file or directory
3 | #include<climits>
| ^~~~~~~~~
compilation terminated.
|
s222494460 | p00443 | C | #include<stdio.h>
typedef struct {
long long p,q,r,b;
} mobile;
mobile bar[100];
long long data[100];
long long kbs(long long a, long long b){
if(a>b){
if(a%b==0) return b;
else return kbs(a%b,b);
}else{
if(b%a==0) return a;
else return kbs(a,b%a);
}
}
long long weight(int i){
if(data[i-1]>0) return data[i-1];
long long j;
if(bar[i-1].r==0 && bar[i-1].b==0){
j=kbs(bar[i-1].p,bar[i-1].q);
return data[i-1]=bar[i-1].p/j+bar[i-1].q/j;
}else if(bar[i-1].r==0){
b=bar[i-1].q*weight(bar[i-1].b);
j=kbs(bar[i-1].p,b);
return data[i-1]=weight(bar[i-1].b)*bar[i-1].p/j+b/j;
}else if(bar[i-1].b==0){
a=bar[i-1].p*weight(bar[i-1].r);
j=kbs(bar[i-1].q,a);
return data[i-1]=weight(bar[i-1].r)*bar[i-1].q/j+a/j;
}else{
a=bar[i-1].q*weight(bar[i-1].b);
b=bar[i-1].p*weight(bar[i-1].r);
j=kbs(a,b);
return data[i-1]=weight(bar[i-1].r)*b/j+weight(bar[i-1].b)*a/j;
}
}
int main(){
int n,i;
long long heavy,max;
scanf("%d",&n);
while(n!=0){
for(i=0;i<n;i++){
scanf("%lld %lld %lld %lld",&bar[i].p,&bar[i].q,&bar[i].r,&bar[i].b);
}
for(i=0;i<n;i++){
data[i]=0;
}
heavy=0;
max=0;
for(i=1;i<=n;i++){
heavy=weight(i);
max=max<heavy?heavy:max;
}
printf("%lld\n",max);
scanf("%d",&n);
}
return 0;
} | main.c: In function 'weight':
main.c:27:17: error: 'b' undeclared (first use in this function)
27 | b=bar[i-1].q*weight(bar[i-1].b);
| ^
main.c:27:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:31:17: error: 'a' undeclared (first use in this function)
31 | a=bar[i-1].p*weight(bar[i-1].r);
| ^
|
s919686985 | p00443 | C | #include <stdio.h>
#include <string.h>
typedef __int64 ll;
typedef struct {
int ldata, rdata;
int left, right;
int parent;
} BINARY;
BINARY tree[101];
int gcd(int a, int b)
{
if (a < b){
a ^= b;
b ^= a;
a ^= b;
}
return (b == 0 ? a : gcd(b, a % b));
}
int lcm(int a, int b)
{
return ((a / gcd(a, b)) * b);
}
int postorder(int root)
{
int l, r, x, y;
int cd;
if (tree[root].left){
l = postorder(tree[root].left);
}
else {
l = 1;
}
if (tree[root].right){
r = postorder(tree[root].right);
}
else {
r = 1;
}
if (tree[root].right + tree[root].left == 0){
cd = gcd(tree[root].ldata, tree[root].rdata);
return (tree[root].ldata / cd + tree[root].rdata / cd);
}
l *= tree[root].ldata;
r *= tree[root].rdata;
cd = gcd(l, r);
x = r / cd;
y = l / cd;
l *= x;
r *= y;
return (l / tree[root].ldata + r / tree[root].rdata);
}
int main(void)
{
int i;
int n;
int p, q, r, b;
int root;
while (1){
scanf("%d", &n);
if (n == 0){
break;
}
memset(tree, 0, sizeof(tree));
for (i = 1; i <= n; i++){
scanf("%d%d%d%d", &p, &q, &r, &b);
tree[i].ldata = p;
tree[i].rdata = q;
tree[i].left = r;
tree[i].right = b;
tree[r].parent = tree[b].parent = i;
}
for (i = 1; i <= n; i++){
if (tree[i].parent == 0){
root = i;
}
}
printf("%d\n", postorder(root));
}
return (0);
} | main.c:4:9: error: unknown type name '__int64'; did you mean '__int64_t'?
4 | typedef __int64 ll;
| ^~~~~~~
| __int64_t
|
s106386567 | p00443 | C | #include <cstdio>
using namespace std;
typedef struct stick{
int lren, rren, sl, sr, weight;
} STICK;
int n, tmp, top;
int depth[101];
STICK st[101];
void init(int k){
for(int i = 0; i <= k; i++){
depth[i] = 0;
st[i].weight = 0;
}
}
int gcd(int a, int b){
if(b == 0) return a;
return gcd(b, a % b);
}
int lcm(int a, int b){
return a / gcd(a, b) * b;
}
int solve(int k){
if(st[k].weight > 0) return st[k].weight;
if(st[k].sl == 0 && st[k].sr == 0){
return st[k].weight = st[k].lren + st[k].rren;
}else if(st[k].sl == 0){
return st[k].weight = solve(st[k].sr) * (st[k].lren + st[k].rren) / gcd(solve(st[k].sr), st[k].lren);
}else if(st[k]. sr == 0){
return st[k].weight = solve(st[k].sl) * (st[k].lren + st[k].rren) / gcd(solve(st[k].sl), st[k].rren);
}else {
tmp = lcm(solve(st[k].sl) * st[k].lren, solve(st[k].sr) * st[k].rren);
return st[k].weight = tmp / st[k].lren + tmp / st[k].rren;
}
}
int main(){
while(scanf("%d", &n)){
if(n == 0) break;
init(n);
for(int i = 1; i <= n; i++){
scanf("%d %d %d %d", &st[i].lren, &st[i].rren, &st[i].sl, &st[i].sr);
tmp = gcd(st[i].lren, st[i].rren);
st[i].lren /= tmp;
st[i].rren /= tmp;
}
for(int i = 1; i <= n; i++){
depth[st[i].sl]++;
depth[st[i].sr]++;
}
for(int i = 1; i<= n; i++){
if(depth[i] == 0){
top = i;
break;
}
}
printf("%d\n", solve(top));
}
return 0;
} | main.c:1:10: fatal error: cstdio: No such file or directory
1 | #include <cstdio>
| ^~~~~~~~
compilation terminated.
|
s500105818 | p00443 | C | /*
AizuOnline A0520
Lightest Mobile
*/
#include <stdio.h>
struct MOB
{
int leftlen ;int rightlen;
int leftnode ;int rightnode;
} ;
struct MOB mobiles[100];
int prime[10]={2,3,5,7,11,13,17,19,23,29};
long int gcd(long int x,long int y)
{ long int w,r;
int i,pr;
for(i=0;i<10;i++)
{
pr=prime[i];
if(x % pr == 0 && y % pr == 0)
return(pr*gcd(x/pr,y/pr));
}
if(x < y)
{
w = x;
x = y;
y= w;
}
if((r = x % y) ==0)
return(y);
return(gcd (y, r));
}
long int lcm(long int x,long int y)
{
return(x/gcd(x,y)*y);1
}
long int calc_total_weight1(int leftlen, int rightlen,long int leftweight , long int rightweight)
{
long int l;
// printf("%d %d %ld %ld\n",leftlen,rightlen,leftweight,rightweight);
l=lcm((leftlen *rightweight),(rightlen * leftweight));
return(l/leftlen+l/rightlen);
}
long int calc_total_weight(struct MOB *m,int node_no)
{ long int w1,w2,tw;
struct MOB * bar;
bar = m + (node_no - 1);
if(bar -> leftnode != 0)
w1 = calc_total_weight(m,(bar->leftnode));
else
w1 = 1;
if(bar -> rightnode != 0)
w2 = calc_total_weight(m,(bar->rightnode));
else
w2 = 1;
tw = calc_total_weight1(bar->leftlen,bar->rightlen,w1,w2);
return(tw);
}
int search_root(struct MOB * m,int siz)
{
int i,j;
for(i=1;i<=siz;i++)
{ for(j=0;j<siz;j++)
{
if(m[j].leftnode == i ||m[j].rightnode == i)
goto AAA;
}
return(i);
AAA:
;
}
return(-1);
}
main()
{
int i;
long int total_weight;
int root;
int cnt;
while(EOF != scanf("%d",&cnt) && cnt)
{
for(i=0;i<cnt;i++)
scanf(" %d %d %d %d",
&(mobiles[i].leftlen),
&(mobiles[i].rightlen),
&(mobiles[i].leftnode),
&(mobiles[i].rightnode));
root = search_root(mobiles,cnt);
total_weight = calc_total_weight(mobiles,root);
printf("%ld\n",total_weight);
}
return(0);
} | main.c: In function 'lcm':
main.c:37:25: error: expected ';' before '}' token
37 | return(x/gcd(x,y)*y);1
| ^
| ;
38 | }
| ~
main.c: At top level:
main.c:87:1: error: return type defaults to 'int' [-Wimplicit-int]
87 | main()
| ^~~~
|
s432781225 | p00443 | C | #include <stdio.h>
typedef struct _node{
unsigned int p;
unsigned int q;
unsigned int r;
unsigned int b;
unsigned int left; //p-side mass
unsigned int right; //q-side mass
} Node;
unsigned int calc_mass(unsigned int trgt);
unsigned int calc_gcd( unsigned int a, unsigned int b);
Node MOB[101];
unsigned int main(){
unsigned int n;
unsigned int chk[101];
unsigned int i;
unsigned int p;
unsigned int q;
unsigned int r;
unsigned int b;
unsigned int Top;
unsigned int Total;
unsigned int gcd;
while(1){
scanf("%d\n",&n);
if(n==0)break;
for(i=1;i<=n;i++){
scanf("%d %d %d %d\n",&p,&q,&r,&b);
gcd=calc_gcd(p,q);
MOB[i].p=p/gcd;
MOB[i].q=q/gcd;
MOB[i].r=r;
MOB[i].b=b;
MOB[i].left=0;
MOB[i].right=0;
}
// search TOP;
for(i=1;i<=n;i++)chk[i]=0;
for(i=1;i<=n;i++){
if(MOB[i].r!=0)chk[MOB[i].r]=1;
if(MOB[i].b!=0)chk[MOB[i].b]=1;
}
for(i=1;i<=n;i++){
if(chk[i]==0)Top=i;
}
Total=calc_mass(Top);
prunsigned intf("%d\n",Total);
}
return 0;
}
unsigned int calc_gcd( unsigned int a, unsigned int b){
unsigned int c=1;
unsigned int gcd;
if(a==0 || b==0)return 0;
if(a<b){
c=a,a=b,b=c;
}
gcd=1;
while(a%b!=0){
c=b;
b=a%b;
a=c;
}
gcd=b;
return gcd;
}
unsigned int calc_mass(unsigned int trgt){
unsigned int gcd;
unsigned int left,right;
if(MOB[trgt].r==0 && MOB[trgt].b==0){
gcd=calc_gcd(MOB[trgt].p,MOB[trgt].q);
MOB[trgt].left=MOB[trgt].q/gcd;
MOB[trgt].right=MOB[trgt].p/gcd;
return MOB[trgt].left+MOB[trgt].right;
}
if(MOB[trgt].left==0){
if(MOB[trgt].r==0)left=1;
if(MOB[trgt].r!=0)left=calc_mass(MOB[trgt].r);
}
if(MOB[trgt].right==0){
if(MOB[trgt].b==0)right=1;
if(MOB[trgt].b!=0)right=calc_mass(MOB[trgt].b);
}
gcd=calc_gcd(left*MOB[trgt].q,right*MOB[trgt].p);
MOB[trgt].left=left*right*MOB[trgt].p/gcd;
MOB[trgt].right=right*left*MOB[trgt].q/gcd;
return MOB[trgt].left+MOB[trgt].right;
} | main.c: In function 'main':
main.c:54:17: error: unknown type name 'prunsigned'; did you mean 'unsigned'?
54 | prunsigned intf("%d\n",Total);
| ^~~~~~~~~~
| unsigned
main.c:54:33: error: expected declaration specifiers or '...' before string constant
54 | prunsigned intf("%d\n",Total);
| ^~~~~~
main.c:54:40: error: expected declaration specifiers or '...' before 'Total'
54 | prunsigned intf("%d\n",Total);
| ^~~~~
|
s206193635 | p00443 | C | #include <stdio.h>
typedef struct _node{
unsigned int p;
unsigned int q;
unsigned int r;
unsigned int b;
unsigned int left; //p-side mass
unsigned int right; //q-side mass
} Node;
unsigned int calc_mass(unsigned int trgt);
unsigned int calc_gcd( unsigned int a, unsigned int b);
Node MOB[101];
unsigned int main(){
unsigned int n;
unsigned int chk[101];
unsigned int i;
unsigned int p;
unsigned int q;
unsigned int r;
unsigned int b;
unsigned int Top;
unsigned int Total;
unsigned int gcd;
while(1){
scanf("%u\n",&n);
if(n==0)break;
for(i=1;i<=n;i++){
scanf("%u %u %u %u\n",&p,&q,&r,&b);
gcd=calc_gcd(p,q);
MOB[i].p=p/gcd;
MOB[i].q=q/gcd;
MOB[i].r=r;
MOB[i].b=b;
MOB[i].left=0;
MOB[i].right=0;
}
// search TOP;
for(i=1;i<=n;i++)chk[i]=0;
for(i=1;i<=n;i++){
if(MOB[i].r!=0)chk[MOB[i].r]=1;
if(MOB[i].b!=0)chk[MOB[i].b]=1;
}
for(i=1;i<=n;i++){
if(chk[i]==0)Top=i;
}
Total=calc_mass(Top);
printf("%u\n",Total);
}
return 0;
}
unsigned int calc_gcd( unsigned int a, unsigned int b){
unsigned int c=1;
unsigned int gcd;
if(a==0 || b==0)return 0;
if(a==1 || b==1)return 1;
if(a<b){
c=a,a=b,b=c;
}
gcd=1;
while(a%b!=0){
c=b;
b=a%b;
a=c;
}
gcd=b;
return gcd;
}
unsigned int calc_mass(unsigned int trgt){
unsigned int gcd;
unsigned int left,right;
unsigned int left2,right2;
unsigned int ratio;
if(MOB[trgt].r==0 && MOB[trgt].b==0){
gcd=calc_gcd(MOB[trgt].p,MOB[trgt].q);
MOB[trgt].left=MOB[trgt].q/gcd;
MOB[trgt].right=MOB[trgt].p/gcd;
return MOB[trgt].left+MOB[trgt].right;
}
if(MOB[trgt].left==0){
if(MOB[trgt].r==0)left=1;
if(MOB[trgt].r!=0)left=calc_mass(MOB[trgt].r);
}
if(MOB[trgt].right==0){
if(MOB[trgt].b==0)right=1;
if(MOB[trgt].b!=0)right=calc_mass(MOB[trgt].b);
}
gcd=calc_gcd(right,left)
left2=left/gcd,right2=right/gcd;
gcd=calc_gcd(left2*MOB[trgt].q,right2*MOB[trgt].p);
ratio=(right2*MOB[trgt].p)/gcd;
MOB[trgt].left=left*ratio;
ratio=(left2*MOB[trgt].q)/gcd;
MOB[trgt].right=right*ratio;
return MOB[trgt].left+MOB[trgt].right;
} | main.c: In function 'calc_mass':
main.c:111:33: error: expected ';' before 'left2'
111 | gcd=calc_gcd(right,left)
| ^
| ;
112 | left2=left/gcd,right2=right/gcd;
| ~~~~~
|
s114721263 | p00443 | C | #include <stdio.h>
typedef struct _node{
long long int p;
long long int q;
int r;
int b;
long long int left; //p-side mass
long long int right; //q-side mass
} Node;
long long int calc_mass(int trgt);
long long int calc_gcd( int a, int b);
Node MOB[101];
int main(){
int n;
int chk[101];
int i;
long long int p;
long long int q;
int r;
int b;
int Top;
long long int Total;
long long int gcd;
while(1){
scanf("%d\n",&n);
if(n==0)break;
for(i=1;i<=n;i++){
scanf("%lld %lld %d %d\n",&p,&q,&r,&b);
gcd=calc_gcd(p,q);
MOB[i].p=p/gcd;
MOB[i].q=q/gcd;
MOB[i].r=r;
MOB[i].b=b;
MOB[i].left=0;
MOB[i].right=0;
}
// search TOP;
for(i=1;i<=n;i++)chk[i]=0;
for(i=1;i<=n;i++){
if(MOB[i].r!=0)chk[MOB[i].r]=1;
if(MOB[i].b!=0)chk[MOB[i].b]=1;
}
for(i=1;i<=n;i++){
if(chk[i]==0){
Top=i;
break;
}
}
Total=calc_mass(Top);
printf("%lld\n",Total);
}
return 0;
}
long long int calc_gcd( long long int a, long long int b){
long long int c=1;
long long int gcd;
// if(a==0 || b==0)return 0;
// if(a==1 || b==1)return 1;
// if(a<b){
// c=a,a=b,b=c;
// }
gcd=1;
while(a%b!=0){
c=b;
b=a%b;
a=c;
}
gcd=b;
return gcd;
}
long long int calc_mass(int trgt){
long long int gcd;
long long int left,right;
if(MOB[trgt].r==0 && MOB[trgt].b==0){
gcd=calc_gcd(MOB[trgt].p,MOB[trgt].q);
MOB[trgt].left=MOB[trgt].q/gcd;
MOB[trgt].right=MOB[trgt].p/gcd;
return MOB[trgt].left+MOB[trgt].right;
}
if(MOB[trgt].left==0){
if(MOB[trgt].r==0)left=1;
if(MOB[trgt].r!=0)left=calc_mass(MOB[trgt].r);
}
if(MOB[trgt].right==0){
if(MOB[trgt].b==0)right=1;
if(MOB[trgt].b!=0)right=calc_mass(MOB[trgt].b);
}
gcd=calc_gcd(left*MOB[trgt].q,right*MOB[trgt].p);
MOB[trgt].left=left*right*MOB[trgt].p/gcd;
MOB[trgt].right=right*left*MOB[trgt].q/gcd;
return MOB[trgt].left+MOB[trgt].right;
} | main.c:64:15: error: conflicting types for 'calc_gcd'; have 'long long int(long long int, long long int)'
64 | long long int calc_gcd( long long int a, long long int b){
| ^~~~~~~~
main.c:12:15: note: previous declaration of 'calc_gcd' with type 'long long int(int, int)'
12 | long long int calc_gcd( int a, int b);
| ^~~~~~~~
|
s935039855 | p00443 | C++ | #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int gcd(int a, int b) {
if (b == 0) {
return a;
}
int r = a % b;
return gcd(b, r);
int we(int wl, int wr, int lel, int ler) {
int ml = wl * lel;
int mr = wr * ler;
int bil = mr / gcd(ml, mr);
int bir = ml / gcd(ml, mr);
return (wl * bil)+(wr*bir);
}
int main(){
int n;
cin >> n;
while(n!=0){
vector<int> w(n);
vector<int> lel(n);
vector<int> ler(n);
vector<int> nul(n);
vector<int> nur(n);
for (int i = 0; i < n; i++) {
int l, r;
cin >> lel[i] >> ler[i] >> l >> r;
l--; r--;
nul[i] = l; nur[i] = r;
}
vector<int> d(n,n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int x, y;
if (nul[j] == -1) {
x = -1;
}
else {
x = d[nul[j]];
}
if (nur[j] == -1) {
y = -1;
}
else {
y = d[nur[j]];
}
d[j]=min(d[j], max(x, y)+1);
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (d[j] == i) {
int wl, wr;
int l = nul[j];
int r = nur[j];
if (l == -1) {
wl = 1;
}
else {
wl = w[l];
}
if (r == -1) {
wr = 1;
}
else {
wr = w[r];
}
w[j] = we(wl, wr, lel[j], ler[j]);
ans = max(ans, w[j]);
}
}
}
cout << ans << endl;
cin >> n;
}
}
| a.cc: In function 'int gcd(int, int)':
a.cc:13:42: error: a function-definition is not allowed here before '{' token
13 | int we(int wl, int wr, int lel, int ler) {
| ^
a.cc:20:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
20 | int main(){
| ^~
a.cc:20:9: note: remove parentheses to default-initialize a variable
20 | int main(){
| ^~
| --
a.cc:20:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:20:11: error: a function-definition is not allowed here before '{' token
20 | int main(){
| ^
a.cc:81:2: error: expected '}' at end of input
81 | }
| ^
a.cc:6:23: note: to match this '{'
6 | int gcd(int a, int b) {
| ^
|
s160356896 | p00443 | C++ | #include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
struct node{ll lv,rv,lc,rc;};
#define MAX_N 101
ll gcd(ll x,ll y){return __gcd(x,y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
int n;
node g[MAX_N];
int t[MAX_N];
ll rec(int pos){
if(pos==0)return 1;
node m=g[pos];
ll a=rec(m.lc);
ll b=rec(m.rc);
ll c=gcd(a*m.lv,b*m.rv);
return a*(b*m.rv/c)+b*(a*m.lv/c);
}
void solve(){
int root;
for(root=1;t[root]>0;root++);
cout<<rec(root)<<endl;
}
void init(){
for(int i=0;i<MAX_N;i++)t[i]=0;
}
int main(){
while(1){
cin>>n;
if(n==0)break;
init();
for(int i=1;i<=n;i++){
ll p,q,r,b,x;
cin>>p>>q>>r>>b;
x=gcd(p,q);
p/=x,q/=x;
g[i]=(node){p,q,r,b};
t[r]=t[b]=i;
}
solve();
}
return 0;
} | a.cc: In function 'void solve()':
a.cc:26:3: error: 'cout' was not declared in this scope
26 | cout<<rec(root)<<endl;
| ^~~~
a.cc:3:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include<algorithm>
+++ |+#include <iostream>
3 | using namespace std;
a.cc:26:20: error: 'endl' was not declared in this scope
26 | cout<<rec(root)<<endl;
| ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
2 | #include<algorithm>
+++ |+#include <ostream>
3 | using namespace std;
a.cc: In function 'int main()':
a.cc:35:5: error: 'cin' was not declared in this scope
35 | cin>>n;
| ^~~
a.cc:35:5: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s889740789 | p00443 | C++ | #include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int GCD(int a,int b){
if(b>a)swap(a,b);
return (b==0)?a:GCD(b,a%b);
}
int LCM(int a,int b){
return a*b/GCD(a,b);
}
int l[101],r[101],w1[101],w2[101];
int dfs(int x){
if(x==0)return 1;
int red=l[x]*dfs(w1[x]);
int blue=r[x]*dfs(w2[x]);
int lcm=LCM(red,blue);
return memo[x]=lcm/l[x]+lcm/r[x];
}
int main(){
int n;
while(scanf("%d",&n),n){
bool flag[N+1];fill(flag,flag+n+1,true);
for(int i=1;i<=n;i++){
scanf("%d%d%d%d",&l[i],&r[i],&w1[i],&w2[i]);
flag[w1[i]]=flag[w2[i]]=false;
}
for(int i=1;i<=n;i++){
if(flag[i]){
printf("%d\n",dfs(i));
break;
}
}
}
return 0;
} | a.cc: In function 'int dfs(int)':
a.cc:18:12: error: 'memo' was not declared in this scope
18 | return memo[x]=lcm/l[x]+lcm/r[x];
| ^~~~
a.cc: In function 'int main()':
a.cc:23:19: error: 'N' was not declared in this scope
23 | bool flag[N+1];fill(flag,flag+n+1,true);
| ^
a.cc:23:29: error: 'flag' was not declared in this scope
23 | bool flag[N+1];fill(flag,flag+n+1,true);
| ^~~~
|
s224197584 | p00443 | C++ | #include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int GCD(int a,int b){
if(b>a)swap(a,b);
return (b==0)?a:GCD(b,a%b);
}
int LCM(int a,int b){
return a/gcd(a,b)*b;
}
int l[101],r[101],w1[101],w2[101];
int memo[101];
int dfs(int x){
if(x==0)return 1;
if(memo[x]!=-1)return memo[x];
int red=l[x]*dfs(w1[x]);
int blue=r[x]*dfs(w2[x]);
int lcm=LCM(red,blue);
return memo[x]=lcm/l[x]+lcm/r[x];
}
int main(){
int n;
while(scanf("%d",&n),n){
bool flag[101];fill(flag,flag+n+1,true);
fill(memo,memo+n+1,-1);
for(int i=1;i<=n;i++){
scanf("%d%d%d%d",&l[i],&r[i],&w1[i],&w2[i]);
flag[w1[i]]=flag[w2[i]]=false;
}
for(int i=1;i<=n;i++){
if(flag[i]){
printf("%d\n",dfs(i));
break;
}
}
}
return 0;
} | a.cc: In function 'int LCM(int, int)':
a.cc:10:14: error: 'gcd' was not declared in this scope
10 | return a/gcd(a,b)*b;
| ^~~
|
s970469374 | p00443 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n;
ll red[100];
ll blue[100];
ll le[100];
ll ri[100];
ll gcd(ll a,ll b){
if(b>a){ a^=b; b^=a; a^=b; }
while(1){
int temp=a%b;
if(temp==0) break;
a=b; b=temp;
}
return b;
}
ll dfs(int now){
ll l=1,r=1;
if(le[now]!=0) l*=dfs(le[now]-1);
if(ri[now]!=0) r*=dfs(ri[now]-1);
ll g=gcd(blue[now]*r,red[now]*l);
l
l ans=blue[now]*r*red[now]*l/g;
return ans/blue[now]+ans/red[now];
}
int main(){
while(true){
cin>>n;
if(n==0) return 0;
vector<int> parent(n,-1);
for(int i=0;i<n;i++){
cin>>red[i]>>blue[i]>>le[i]>>ri[i];
if(le[i]!=0) parent[le[i]-1]=i;
if(ri[i]!=0) parent[ri[i]-1]=i;
}
for(int i=0;i<n;i++){
if(parent[i]==-1){
cout<<dfs(i)<<endl;
break;
}
}
}
return 0;
} | a.cc: In function 'll dfs(int)':
a.cc:25:10: error: expected ';' before 'l'
25 | l
| ^
| ;
26 | l ans=blue[now]*r*red[now]*l/g;
| ~
a.cc:27:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
27 | return ans/blue[now]+ans/red[now];
| ^~~
| abs
|
s737715893 | p00443 | C++ | #include <iostream>
using namespace std;
int dp[110],K[110],O[110],L[110],R[110];
int gcd(int a,int b){
int tmp;
while((tmp=a%b)!=0){
a=b;
b=tmp;
}
return b;
}
int mobi(int bou){
if(bou==0) return 1;
if(dp[bou]!=0) return dp[bou];
int l,r,li,ri,gc,gc2,a,b;
l=mobi(L[bou]);
r=mobi(R[bou]);
ri=K[bou];li=O[bou];
gc=gcd(li,ri);
li/=gc;ri/=gc;
gc2=gcd(li*l,ri*r);
b=li*l/gc2;
a=ri*r/gc2;
return dp[bou]=(a*l+b*r);
}
int main(){
int N,res;
while(1){
cin>>N;
memset(dp,0,sizeof(dp));
for(int i=1;i<=N;i++){
cin>>K[i]>>O[i]>>L[i]>>R[i];
}
res=0;
for(int i=1;i<=N;i++){
res=max(res,mobi(i));
}
cout<<res<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:35:17: error: 'memset' was not declared in this scope
35 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | using namespace std;
|
s795475820 | p00443 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int x[100][2],w[100][2],n;
bool cal[110];
int COU(int a,int b){
??while(true){
????if(a<2||b<2)return 1;
????if(a<b){int t=a;a=b,b=t;}
????a%=b;
????if(!a)return b;
??}
}
long long DFS(int q){
????????if(!q)return 1;
????????q--;
????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
????????return (a*b*(x[q][0]+x[q][1]))/COU(a*x[q][0],b*x[q][1]);
}
int main(){
??while(true){
??cin>>n;
??if(!n)break;
??for(int i=0;i<n;i++)cal[i]=false;
??for(int i=0;i<n;i++){
????cin>>x[i][0]>>x[i][1]>>w[i][0]>>w[i][1];
????cal[w[i][0]-1]=true,cal[w[i][1]-1]=true;
??}
??for(int i=0;i<n;i++)if(!cal[i])cout<<DFS(i+1)<<endl;
??}
??return 0;
} | a.cc: In function 'int COU(int, int)':
a.cc:7:1: error: expected primary-expression before '?' token
7 | ??while(true){
| ^
a.cc:7:2: error: expected primary-expression before '?' token
7 | ??while(true){
| ^
a.cc:7:3: error: expected primary-expression before 'while'
7 | ??while(true){
| ^~~~~
a.cc:7:3: error: expected ':' before 'while'
7 | ??while(true){
| ^~~~~
| :
a.cc:7:3: error: expected primary-expression before 'while'
7 | ??while(true){
| ^~~~~
a.cc:7:3: error: expected ':' before 'while'
7 | ??while(true){
| ^~~~~
| :
a.cc:7:3: error: expected primary-expression before 'while'
7 | ??while(true){
| ^~~~~
a.cc:13:1: warning: no return statement in function returning non-void [-Wreturn-type]
13 | }
| ^
a.cc: In function 'long long int DFS(int)':
a.cc:15:1: error: expected primary-expression before '?' token
15 | ????????if(!q)return 1;
| ^
a.cc:15:2: error: expected primary-expression before '?' token
15 | ????????if(!q)return 1;
| ^
a.cc:15:3: error: expected primary-expression before '?' token
15 | ????????if(!q)return 1;
| ^
a.cc:15:4: error: expected primary-expression before '?' token
15 | ????????if(!q)return 1;
| ^
a.cc:15:5: error: expected primary-expression before '?' token
15 | ????????if(!q)return 1;
| ^
a.cc:15:6: error: expected primary-expression before '?' token
15 | ????????if(!q)return 1;
| ^
a.cc:15:7: error: expected primary-expression before '?' token
15 | ????????if(!q)return 1;
| ^
a.cc:15:8: error: expected primary-expression before '?' token
15 | ????????if(!q)return 1;
| ^
a.cc:15:9: error: expected primary-expression before 'if'
15 | ????????if(!q)return 1;
| ^~
a.cc:15:9: error: expected ':' before 'if'
15 | ????????if(!q)return 1;
| ^~
| :
a.cc:15:9: error: expected primary-expression before 'if'
15 | ????????if(!q)return 1;
| ^~
a.cc:15:9: error: expected ':' before 'if'
15 | ????????if(!q)return 1;
| ^~
| :
a.cc:15:9: error: expected primary-expression before 'if'
15 | ????????if(!q)return 1;
| ^~
a.cc:15:9: error: expected ':' before 'if'
15 | ????????if(!q)return 1;
| ^~
| :
a.cc:15:9: error: expected primary-expression before 'if'
15 | ????????if(!q)return 1;
| ^~
a.cc:15:9: error: expected ':' before 'if'
15 | ????????if(!q)return 1;
| ^~
| :
a.cc:15:9: error: expected primary-expression before 'if'
15 | ????????if(!q)return 1;
| ^~
a.cc:15:9: error: expected ':' before 'if'
15 | ????????if(!q)return 1;
| ^~
| :
a.cc:15:9: error: expected primary-expression before 'if'
15 | ????????if(!q)return 1;
| ^~
a.cc:15:9: error: expected ':' before 'if'
15 | ????????if(!q)return 1;
| ^~
| :
a.cc:15:9: error: expected primary-expression before 'if'
15 | ????????if(!q)return 1;
| ^~
a.cc:15:9: error: expected ':' before 'if'
15 | ????????if(!q)return 1;
| ^~
| :
a.cc:15:9: error: expected primary-expression before 'if'
15 | ????????if(!q)return 1;
| ^~
a.cc:15:9: error: expected ':' before 'if'
15 | ????????if(!q)return 1;
| ^~
| :
a.cc:15:9: error: expected primary-expression before 'if'
15 | ????????if(!q)return 1;
| ^~
a.cc:16:1: error: expected primary-expression before '?' token
16 | ????????q--;
| ^
a.cc:16:2: error: expected primary-expression before '?' token
16 | ????????q--;
| ^
a.cc:16:3: error: expected primary-expression before '?' token
16 | ????????q--;
| ^
a.cc:16:4: error: expected primary-expression before '?' token
16 | ????????q--;
| ^
a.cc:16:5: error: expected primary-expression before '?' token
16 | ????????q--;
| ^
a.cc:16:6: error: expected primary-expression before '?' token
16 | ????????q--;
| ^
a.cc:16:7: error: expected primary-expression before '?' token
16 | ????????q--;
| ^
a.cc:16:8: error: expected primary-expression before '?' token
16 | ????????q--;
| ^
a.cc:16:12: error: expected ':' before ';' token
16 | ????????q--;
| ^
| :
a.cc:16:12: error: expected primary-expression before ';' token
a.cc:16:12: error: expected ':' before ';' token
16 | ????????q--;
| ^
| :
a.cc:16:12: error: expected primary-expression before ';' token
a.cc:16:12: error: expected ':' before ';' token
16 | ????????q--;
| ^
| :
a.cc:16:12: error: expected primary-expression before ';' token
a.cc:16:12: error: expected ':' before ';' token
16 | ????????q--;
| ^
| :
a.cc:16:12: error: expected primary-expression before ';' token
a.cc:16:12: error: expected ':' before ';' token
16 | ????????q--;
| ^
| :
a.cc:16:12: error: expected primary-expression before ';' token
a.cc:16:12: error: expected ':' before ';' token
16 | ????????q--;
| ^
| :
a.cc:16:12: error: expected primary-expression before ';' token
a.cc:16:12: error: expected ':' before ';' token
16 | ????????q--;
| ^
| :
a.cc:16:12: error: expected primary-expression before ';' token
a.cc:16:12: error: expected ':' before ';' token
16 | ????????q--;
| ^
| :
a.cc:16:12: error: expected primary-expression before ';' token
a.cc:17:1: error: expected primary-expression before '?' token
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^
a.cc:17:2: error: expected primary-expression before '?' token
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^
a.cc:17:3: error: expected primary-expression before '?' token
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^
a.cc:17:4: error: expected primary-expression before '?' token
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^
a.cc:17:5: error: expected primary-expression before '?' token
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^
a.cc:17:6: error: expected primary-expression before '?' token
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^
a.cc:17:7: error: expected primary-expression before '?' token
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^
a.cc:17:8: error: expected primary-expression before '?' token
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^
a.cc:17:9: error: expected primary-expression before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
a.cc:17:9: error: expected ':' before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
| :
a.cc:17:9: error: expected primary-expression before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
a.cc:17:9: error: expected ':' before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
| :
a.cc:17:9: error: expected primary-expression before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
a.cc:17:9: error: expected ':' before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
| :
a.cc:17:9: error: expected primary-expression before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
a.cc:17:9: error: expected ':' before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
| :
a.cc:17:9: error: expected primary-expression before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
a.cc:17:9: error: expected ':' before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
| :
a.cc:17:9: error: expected primary-expression before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
a.cc:17:9: error: expected ':' before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
| :
a.cc:17:9: error: expected primary-expression before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
a.cc:17:9: error: expected ':' before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
| :
a.cc:17:9: error: expected primary-expression before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
a.cc:17:9: error: expected ':' before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
| :
a.cc:17:9: error: expected primary-expression before 'long'
17 | ????????long long a=DFS(w[q][0]),b=DFS(w[q][1]);
| ^~~~
a.cc:18:1: error: expected primary-expression before '?' token
18 | ????????return (a*b*(x[q][0]+x[q][1]))/COU(a*x[q][0],b*x[q][1]);
| ^
a.cc:18:2: error: expected primary-expression before '?' token
18 | ????????return (a*b*(x[q][0]+x[q][1]))/COU(a*x[q][0],b*x[q][1]);
| ^
a.cc:18:3: error: expected primary-expression before '?' token
18 | ????????return (a*b*(x[q][0]+x[q][1]))/COU(a*x[q][0],b*x[q][1]);
| ^
a.cc:18:4: error: expected primary-expression before '?' token
18 | ????????return (a*b*(x[q][0]+x[q][1]))/COU(a*x[q][0],b*x[q][1]);
| ^
a.cc:18:5: error: expected primary-expression before '?' token
18 | ????????return (a*b*(x[q][0]+x[q][1]))/COU(a*x[q][0],b*x[q][1]);
| ^
a.cc:18:6: error: expected primary-expression before '?' token
18 | ????????return (a*b*(x[q][0]+x[q][1]))/COU(a*x[q][0],b*x[q][1]);
| ^
a.cc:18:7: error: expected primary-expression before '?' token
18 | ????????return (a*b*(x[q][0]+x[q][1])) |
s514273349 | p00443 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int x[100][2],w[100][2],n;
bool cal[110];
int COU(int a,int b){
while(true){
if(a<2||b<2)return 1;
if(a<b){int t=a;a=b,b=t;}
a%=b;
if(!a)return b;
}
}
long long DFS(int q){
if(!q)return 1;
q--;
long long a=DFS(w[q][0]),b=DFS(w[q][1]);
return (a*b*(x[q][0]+x[q][1]))/COU(a*x[q][0],b*x[q][1]);
}
int main(){
while(true){
cin>>n;
if(!n)break
for(int i=0;i<n;i++)cal[i]=false;
for(int i=0;i<n;i++){
cin>>x[i][0]>>x[i][1]>>w[i][0]>>w[i][1];
cal[w[i][0]-1]=true,cal[w[i][1]-1]=true;
}
for(int i=0;i<n;i++)if(!cal[i])cout<<DFS(i+1)<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:23:28: error: expected ';' before 'for'
23 | if(!n)break
| ^
| ;
24 | for(int i=0;i<n;i++)cal[i]=false;
| ~~~
|
s459731263 | p00443 | C++ | #include<bits/stdc++.h>
#define int long long
using namespace std;
int gcd(int a,int b){
if(b==0)return a;
return gcd(b,a%b);
}
int lcm(int a,int b){return a*b/gcd(a,b);}
struct bou{
int l,r,x,y;
};
int n[100];bou m[101];
int mincost(int a){
if(n[a-1]!=-1)return n[a-1];
int b=1,c=1;
if(m[a].x)b=mincost(m[a].x);
if(m[a].y)c=mincost(m[a].y);
n[a-1]=lcm(b,c)*(m[a].l+m[a].r);
return lcm(b,c)*(m[a].l+m[a].r);
}
int main(){
int a;
while(cin>>a,a){
memset(n,-1,sizeof(n));
bou g;
for(int b=1;b<=a;b++){
int c,d;
scanf("%d%d%d%d",&c,&d,&g.x,&g.y);
g.l=c/gcd(c,d);g.r=d/gcd(c,d);
m[b]=g;
}
for(int i=0;i<a;i++){
if(n[i]==-1)mincost(i+1);
}
int MAX=0;
for(int i=0;i<a;i++){
MAX=max(MAX,n[i]);
}
cout<<MAX<<endl;
}
} | cc1plus: error: '::main' must return 'int'
|
s402874352 | p00443 | C++ | #include "bits/stdc++.h"
using namespace std;
#define int long long
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
VV g;
vector<P> len;
int dfs(int now) {
int a = g[now][0] >= 0 ? dfs(g[now][0]) : 1;
int b = g[now][1] >= 0 ? dfs(g[now][1]) : 1;
int p, q;
tie(p, q) = len[now];
int gcd = __gcd(a*p, b*q);
int x = b*q / gcd;
int y = a*p / gcd;
return a*x + b*y;
}
signed main() {
int n;
while (cin >> n&&n) {
g.clear();
g.resize(n);
len.clear();
len.resize(n);
V root(n, true);
rep(i, n) {
int p, q, r, b;
cin >> p >> q >> r >> b;
r--; b--;
int gcd = __gcd(p, q);
p = p / gcd;
q = q / gcd;
if (~r) root[r] = false;
if (~b) root[b] = false;
g[i].push_back(r);
g[i].push_back(b);
len[i] = P(p, q);
}
int idx = find(all(root), true) - root.begin();
cout << dfs(idx) << endl;
}
} | a.cc: In function 'int main()':
a.cc:52:32: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
52 | int idx = find(all(root), true) - root.begin();
| ^~~
| std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
158 | all = 0777,
| ^~~
|
s732937866 | p00443 | C++ | #include <iostream>
#define int long long
using namespace std;
typedef struct Node {
int p, q, r, b;
} Node;
int gcd(int a, int b){
if(a < b){ return gcd(b, a); }
if(b > 0){ return gcd(b, a % b); }
return a;
}
int lcm(int a, int b){
long long tmp = a;
tmp *= b;
return (int)(tmp / gcd(a, b));
}
Node nodes[101];
int calculate(int n){
int d = gcd(nodes[n].p, nodes[n].q);
int op = nodes[n].p / d, oq = nodes[n].q / d, answer;
if(nodes[n].r == 0 && nodes[n].b == 0){
answer = op + oq;
}else if(nodes[n].r == 0){
int t = lcm(oq, calculate(nodes[n].b) * op);
answer = t / op + t / oq;
}else if(nodes[n].b == 0){
int t = lcm(op, calculate(nodes[n].r) * oq);
answer = t / op + t / oq;
}else{
int t = lcm(op * calculate(nodes[n].b), oq * calculate(nodes[n].r));
answer = t / op + t / oq;
}
return answer;
}
int main(){
while(true){
int n;
cin >> n;
if(n == 0){ break; }
for(int i = 1; i <= n; i++){
cin >> nodes[i].p >> nodes[i].q >> nodes[i].r >> nodes[i].b;
}
bool flags[101] = { false };
int remains = n;
while(remains > 1){
bool tmpflg[101] = { false };
for(int i = 1; i <= n; i++){
if(flags[i]){ continue; }
if(
(nodes[i].r == 0 && nodes[i].b == 0) ||
(nodes[i].r == 0 && flags[nodes[i].b]) ||
(flags[nodes[i].r] && nodes[i].b == 0) ||
(flags[nodes[i].r] && flags[nodes[i].b])
){
tmpflg[i] = true;
remains--;
}
}
for(int i = 1; i <= n; i++){
flags[i] |= tmpflg[i];
}
}
int root;
for(root = 1; root <= n; root++){
if(!flags[root]){ break; }
}
printf("%d\n", calculate(root));
}
return 0;
} | cc1plus: error: '::main' must return 'int'
|
s001961601 | p00443 | C++ | #include<stdio.h>
#include<cstring>
#define max(a,b) (a>b?a:b)
long long int a[101],b[101],c[101],d[101],memo[101],res=0;
long long int gcd(long long int x,long long int y){
if(x==0)return y;
else return gcd(y%x,x);
}
long long int solve(int x){
if(memo[x]!=0)return memo[x];
int left=a[x]*solve(c[x]),right=b[x]*solve(d[x]),gc;
gc=gcd(left,right);
return memo[x]=right/gc*solve(c[x])+left/gc*solve(d[x]);
}
int main(){
memo[0]=1;
int n;
for(;scanf("%d",&n),n!=0;memset(memo,0,sizeof(memo)){
for(int i=1;i<=n;i++){
scanf("%lld%lld%lld%lld",a+i,b+i,c+i,d+i);
}
for(int i=1;i<=n;i++){
res=max(res,solve(i));
}
printf("%lld\n",res);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:20:61: error: expected ')' before '{' token
20 | for(;scanf("%d",&n),n!=0;memset(memo,0,sizeof(memo)){
| ~ ^
| )
|
s364183060 | p00443 | C++ | #include <cstdio>
using namespace std;
typedef long long ll;
typedef struct stick{
ll lren, rren, sl, sr, weight;
} STICK;
ll n, tmp, top;
ll depth[101];
STICK st[101];
void init(ll k){
for(ll i = 0; i <= k; i++){
depth[i] = 0;
st[i].weight = 0;
}
}
ll gcd(ll a, ll b){
if(b == 0) return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b){
return a * b / gcd(a, b);
}
ll solve(ll k){
if(st[k].weight > 0) return st[k].weight;
if(st[k].sl == 0 && st[k].sr == 0){
return st[k].weight = st[k].lren + st[k].rren;
}else if(st[k].sl == 0){
return st[k].weight = solve(st[k].sr) * (st[k].lren + st[k].rren) / gcd(solve(st[k].sr), st[k].lren);
}else if(st[k]. sr == 0){
return st[k].weight = solve(st[k].sl) * (st[k].lren + st[k].rren) / gcd(solve(st[k].sl), st[k].rren);
}else {
tmp = lcm(solve(st[k].sl) * st[k].lren, solve(st[k].sr) * st[k].rren);
return st[k].weight = tmp / st[k].lren + tmp / st[k].rren;
}
}
ll main(){
while(scanf("%d", &n)){
if(n == 0) break;
init(n);
for(ll i = 1; i <= n; i++){
scanf("%d %d %d %d", &st[i].lren, &st[i].rren, &st[i].sl, &st[i].sr);
tmp = gcd(st[i].lren, st[i].rren);
st[i].lren /= tmp;
st[i].rren /= tmp;
}
for(ll i = 1; i <= n; i++){
depth[st[i].sl]++;
depth[st[i].sr]++;
}
for(ll i = 1; i<= n; i++){
if(depth[i] == 0){
top = i;
break;
}
}
printf("%d\n", solve(top));
}
return 0;
} | a.cc:43:1: error: '::main' must return 'int'
43 | ll main(){
| ^~
|
s042495262 | p00443 | C++ | require 'rational'
class AOJ0520
def initialize(n)
@n = n
@poles = []
end
def solve
@n.times{ @poles << gets.split.map(&:to_i) }
top = ((1..@n).to_a - @poles.map{ |p| [p[2], p[3]] }.flatten)[0]
weight(top-1)
end
def weight(id)
r = (@poles[id][2] == 0 ? 1 : weight(@poles[id][2]-1))
l = (@poles[id][3] == 0 ? 1 : weight(@poles[id][3]-1))
p = @poles[id][0]
q = @poles[id][1]
a = (r*p).lcm(l*q) / q
b = (r*p).lcm(l*q) / p
a+b
end
end
while (n = gets.chomp.to_i) != 0
puts AOJ0520.new(n).solve
end | a.cc:1:9: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
1 | require 'rational'
| ^~~~~~~~~~
a.cc:5:5: error: stray '@' in program
5 | @n = n
| ^
a.cc:6:5: error: stray '@' in program
6 | @poles = []
| ^
a.cc:10:5: error: stray '@' in program
10 | @n.times{ @poles << gets.split.map(&:to_i) }
| ^
a.cc:10:15: error: stray '@' in program
10 | @n.times{ @poles << gets.split.map(&:to_i) }
| ^
a.cc:12:13: error: too many decimal points in number
12 | top = ((1..@n).to_a - @poles.map{ |p| [p[2], p[3]] }.flatten)[0]
| ^~~
a.cc:12:16: error: stray '@' in program
12 | top = ((1..@n).to_a - @poles.map{ |p| [p[2], p[3]] }.flatten)[0]
| ^
a.cc:12:27: error: stray '@' in program
12 | top = ((1..@n).to_a - @poles.map{ |p| [p[2], p[3]] }.flatten)[0]
| ^
a.cc:18:10: error: stray '@' in program
18 | r = (@poles[id][2] == 0 ? 1 : weight(@poles[id][2]-1))
| ^
a.cc:18:42: error: stray '@' in program
18 | r = (@poles[id][2] == 0 ? 1 : weight(@poles[id][2]-1))
| ^
a.cc:19:10: error: stray '@' in program
19 | l = (@poles[id][3] == 0 ? 1 : weight(@poles[id][3]-1))
| ^
a.cc:19:42: error: stray '@' in program
19 | l = (@poles[id][3] == 0 ? 1 : weight(@poles[id][3]-1))
| ^
a.cc:21:9: error: stray '@' in program
21 | p = @poles[id][0]
| ^
a.cc:22:9: error: stray '@' in program
22 | q = @poles[id][1]
| ^
a.cc:1:1: error: 'require' does not name a type
1 | require 'rational'
| ^~~~~~~
a.cc:12:5: error: 'top' does not name a type
12 | top = ((1..@n).to_a - @poles.map{ |p| [p[2], p[3]] }.flatten)[0]
| ^~~
a.cc:12:57: error: expected unqualified-id before '.' token
12 | top = ((1..@n).to_a - @poles.map{ |p| [p[2], p[3]] }.flatten)[0]
| ^
|
s966063028 | p00443 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
int a[100+2],b[100+2],c[100+2],d[100+2],w[100+2],n;
int s(int x){
int ans;
if(w[x]!=-1)return w[x];
else {
int e=a[x]*s(c[x]),f=b[x]*s(d[x]);
int g=e,h=f,gcd;
while(1){
g%=h;
if(g==0)break;
h%=g;
if(h==0)break;
}
gcd=e*f/max(g,h);
ans=gcd/a[x]+gcd/b[x];
}
w[x]=ans;
return ans;
}
int main(){
int an=0,aaa;
scanf("%d",&n);
if(n==0)break;
w[0]=1;
for(int i=1;i<=n;i++){scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]); w[i]=-1;}
for(int i=1;i<=n;i++){
if(w[i]==-1)aaa=s(i);
if(an<w[i])an=w[i];
}
printf("%d\n",an);
} | a.cc: In function 'int main()':
a.cc:28:17: error: break statement not within loop or switch
28 | if(n==0)break;
| ^~~~~
|
s857886301 | p00443 | C++ | //Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int dp[105];
int m[105]={};
int u[105][2]={};
int v[105][2]={};
int a[105]={};
int gcd(int a,int b)
{
if(a%b==0) return b;
return gcd(b,a%b);
}
int main()
{
while(1)
{
scanf("%d",&n);
if(!n) return 0;
queue<int>que;
for(int i=1;i<=n;i++)
{
int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
u[i][0]=c;
u[i][1]=d;
if(c)a[i]++;
if(d)a[i]++;
int di=gcd(a,b);
v[i][0]=a/di;
v[i][1]=b/di;
if(!a[i]) que.push(i);
}
fill(dp,dp+105,1);
int ret;
while(!que.empty())
{
int r=que.front(); que.pop();
int bas=1;
for(int i=0;i<2;i++)
{
if(u[r][i])
{
int f=dp[u[r][i]]/gcd(dp[u[r][i]],v[r][1-i]);
bas=bas/gcd(bas,f)*f;
}
}
dp[r]=bas*(v[r][0]+v[r][1]); ret=dp[r];
for(int i=1;i<=n;i++)
{
if(u[i][0]==r || u[i][1]==r)
{
a[i]--;
if(!a[i]) que.push(i);
}
}
}
printf("%d\n",ret);
}
} | a.cc: In function 'int main()':
a.cc:43:29: error: 'n' was not declared in this scope; did you mean 'yn'?
43 | scanf("%d",&n);
| ^
| yn
a.cc:52:31: error: invalid types 'int[int]' for array subscript
52 | if(c)a[i]++;
| ^
a.cc:53:31: error: invalid types 'int[int]' for array subscript
53 | if(d)a[i]++;
| ^
a.cc:57:30: error: invalid types 'int[int]' for array subscript
57 | if(!a[i]) que.push(i);
| ^
|
s153637864 | p00444 | Java | import java.util.*;
public class AOJ_0521{
void run(){
Scanner sc = new Scanner(System.in);
int[] coins = { 500, 100, 50, 10, 5, 1};
while(true){
int price = sc.nextInt();
if(price == 0){
break;
}
int change = 1000 - price;
int ans = 0;
for(int c: coins){
while(change >= c){
change -= c;
ans++;
}
}
System.out.println(ans);
}
}
public static void main(String[] args){
new AOJ_0521().run();
}
} | Main.java:2: error: class AOJ_0521 is public, should be declared in a file named AOJ_0521.java
public class AOJ_0521{
^
1 error
|
s179461388 | p00444 | Java | import java.util.Scanner;
class Main{
Main(){
Scanner scan = new Scanner(System.in);
while(true){
int yen=scan.nextInt();
if(yen==0){
break;
}
yen=1000-yen;
System.out.println(hantei(yen));
}
}
int[] init(int[] w){
for(int i=0;i<w.length;i++){
w[i]=0;
}
return w;
}
int hantei(int yen){
int coin=0;
if((yen/500)>0){
int a=yen/500;
for(int i=0;i<a;i++){
coin++;
}
yen=yen%500;
}
if((yen/100)>0){
int a=yen/100;
for(int i=0;i<a;i++){
coin++;
}
yen=yen%100;
}
if((yen/50)>0){
int a=yen/50;
for(int i=0;i<a;i++){
coin++;
}
yen=yen%50;
}
if((yen/10)>0){
int a=yen/10;
for(int i=0;i<a;i++){
coin++;
}
yen=yen%10;
}
if((yen/5)>0){
int a=yen/5;
for(int i=0;i<a;i++){
coin++;
}
yen=yen%5;
}
for(int i=0;i<yen;i++){
coin++;
}
return coin;
}
public st | Main.java:72: error: reached end of file while parsing
public st
^
1 error
|
s479829245 | p00444 | Java | public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(true){
int x,ans;
x=cin.nextInt();
if(x==0){
break;
}
x=1000-x;
ans=x/500;
x=x%500;
ans=ans+x/100;
x=x%100;
ans=ans+x/50;
x=x%50;
ans=ans+x/10;
x=x%10;
ans=ans+x;
System.out.println(ans);
}
} | Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args) {
^
(use --enable-preview to enable unnamed classes)
1 error
|
s179320560 | p00444 | C | #include <stdio.h>
int main(){
int g,t,m500,m100,m50,m10,m5,m1,cnt=0;
while(1){
scanf("%d",&g);
if(g==0){
break;
}
t=1000-g;
m500=t/500;
cnt=cnt+m500;
m500=t%500;
m100=m500/100;
cnt=cnt+m100;
m100=m500%100;
m50=m100/50;
cnt=cnt+m50;
m50=m100%50;
m10=m50/10;
cnt=cnt+m10;
m10=m50%10;
m5=m10/5;
cnt=cnt+m5;
m5=m10%5;
m1=m5/1;
cnt=cnt+m1;
printf("%d\n",cnt);
cnt=0;
} | main.c: In function 'main':
main.c:29:3: error: expected declaration or statement at end of input
29 | }
| ^
|
s102873959 | p00444 | C | #include <stdio.h>
int main(void)
{
int daikin;
int oturi;
int maisu = 0;
while( 0){
scanf("%d", &daikin);
oturi = 1000 - daikin;
if(oturi / 500 >= 1){
maisu += oturi / 500;
oturi = oturi % 500;
}
if(oturi / 100 >= 1){
maisu += oturi / 100;
oturi = oturi % 100;
}
if(oturi / 50 >= 1){
maisu += oturi / 50;
oturi = oturi % 50;
}
if(oturi / 10 >= 1){
maisu += oturi/ 10;
oturi = oturi % 10;
}
if(oturi / 5 >= 1){
maisu += oturi / 5;
oturi = oturi % 5;
}
if(oturi / 1 >= 1){
maisu += oturi / 1;
}
if(daikin == 0){
break; }
else {
printf("%d\n", maisu);
}
return 0;
} | main.c: In function 'main':
main.c:46:1: error: expected declaration or statement at end of input
46 | }
| ^
|
s291525978 | p00444 | C | #include <stdio.h>
const int money[] = { 500, 100, 50, 10, 5, 1 };
const int size = sizeof( money ) / sizeof( int );
int main ( void )
{
int x, i, answer = 0;
//while ( 1 ) {
scanf( "%d", &x );
if ( x == 0 ) {
break;
}
x = 1000 - x;
for ( i = 0; i < size; ++i ) {
answer += x / money[i];
x %= money[i];
}
printf( "%d\n", answer );
//}
return 0;
} | main.c: In function 'main':
main.c:13:25: error: break statement not within loop or switch
13 | break;
| ^~~~~
|
s482104696 | p00444 | C | #include <stdio.h>
int main(void)
{
int price;
int change;
int cnt;
int i;
while (scanf("%d", &n) != EOF){
change = 1000 - price;
cnt = 0;
for (i = 100; i > 0; i /= 10){
cnt += change / 5 / i;
change %= 5 * i;
cnt += change / i;
change %= i;
}
printf("%d\n", cnt);
}
return (0);
} | main.c: In function 'main':
main.c:10:25: error: 'n' undeclared (first use in this function)
10 | while (scanf("%d", &n) != EOF){
| ^
main.c:10:25: note: each undeclared identifier is reported only once for each function it appears in
|
s288295298 | p00444 | C | #include <iostream>
using namespace std;
int main(){
int a[6]={500,100,50,10,5,1},input,count,i;
while(1){
cin>>input;
if(input==0){
break;
}
input=1000-input;
for(i=0,count=0;i<6;i++){
if(input/a[i]>0){
count+=input/a[i];
}
input=input-(input/a[i])*a[i];
}
cout<<count<<endl;
}
return 0;
} | main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s789744017 | p00444 | C | #include <stdio.h>
int main()
{
int a , b, c, d, e, f, x;
while(1)
{
scanf("%d", &x);
if( x == 0 )break;
a = (1000 - x) / 500;
b = (1000 - (x+a*500))/100;
c = (1000 - (x+a*500+b*100) / 50;
d = (1000 - (x+a*500+b*100+c*50) / 10;
e = (1000 - (x+a*500+b*100+c*50+d*10) / 5 ;
f = (1000 - (x+a*500+b*100+c*50+d*10+e*5) / 1;
printf("%d\n",a+b+c+d+e+f);
}
return 0;
} | main.c: In function 'main':
main.c:11:40: error: expected ')' before ';' token
11 | c = (1000 - (x+a*500+b*100) / 50;
| ~ ^
| )
main.c:19:1: error: expected declaration or statement at end of input
19 | }
| ^
main.c:19:1: error: expected declaration or statement at end of input
|
s605472397 | p00444 | C | #include <stdio.h>
int main()
{
int a , b, c, d, e, f, x;
while(1)
{
scanf("%d", &x);
if( x == 0 )break;
a = (1000 - x) / 500;
b = (1000 - (x+a*500))/100;
c = (1000 - (x+a*500+b*100) / 50;
d = (1000 - (x+a*500+b*100+c*50) / 10;
e = (1000 - (x+a*500+b*100+c*50+d*10) / 5 ;
f = (1000 - (x+a*500+b*100+c*50+d*10+e*5) / 1;
printf("%d\n",a+b+c+d+e+f);
}
return 0;
} | main.c: In function 'main':
main.c:11:40: error: expected ')' before ';' token
11 | c = (1000 - (x+a*500+b*100) / 50;
| ~ ^
| )
main.c:19:1: error: expected declaration or statement at end of input
19 | }
| ^
main.c:19:1: error: expected declaration or statement at end of input
|
s247449581 | p00444 | C | #include <stdio.h>
int main()
{
int a , b, c, d, e, f, x;
while(1)
{
scanf("%d", &x);
if( x == 0 )break;
a = (1000 - x) / 500;
b = (1000 - (x+a*500))/100;
c = (1000 - (x+a*500+b*100) / 50;
d = (1000 - (x+a*500+b*100+c*50) / 10;
e = (1000 - (x+a*500+b*100+c*50+d*10) / 5 ;
f = (1000 - (x+a*500+b*100+c*50+d*10+e*5) / 1;
printf("%d\n",a+b+c+d+e+f);
}
return 0;
} | main.c: In function 'main':
main.c:11:40: error: expected ')' before ';' token
11 | c = (1000 - (x+a*500+b*100) / 50;
| ~ ^
| )
main.c:19:1: error: expected declaration or statement at end of input
19 | }
| ^
main.c:19:1: error: expected declaration or statement at end of input
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.