submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 3
values | code
stringlengths 1
522k
| compiler_output
stringlengths 43
10.2k
|
|---|---|---|---|---|
s297158111
|
p04048
|
Java
|
vimport java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
public class Main {
static PrintWriter out;
static InputReader ir;
static boolean debug = false;
static void solve() {
long n = ir.nextLong();
long x = ir.nextLong();
long res = n;
long a = n - x;
long b = x;
while (a != 0 && b != 0) {
if (a < b) {
long tmp = a;
a = b;
b = tmp;
}
long d = a / b;
res += d * 2 * b;
a %= b;
}
out.println(res - Math.max(a, b));
}
public static void main(String[] args) {
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;
}
}
static void tr(Object... o) {
if (debug)
out.println(Arrays.deepToString(o));
}
}
|
Main.java:1: error: class, interface, enum, or record expected
vimport java.io.IOException;
^
Main.java:2: error: class, interface, enum, or record expected
import java.io.InputStream;
^
Main.java:3: error: class, interface, enum, or record expected
import java.io.PrintWriter;
^
Main.java:4: error: class, interface, enum, or record expected
import java.util.Arrays;
^
Main.java:5: error: class, interface, enum, or record expected
import java.util.InputMismatchException;
^
Main.java:6: error: class, interface, enum, or record expected
import java.util.NoSuchElementException;
^
6 errors
|
s643726217
|
p04048
|
Java
|
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long int n = sc.nextInt();
n++;
long int x = sc.nextInt();
//1:point 0:not point
long int field[][] = new int[n][2*n-1];
for(long int i=0; i<n; i++){
for(long int j=0; j<2*n-1; j++){
if((i+j)%2==0){
if((i<=j && j<n)||(i<=(2*n-2-j) && j>=n)){
field[i][j] = 1;
}
else{
field[i][j] = 0;
}
}
else{
field[i][j] = 0;
}
}
}
//10:ab 20:bc 30:ca 40:corner
field[0][0] = field[0][0] + 40;
field[0][2*n-2] = field[0][2*n-2] + 40;
field[n-1][n-1] = field[n-1][n-1] + 40;
for(long int i=0; i<n; i++){
for(long int j=0; j<2*n-1; j++){
if(i==0 && field[i][j]==1){
field[i][j] = field[i][j] + 20;
}
else if(i==j && field[i][j]==1){
field[i][j] = field[i][j] + 10;
}
else if(i==2*n-2-j && field[i][j]==1){
field[i][j] = field[i][j] + 30;
}
}
}
//light[i, j, vec]
long int light[] = {n-x, n-x, 20};
field[n-x][n-x] = field[n-x][n-x] + 30;
long int ans = 0;
while(true){
if(Math.abs(light[2])==10){
if(light[2]>0){
light[0] += -1;
light[1] += -1;
}
else{
light[0] += 1;
light[1] += 1;
}
}
else if(Math.abs(light[2])==20){
if(light[2]>0){
light[1] += 2;
}
else{
light[1] += -2;
}
}
else{
if(light[2]>0){
light[0] += 1;
light[1] += -1;
}
else{
light[0] += -1;
light[1] += 1;
}
}
ans ++;
if(field[light[0]][light[1]]>=40){
break;
}
else if(field[light[0]][light[1]]>=30){
field[light[0]][light[1]] = 41;
if(Math.abs(light[2])==10){
light[2] = 20*(long int)Math.signum(light[2]);
}
else{
light[2] = 10*(long int)Math.signum(light[2]);
}
}
else if(field[light[0]][light[1]]>=20){
field[light[0]][light[1]] = 41;
if(Math.abs(light[2])==10){
light[2] = 30*(long int)Math.signum(light[2]);
}
else{
light[2] = 10*(long int)Math.signum(light[2]);
}
}
else if(field[light[0]][light[1]]>=10){
field[light[0]][light[1]] = 41;
if(Math.abs(light[2])==20){
light[2] = 30*(long int)Math.signum(light[2]);
}
else{
light[2] = 20*(long int)Math.signum(light[2]);
}
}
else{
field[light[0]][light[1]] = light[2] + 1;
}
}
System.out.println(ans);
}
}
|
Main.java:5: error: not a statement
long int n = sc.nextInt();
^
Main.java:5: error: ';' expected
long int n = sc.nextInt();
^
Main.java:7: error: not a statement
long int x = sc.nextInt();
^
Main.java:7: error: ';' expected
long int x = sc.nextInt();
^
Main.java:9: error: not a statement
long int field[][] = new int[n][2*n-1];
^
Main.java:9: error: ';' expected
long int field[][] = new int[n][2*n-1];
^
Main.java:10: error: not a statement
for(long int i=0; i<n; i++){
^
Main.java:10: error: ';' expected
for(long int i=0; i<n; i++){
^
Main.java:10: error: '.class' expected
for(long int i=0; i<n; i++){
^
Main.java:10: error: ')' expected
for(long int i=0; i<n; i++){
^
Main.java:10: error: > or ',' expected
for(long int i=0; i<n; i++){
^
Main.java:10: error: not a statement
for(long int i=0; i<n; i++){
^
Main.java:10: error: ';' expected
for(long int i=0; i<n; i++){
^
Main.java:11: error: not a statement
for(long int j=0; j<2*n-1; j++){
^
Main.java:11: error: ';' expected
for(long int j=0; j<2*n-1; j++){
^
Main.java:11: error: '.class' expected
for(long int j=0; j<2*n-1; j++){
^
Main.java:11: error: ')' expected
for(long int j=0; j<2*n-1; j++){
^
Main.java:11: error: illegal start of type
for(long int j=0; j<2*n-1; j++){
^
Main.java:11: error: not a statement
for(long int j=0; j<2*n-1; j++){
^
Main.java:11: error: not a statement
for(long int j=0; j<2*n-1; j++){
^
Main.java:11: error: ';' expected
for(long int j=0; j<2*n-1; j++){
^
Main.java:29: error: not a statement
for(long int i=0; i<n; i++){
^
Main.java:29: error: ';' expected
for(long int i=0; i<n; i++){
^
Main.java:29: error: '.class' expected
for(long int i=0; i<n; i++){
^
Main.java:29: error: ')' expected
for(long int i=0; i<n; i++){
^
Main.java:29: error: > or ',' expected
for(long int i=0; i<n; i++){
^
Main.java:29: error: not a statement
for(long int i=0; i<n; i++){
^
Main.java:29: error: ';' expected
for(long int i=0; i<n; i++){
^
Main.java:30: error: not a statement
for(long int j=0; j<2*n-1; j++){
^
Main.java:30: error: ';' expected
for(long int j=0; j<2*n-1; j++){
^
Main.java:30: error: '.class' expected
for(long int j=0; j<2*n-1; j++){
^
Main.java:30: error: ')' expected
for(long int j=0; j<2*n-1; j++){
^
Main.java:30: error: illegal start of type
for(long int j=0; j<2*n-1; j++){
^
Main.java:30: error: not a statement
for(long int j=0; j<2*n-1; j++){
^
Main.java:30: error: not a statement
for(long int j=0; j<2*n-1; j++){
^
Main.java:30: error: ';' expected
for(long int j=0; j<2*n-1; j++){
^
Main.java:43: error: not a statement
long int light[] = {n-x, n-x, 20};
^
Main.java:43: error: ';' expected
long int light[] = {n-x, n-x, 20};
^
Main.java:45: error: not a statement
long int ans = 0;
^
Main.java:45: error: ';' expected
long int ans = 0;
^
Main.java:82: error: ')' expected
light[2] = 20*(long int)Math.signum(light[2]);
^
Main.java:82: error: '.class' expected
light[2] = 20*(long int)Math.signum(light[2]);
^
Main.java:85: error: ')' expected
light[2] = 10*(long int)Math.signum(light[2]);
^
Main.java:85: error: '.class' expected
light[2] = 10*(long int)Math.signum(light[2]);
^
Main.java:91: error: ')' expected
light[2] = 30*(long int)Math.signum(light[2]);
^
Main.java:91: error: '.class' expected
light[2] = 30*(long int)Math.signum(light[2]);
^
Main.java:94: error: ')' expected
light[2] = 10*(long int)Math.signum(light[2]);
^
Main.java:94: error: '.class' expected
light[2] = 10*(long int)Math.signum(light[2]);
^
Main.java:100: error: ')' expected
light[2] = 30*(long int)Math.signum(light[2]);
^
Main.java:100: error: '.class' expected
light[2] = 30*(long int)Math.signum(light[2]);
^
Main.java:103: error: ')' expected
light[2] = 20*(long int)Math.signum(light[2]);
^
Main.java:103: error: '.class' expected
light[2] = 20*(long int)Math.signum(light[2]);
^
52 errors
|
s532517104
|
p04048
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, x, t;
int32_t main(){
scanf("%lld %lld", &n, &x);
t = 3*(n-1);
if(t&1) return !printf(t);
printf("%lld", t-3*(min(x, n-x)-1));
}
|
a.cc: In function 'int32_t main()':
a.cc:8:28: error: invalid conversion from 'long long int' to 'const char*' [-fpermissive]
8 | if(t&1) return !printf(t);
| ^
| |
| long long int
In file included from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/stdio.h:363:43: note: initializing argument 1 of 'int printf(const char*, ...)'
363 | extern int printf (const char *__restrict __format, ...);
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
|
s451435321
|
p04048
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[100],b=0;
cin>>a[0]>>a[1];
int i=1
for(;;i++){
a[i+1]=a[i-1]%a[i];
if(a[i]<a[i+1])swap(a[i],a[i+1]);
if(a[i+1]==0) break;
}
for(int j=1;j<i;j+=2) b+=a[j];
cout<<b<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:7:5: error: expected ',' or ';' before 'for'
7 | for(;;i++){
| ^~~
a.cc:7:14: error: expected ';' before ')' token
7 | for(;;i++){
| ^
| ;
|
s098648558
|
p04048
|
C++
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x;
inline ll gcd(ll a,ll b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
cin>>n>>x;
cout<<3*(n-gcd(n,x));
return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x;
inline ll gcd(ll a,ll b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
cin>>n>>x;
cout<<3*(n-gcd(n,x));
return 0;
}
|
a.cc:18:4: error: redefinition of 'll n'
18 | ll n,x;
| ^
a.cc:4:4: note: 'll n' previously declared here
4 | ll n,x;
| ^
a.cc:18:6: error: redefinition of 'll x'
18 | ll n,x;
| ^
a.cc:4:6: note: 'll x' previously declared here
4 | ll n,x;
| ^
a.cc:19:11: error: redefinition of 'll gcd(ll, ll)'
19 | inline ll gcd(ll a,ll b)
| ^~~
a.cc:5:11: note: 'll gcd(ll, ll)' previously defined here
5 | inline ll gcd(ll a,ll b)
| ^~~
a.cc:23:5: error: redefinition of 'int main()'
23 | int main()
| ^~~~
a.cc:9:5: note: 'int main()' previously defined here
9 | int main()
| ^~~~
|
s895623471
|
p04048
|
C++
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x;
inline ll gcd(ll a,ll b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
cin>>n>>x;
cout<<3*(n-gcd(n,x));
return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x;
inline ll gcd(ll a,ll b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
cin>>n>>x;
cout<<3*(n-gcd(n,x));
return 0;
}
Submission
|
a.cc:18:4: error: redefinition of 'll n'
18 | ll n,x;
| ^
a.cc:4:4: note: 'll n' previously declared here
4 | ll n,x;
| ^
a.cc:18:6: error: redefinition of 'll x'
18 | ll n,x;
| ^
a.cc:4:6: note: 'll x' previously declared here
4 | ll n,x;
| ^
a.cc:19:11: error: redefinition of 'll gcd(ll, ll)'
19 | inline ll gcd(ll a,ll b)
| ^~~
a.cc:5:11: note: 'll gcd(ll, ll)' previously defined here
5 | inline ll gcd(ll a,ll b)
| ^~~
a.cc:23:5: error: redefinition of 'int main()'
23 | int main()
| ^~~~
a.cc:9:5: note: 'int main()' previously defined here
9 | int main()
| ^~~~
a.cc:29:1: error: 'Submission' does not name a type
29 | Submission
| ^~~~~~~~~~
|
s355071731
|
p04048
|
C++
|
#include <iostream>
using namespace std;
int gcd(LLI a,LLI b){
if(a==0||b==0) return a+b;
else if(a>=b) return gcd(a%b,b);
else return gcd(a,b%a);
}
int main(){
LLI n,x; cin>>n>>x;
cout<<3*(n-gcd(n,x));
}
|
a.cc:3:9: error: 'LLI' was not declared in this scope
3 | int gcd(LLI a,LLI b){
| ^~~
a.cc:3:15: error: 'LLI' was not declared in this scope
3 | int gcd(LLI a,LLI b){
| ^~~
a.cc:3:20: error: expression list treated as compound expression in initializer [-fpermissive]
3 | int gcd(LLI a,LLI b){
| ^
a.cc: In function 'int main()':
a.cc:9:5: error: 'LLI' was not declared in this scope
9 | LLI n,x; cin>>n>>x;
| ^~~
a.cc:9:19: error: 'n' was not declared in this scope
9 | LLI n,x; cin>>n>>x;
| ^
a.cc:9:22: error: 'x' was not declared in this scope
9 | LLI n,x; cin>>n>>x;
| ^
a.cc:10:19: error: 'gcd' cannot be used as a function
10 | cout<<3*(n-gcd(n,x));
| ~~~^~~~~
|
s683952697
|
p04048
|
C++
|
#include<stdio.h>
#include<algorithm>
long n,m,a;
main(){
scanf("%ld%ld",&n,&m);
a=3*(n-std::__gcd(n,m);
printf("%ld",a);
}
|
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:8:27: error: expected ')' before ';' token
8 | a=3*(n-std::__gcd(n,m);
| ~ ^
| )
|
s488825638
|
p04048
|
C++
|
#include<stdio.h>
#include<algorithm>
long n,m,a;
main(){
scanf("%ld%ld",&n,&m);
a=3*(n-std::__gcd(n,m);
printf("%ld",a);
}
|
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:8:27: error: expected ')' before ';' token
8 | a=3*(n-std::__gcd(n,m);
| ~ ^
| )
|
s626955073
|
p04048
|
C++
|
#include<bits/stdc++.h>
long n,m;main(){std::cin>>n>>m;std::cout<<3*(n-__gcd(n,m));}
|
a.cc:2:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
2 | long n,m;main(){std::cin>>n>>m;std::cout<<3*(n-__gcd(n,m));}
| ^~~~
a.cc: In function 'int main()':
a.cc:2:48: error: '__gcd' was not declared in this scope
2 | long n,m;main(){std::cin>>n>>m;std::cout<<3*(n-__gcd(n,m));}
| ^~~~~
a.cc:2:48: note: suggested alternatives:
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:1137:5: note: 'std::__gcd'
1137 | __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58:
/usr/include/c++/14/numeric:134:5: note: 'std::__detail::__gcd'
134 | __gcd(_Tp __m, _Tp __n)
| ^~~~~
|
s533036074
|
p04048
|
C++
|
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long n = 0, length = 0;
void Go_Ray(long long rayActual, long long rayPasado)
{
if (rayActual == rayPasado)
{
length += rayActual;
return;
}
if (rayPasado < rayActual)
{
length += (2 * rayPasado);
Go_Ray(rayPasado, rayActual - rayPasado);
}
else
{
length += (2 * rayActual);
Go_Ray(rayActual, rayPasado - rayActual);
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
long long x;
cin >> n >> x;
length = n;
Go_Ray(n - x,x);
cout << length << endl;
return 0;
|
a.cc: In function 'int main()':
a.cc:36:14: error: expected '}' at end of input
36 | return 0;
| ^
a.cc:28:1: note: to match this '{'
28 | {
| ^
|
s137262786
|
p04048
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
LL n, x;
LL f(LL a, LL b) {
if(a > b) swap(a, b);
if(a == 1) return b * 2 - 1;
return 1ll * f(b - a, a) + 2 * a;
}
LL ans;
int main(){
scanf("%lld %lld", &n, &x);
ans = n + f(x, n - x)
printf("%lld\n", ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:15:30: error: expected ';' before 'printf'
15 | ans = n + f(x, n - x)
| ^
| ;
16 | printf("%lld\n", ans);
| ~~~~~~
|
s891643852
|
p04048
|
C++
|
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
#ifdef HOME
freopen("agc1b.in", "r", stdin);
freopen("agc1b.out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
i64 sum(0);
int a, b;
cin >> a >> b;
a = a - b;
sum = a + b;
while (a && b) {
if (a > b)
sum+= a / b * b * 2, a%= b;
else
sum+= b / a * a * l, b%= a; }
cout << sum - a - b << endl;
return 0; }
|
a.cc: In function 'int main()':
a.cc:24:43: error: 'l' was not declared in this scope
24 | sum+= b / a * a * l, b%= a; }
| ^
|
s687226338
|
p04048
|
C++
|
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
signed main(){
int n, x;
cin >> n >> x;
if(n == 2 * x)
cout << 3 * x << endl;
else if(n % x != 0 && (n % 2 == 1 || x % 2 == 1))
cout << n + n - 1 + n - 2 << endl;
else{
int amari = n % x;
int va = n - amari;
cout << 3 * va - 3 * amari << endl;
}
|
a.cc: In function 'int main()':
a.cc:27:2: error: expected '}' at end of input
27 | }
| ^
a.cc:12:14: note: to match this '{'
12 | signed main(){
| ^
|
s495543192
|
p04048
|
C++
|
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
signed main(){
int n, x;
cin >> n >> x;
if(n == 2 * x)
cout << 3 * x << endl;
else if(n % 3 != 0 && (n % 2 == 1 || x % 2 == 1))
cout << n + n - 1 + n - 2 << endl;
else{
int amari = n % x;
int va = n - amari;
cout << 3 * va - 3 * amari << endl;
}
|
a.cc: In function 'int main()':
a.cc:27:2: error: expected '}' at end of input
27 | }
| ^
a.cc:12:14: note: to match this '{'
12 | signed main(){
| ^
|
s440481416
|
p04048
|
C++
|
#include <iostream>
using namespace std;
int main(){
int n,x,s=0;
cin >>n;
cin >>x;
while(x!=0){
s+=x;
if( x>n-x)
{
int a=x;
x=t-x;
t=a;
}
else
{
x=t-x;
}
cout <<s;
}
}
|
a.cc: In function 'int main()':
a.cc:13:27: error: 't' was not declared in this scope
13 | x=t-x;
| ^
a.cc:18:27: error: 't' was not declared in this scope
18 | x=t-x;
| ^
|
s387961476
|
p04048
|
C++
|
#include <iostream>
using namesspace std;
int main(){
int n,x,s=0;
cin >>n;
cin >>x;
while(x!=0){
s+=x;
if( x>n-x)
{
int a=x;
x=t-x;
t=a;
}
else
{
x=t-x;
}
cout <<s;
}
}
|
a.cc:2:7: error: expected nested-name-specifier before 'namesspace'
2 | using namesspace std;
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:5:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
5 | cin >>n;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:13:27: error: 't' was not declared in this scope
13 | x=t-x;
| ^
a.cc:18:27: error: 't' was not declared in this scope
18 | x=t-x;
| ^
a.cc:20:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
20 | cout <<s;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
|
s338211058
|
p04048
|
C++
|
#include <bits/stdc++.h>
long long n, x;
int main() {
scanf("%lld%lld", &n, &x);
printf("%lld\n", 3 * (n - __gcd(n, x)));
return 0;
}
|
a.cc: In function 'int main()':
a.cc:7:29: error: '__gcd' was not declared in this scope
7 | printf("%lld\n", 3 * (n - __gcd(n, x)));
| ^~~~~
a.cc:7:29: note: suggested alternatives:
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:1137:5: note: 'std::__gcd'
1137 | __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58:
/usr/include/c++/14/numeric:134:5: note: 'std::__detail::__gcd'
134 | __gcd(_Tp __m, _Tp __n)
| ^~~~~
|
s400184207
|
p04048
|
C++
|
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned long long
#define ls x << 1
#define rs x << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
int x = 0, f = 1; char ch = getchar();
while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
return x * f;
}
ll dfs(ll a,ll b)
{
if(a > b) swap(a, b);
if(b % a == 0) return (a * ((b / a) * 2 - 1));
ll res = get(a, b % a) + (a + a) * (b / a);
return res;
}
ll n,x;
int main(void)
{
scanf("%lld%lld", &n, &x);
if(n == x * 2) printf("%lld\n", x * 3);
else
{
ll ans = 0;
if(x * 2 < n)
{
ans = x + (n - x) + x + x;
ans += dfs(x, n - 2 * x);
}
else
{
ans = x + n - x;
ans += dfs(x, n - x);
}
printf("%lld\n", ans);
}
return 0;
}
|
a.cc: In function 'long long int dfs(long long int, long long int)':
a.cc:29:21: error: no matching function for call to 'get(long long int&, long long int)'
29 | ll res = get(a, b % a) + (a + a) * (b / a);
| ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
1250 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
1255 | get(pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
1260 | get(const pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
1265 | get(const pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
2445 | get(tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2445:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
2451 | get(const tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2451:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
2457 | get(tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2457:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
2466 | get(const tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2466:5: note: candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/functional:65,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/array:390:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
390 | get(array<_Tp, _Nm>& __arr) noexcept
| ^~~
/usr/include/c++/14/array:390:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/array:399:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)'
399 | get(array<_Tp, _Nm>&& __arr) noexcept
| ^~~
/usr/include/c++/14/array:399:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/array:408:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const array<_Tp, _Nm>&)'
408 | get(const array<_Tp, _Nm>& __arr) noexcept
| ^~~
/usr/include/c++/14/array:408:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/array:417:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const array<_Tp, _Nm>&&)'
417 | get(const array<_Tp, _Nm>&& __arr) noexcept
| ^~~
/usr/include/c++/14/array:417:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)'
1272 | get(pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)'
1277 | get(const pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_T1, _T2>&&)'
1282 | get(pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_T1, _T2>&&)'
1287 | get(const pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_Up, _Tp>&)'
1292 | get(pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_Up, _Tp>&)'
1297 | get(const pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_Up, _Tp>&&)'
1302 | get(pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_Up, _Tp>&&)'
1307 | get(const pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2476:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&)' (deleted)
2476 | get(const tuple<_Elements...>&) = delete;
| ^~~
/usr/include/c++/14/tuple:2476:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2483:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(tuple<_Elements ...>&)'
2483 | get(tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2483:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2494:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(tuple<_Elements ...>&&)'
2494 | get(tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2494:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2505:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const tuple<_Elements ...>&)'
2505 | get(const tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2505:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2517:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const tuple<_Elements ...>&&)'
2517 | get(const tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2517:5: note: candidate expects 1 argument, 2 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80:
/usr/include/c++/14/variant:1715:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(variant<_Types ...>&)'
1715 | get(variant<_Types...>& __v)
| ^~~
/usr/include/c++/14/variant:1715:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/variant:1726:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(variant<_Types ...>&&)'
1726 | get(variant<_Types...>&& __v)
| ^~~
/usr/include/c++/14/variant:1726:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/variant:1737:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(const variant<_Types ...>&)'
1737 | get(const variant<_Types...>& __v)
| ^~~
/usr/include/c++/14/variant:1737:5: note: candidate expects 1 argument, 2 p
|
s467629674
|
p04048
|
C++
|
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned long long
#define ls x << 1
#define rs x << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
int x = 0, f = 1; char ch = getchar();
while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
return x * f;
}
ll dfs(ll a,ll b)
{
if(a > b) swap(a, b);
if(b % a == 0) return (a * ((b / a) * 2 - 1));
ll res = get(a, b % a) + (a + a) * (b / a);
return res;
}
ll n,x;
int main(void)
{
scanf("%lld%lld", &n, &x);
if(n == x * 2) printf("%lld\n", x * 3);
else
{
ll ans = 0;
if(x * 2 < n)
{
ans = x + (n - x) + x + x;
ans += dfs(x, n - 2 * x);
}
else
{
ans = x + n - x;
ans += dfs(x, n - x);
}
printf("%lld\n", ans);
}
return 0;
}
|
a.cc: In function 'long long int dfs(long long int, long long int)':
a.cc:29:21: error: no matching function for call to 'get(long long int&, long long int)'
29 | ll res = get(a, b % a) + (a + a) * (b / a);
| ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
1250 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
1255 | get(pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
1260 | get(const pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
1265 | get(const pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
2445 | get(tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2445:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
2451 | get(const tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2451:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
2457 | get(tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2457:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
2466 | get(const tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2466:5: note: candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/functional:65,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/array:390:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
390 | get(array<_Tp, _Nm>& __arr) noexcept
| ^~~
/usr/include/c++/14/array:390:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/array:399:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)'
399 | get(array<_Tp, _Nm>&& __arr) noexcept
| ^~~
/usr/include/c++/14/array:399:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/array:408:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const array<_Tp, _Nm>&)'
408 | get(const array<_Tp, _Nm>& __arr) noexcept
| ^~~
/usr/include/c++/14/array:408:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/array:417:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const array<_Tp, _Nm>&&)'
417 | get(const array<_Tp, _Nm>&& __arr) noexcept
| ^~~
/usr/include/c++/14/array:417:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)'
1272 | get(pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)'
1277 | get(const pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_T1, _T2>&&)'
1282 | get(pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_T1, _T2>&&)'
1287 | get(const pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_Up, _Tp>&)'
1292 | get(pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_Up, _Tp>&)'
1297 | get(const pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_Up, _Tp>&&)'
1302 | get(pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_Up, _Tp>&&)'
1307 | get(const pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2476:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&)' (deleted)
2476 | get(const tuple<_Elements...>&) = delete;
| ^~~
/usr/include/c++/14/tuple:2476:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2483:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(tuple<_Elements ...>&)'
2483 | get(tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2483:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2494:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(tuple<_Elements ...>&&)'
2494 | get(tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2494:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2505:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const tuple<_Elements ...>&)'
2505 | get(const tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2505:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2517:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const tuple<_Elements ...>&&)'
2517 | get(const tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2517:5: note: candidate expects 1 argument, 2 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80:
/usr/include/c++/14/variant:1715:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(variant<_Types ...>&)'
1715 | get(variant<_Types...>& __v)
| ^~~
/usr/include/c++/14/variant:1715:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/variant:1726:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(variant<_Types ...>&&)'
1726 | get(variant<_Types...>&& __v)
| ^~~
/usr/include/c++/14/variant:1726:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/variant:1737:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(const variant<_Types ...>&)'
1737 | get(const variant<_Types...>& __v)
| ^~~
/usr/include/c++/14/variant:1737:5: note: candidate expects 1 argument, 2 p
|
s787945613
|
p04048
|
C++
|
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int a,b;cin>>a>>b;
cout<<3*(a-_gcd(a,b))<<endl;
}
|
a.cc: In function 'int main()':
a.cc:7:12: error: '_gcd' was not declared in this scope
7 | cout<<3*(a-_gcd(a,b))<<endl;
| ^~~~
|
s084986561
|
p04048
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,x) for(int i=0;i<x;++i)
int calc(int a, int b)
{
if (a < b) swap(a, b);
if (a == b) return a;
return 2 * b + calc(b, a - b);
}
int main()
{
int N, X; cin >> N >> X;
cout << N + calc(X, N - X) << endl;
}
|
cc1plus: error: '::main' must return 'int'
|
s143266882
|
p04048
|
Java
|
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.Scanner;
public class Main
{
private enum Direction
{
FLT, ASC, DSC
}
private static class Vertex
{
static AtomicLong counter = new AtomicLong(0);
final long index = counter.incrementAndGet();
Edge in;
Edge out;
long trace(Direction inboundDirection)
{
long result = 0;
Direction reflectedDirection = this.out.reflect(inboundDirection);
// Form a triangle..
if (getNextClockwiseEdge().dir != reflectedDirection && getNextClockwiseEdge().len > this.out.len)
{
// Triangle is formed from clockwise rotation
long triangleSideLegth = this.out.len;
Vertex newVertex = new Vertex();
getNextClockwiseEdge().setFrom(newVertex);
getNextClockwiseEdge().len = getNextClockwiseEdge().len - triangleSideLegth;
this.out = new Edge(this, newVertex, triangleSideLegth, reflectedDirection);
result += triangleSideLegth;
result += newVertex.trace(reflectedDirection);
}
else if (getNextCounterClockwiseEdge().dir != reflectedDirection && getNextCounterClockwiseEdge().len > this.in.len)
{
// Triangle is formed from counterclockwise rotation
// Reverse the graph..
this.in.reverseGraph();
long triangleSideLegth = this.out.len;
Vertex newVertex = new Vertex();
getNextClockwiseEdge().setFrom(newVertex);
getNextClockwiseEdge().len = getNextClockwiseEdge().len - triangleSideLegth;
this.out = new Edge(this, newVertex, triangleSideLegth, reflectedDirection);
result += triangleSideLegth;
result += newVertex.trace(reflectedDirection);
}
else
{
// Need to double check that this is correct
if (getNextCounterClockwiseEdge().len == getNextClockwiseEdge().len)
return getNextCounterClockwiseEdge().len;
else
throw new RuntimeException("WhatTheHackException");
}
return result;
}
Edge getNextClockwiseEdge()
{
return out.to.out;
}
Edge getNextCounterClockwiseEdge()
{
return in.from.in;
}
public String toString()
{
return Long.toString(index);
}
}
private static class Edge
{
static AtomicInteger counter = new AtomicInteger(0);
final int index = counter.incrementAndGet();
Vertex from;
Vertex to;
long len;
Direction dir;
public Edge(Vertex f, Vertex t, long len, Direction direction)
{
this.from = f;
this.from.out = this;
this.to = t;
this.to.in = this;
this.len = len;
this.dir = direction;
}
void setTo(Vertex to)
{
this.to = to;
this.to.in = this;
}
void setFrom(Vertex from)
{
this.from = from;
this.from.out = this;
}
Direction reflect(Direction direction)
{
if (this.dir == Direction.FLT)
{
if (direction == Direction.ASC)
return Direction.DSC;
else if (direction == Direction.DSC)
return Direction.ASC;
else
throw new IllegalArgumentException("Kwap");
}
else if (this.dir == Direction.ASC)
{
if (direction == Direction.FLT)
return Direction.DSC;
else if (direction == Direction.DSC)
return Direction.FLT;
else
throw new IllegalArgumentException("Kwap");
}
else if (this.dir == Direction.DSC)
{
if (direction == Direction.FLT)
return Direction.ASC;
else if (direction == Direction.ASC)
return Direction.DSC;
else
throw new IllegalArgumentException("Kwap");
}
else
throw new IllegalArgumentException("Kwap");
}
void reverseGraph()
{
Edge nextEdge = to.out;
Vertex origFrom = this.from;
this.from = this.to;
this.to = origFrom;
this.to.in = this;
this.from.out = this;
if (nextEdge.to != this.from)
nextEdge.reverseGraph();
}
public String toString()
{
return Long.toString(index);
}
}
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
long n = scan.nextLong();
long x = scan.nextLong();
System.out.println(getRayLength(x,n));
}
private static long getRayLength(long X, long N)
{
Vertex v1 = new Vertex();
Vertex v2 = new Vertex();
Vertex v3 = new Vertex();
Vertex v4 = new Vertex();
Edge e1 = new Edge(v1, v2, N - X, Direction.ASC);
Edge e2 = new Edge(v2, v3, X, Direction.FLT);
Edge e3 = new Edge(v3, v4, N - X, Direction.DSC);
Edge e4 = new Edge(v4, v1, N, Direction.FLT);
return e2.len + v3.trace(Direction.FLT);
}
}
|
Main.java:4: error: cannot find symbol
import java.util.concurrent.Scanner;
^
symbol: class Scanner
location: package java.util.concurrent
Main.java:164: error: cannot find symbol
Scanner scan = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:164: error: cannot find symbol
Scanner scan = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
3 errors
|
s641512046
|
p04048
|
C++
|
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include "math.h"
#include <complex>
#include <iomanip>
#define ifor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex <double> P;
const double eps = 1e-11;
int vex[4]={1,0,-1,0};
int vey[4]={0,1,0,-1};
int gcd(int a,int b){
if(a%b == 0)return b;
return gcd(b,a%b);
}
int main(){
int N ,X;
cin >> N >> X;
cout << 3(N-gcd(N,X))<<endl;
return 0 ;
}
|
a.cc: In function 'int main()':
a.cc:28:18: error: expression cannot be used as a function
28 | cout << 3(N-gcd(N,X))<<endl;
| ~^~~~~~~~~~~~
|
s742212888
|
p04048
|
C++
|
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include "math.h"
#include <complex>
#include <iomanip>
#define ifor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex <double> P;
const double eps = 1e-11;
int vex[4]={1,0,-1,0};
int vey[4]={0,1,0,-1};
int gcd(int a,int b){
if(a%b == 0)return b;
return gcd(b,a%b);
}
int main(){
int N ,X;
cin >> N >> X;
cout << 3(N-gcd(N,X))<<endl;
return 0 ;
}
|
a.cc: In function 'int main()':
a.cc:28:18: error: expression cannot be used as a function
28 | cout << 3(N-gcd(N,X))<<endl;
| ~^~~~~~~~~~~~
|
s778307210
|
p04048
|
C++
|
#include<stdio.h>
int main(){
long long n, k;
scanf("%lld %lld", &n, &k);
long long r=n%k;
long long res=n;
while(r>0){
res+=(n/k-1)*k
n=k;k=r;r=n%k;
}
res+=(k-1)*2+1;
printf("%lld", res);
}
|
a.cc: In function 'int main()':
a.cc:8:16: error: expected ';' before 'n'
8 | res+=(n/k-1)*k
| ^
| ;
9 | n=k;k=r;r=n%k;
| ~
|
s930046833
|
p04048
|
C++
|
#include <iostream>
using namespace std;
int main()
{
|
a.cc: In function 'int main()':
a.cc:4:2: error: expected '}' at end of input
4 | {
| ~^
|
s492967325
|
p04048
|
C++
|
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <sstream>
#include <cmath>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
typedef pair<int, int> Pii;
typedef vector<int> V;
typedef long long ll;
const int inf = 1e9;
const int mod = 1e9 + 7;
ll gcd(ll a, ll b) {
if(a%b==0) return b;
return gcd(b,a%b);
}
int main()
{
ll N, X;
cin >> N >> X;
cout << 3*(N - gcd(N,X)) << endl;
retur
|
a.cc: In function 'int main()':
a.cc:34:9: error: 'retur' was not declared in this scope
34 | retur
| ^~~~~
a.cc:34:14: error: expected '}' at end of input
34 | retur
| ^
a.cc:28:1: note: to match this '{'
28 | {
| ^
|
s346632065
|
p04048
|
C
|
#include<stdio.h>
int main()
{
long N, X;
scanf("%ld %ld", &N, &X);
long L = X > N - X ? X : N - X;
long S = N - L;
printf("%ld\n",(N + f(L, S)));
return 0;
}
long f(long L, long S) {
if (S == 0) return -L;
return 2 * S * (L / S) + f(S, L % S);
}
|
main.c: In function 'main':
main.c:8:25: error: implicit declaration of function 'f' [-Wimplicit-function-declaration]
8 | printf("%ld\n",(N + f(L, S)));
| ^
main.c: At top level:
main.c:11:6: error: conflicting types for 'f'; have 'long int(long int, long int)'
11 | long f(long L, long S) {
| ^
main.c:8:25: note: previous implicit declaration of 'f' with type 'int()'
8 | printf("%ld\n",(N + f(L, S)));
| ^
|
s902210176
|
p04048
|
C++
|
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#define ll long long
#define VL vector<ll>
#define VI vector<int>
#define FOR(i,b) for(int i= 0; i<((int)b); ++i)
#define FOR_(i,a,b) for(int i= a; i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define COUT(x) cout << x << endl;
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define EPS 1e-14
#define DIM2(R,C,arr) vector<vector<int>> arr(R);FOR(i,R) (arr)[i].resize(C);
#define DIM2INIT(R,C,arr) FOR(i,R)FOR(j,C)arr[i][j]=0;
#define MAPGEN(R,C,visited,map) char map[R][C]; FOR(i,R){string s;cin>>s;FOR(j,C){visited[i][j]=0;map[i][j]=s[j];}}
#define Point pair<int,int>
#define POINT(x,y,arr) arr[y][x]
#define SORT(a) sort(a.begin(),a.end());
using namespace std;
ll gcd(ll a, ll b){
if ( a==0 ) return b;
return gcd ( b%a, a );
}
int main() {
//*** ---------------------------------------------------------------------------*//
//
// Variables and Initialize
//
//*----------------------------------------------------------------------------- *//
ll N,X;
cin >> N >> X;
ll ans = 3*(N-gcd(N,X));
COUT(ans);
return 0;
}
|
a.cc:57:19: error: extended character
is not valid in an identifier
57 | cin >> N >> X;
| ^
a.cc: In function 'int main()':
a.cc:57:19: error: '\U00002028' was not declared in this scope
57 | cin >> N >> X;
| ^
a.cc:59:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
59 | COUT(ans);
| ^~~
a.cc:31:25: note: in definition of macro 'COUT'
31 | #define COUT(x) cout << x << endl;
| ^
|
s686792726
|
p04048
|
Java
|
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashMap;
public class New4 {
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
long[] a = la(in.readLine(), 2);
long N=a[0], X=a[1];
long sum=N;
int flag=0;
while (flag==0) {
long k=(N-X)/X;
if ((N-X)%X==0) {
sum+=((2*k+1)*X);
flag=1;
}
else {
sum+=(2*k*X);
long temp=X;
X = (N-X)%X;
N=temp;
}
}
out.write(sum+"\n");
out.flush();
}
private static int ip (String s) {
int n = Integer.parseInt(s);
return n;
}
private static long lp (String s) {
long n = Long.parseLong(s);
return n;
}
private static double dp (String s) {
double n = Double.parseDouble(s);
return n;
}
private static int[] ia (String s, int n) {
String[] s1 = s.split(" ");
int[] A = new int[n];
for (int i=0; i<n; i++) {
A[i] = Integer.parseInt(s1[i]);
}
return A;
}
private static long[] la (String s, int n) {
String[] s1 = s.split(" ");
long[] A = new long[n];
for (int i=0; i<n; i++) {
A[i] = Long.parseLong(s1[i]);
}
return A;
}
private static double[] da (String s, int n) {
String[] s1 = s.split(" ");
double[] A = new double[n];
for (int i=0; i<n; i++) {
A[i] = Double.parseDouble(s1[i]);
}
return A;
}
}
|
Main.java:7: error: class New4 is public, should be declared in a file named New4.java
public class New4 {
^
1 error
|
s114292946
|
p04048
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define DEBUG_ON 1 // 0 = off, 1 = on
namespace {
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define LEN(x) (int)((x).size())
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define OP minmax
#define FOR(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#ifndef ONLINE_JUDGE
#include "debug.h"
#endif // ONLINE_JUDGE
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<ll> vll;
template<typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>;
ll expmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
}
const int MAX_N = 200000;
const ll MODD = 1000000009LL;
const ld EPS = 1e-9;
ll a, b, c;
ll ba, bb, bc;
ll solve(ll N, ll X) {
if (N % 2 == 0 && X == N / 2) return 3 * X;
if (2*X > N) X = N - X;
ll ans = 2 * X + N;
ll rem = (N - 2*X);
ll x = X;
while (rem != 0) {
DEBUG(ans, rem, x);
if (rem % x == 0) {
ans += 2 * rem - x;
return ans;
}
ans += (rem / x) * 2*x;
ll temp = x;
x = rem % x;
rem = temp;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll N, X;
cin >> N >> X;
cout << solve(N, X) << endl;
}
|
a.cc:21:10: fatal error: debug.h: No such file or directory
21 | #include "debug.h"
| ^~~~~~~~~
compilation terminated.
|
s668671023
|
p04048
|
C++
|
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<math.h>
using namespace std;
int main() {
unsigned long long n, x;
cin >> n >> x;
if (n / 2.0 != x) {
int a = (n - x) / x;
int b = (n - x) % x;
cout << x * 3 * ( b + a);
} }else {
cout << x * 3;
}
return 0;
}
|
a.cc:15:18: error: expected unqualified-id before 'else'
15 | } }else {
| ^~~~
a.cc:18:9: error: expected unqualified-id before 'return'
18 | return 0;
| ^~~~~~
a.cc:19:1: error: expected declaration before '}' token
19 | }
| ^
|
s497610149
|
p04048
|
C++
|
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<math.h>
using namespace std;
int main() {
unsigned long long n, x;
cin >> n >> x;
if (n / 2.0 != x) {
int a = (n - x) / x;
int b = (n - x) % x;
cout << x * 3 * ( b + a);
} }else {
cout << x * 3;
}
return 0;
|
a.cc:15:18: error: expected unqualified-id before 'else'
15 | } }else {
| ^~~~
a.cc:18:9: error: expected unqualified-id before 'return'
18 | return 0;
| ^~~~~~
|
s856791613
|
p04048
|
Java
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;
public class Main {
static int count = 0;
public static int[] func(int[] ar) {
//System.out.println(Arrays.toString(ar));
Arrays.sort(ar);
if (ar[0] == 0) {
//int[] result = {count, 0};
//return result;
return ar;
}
//System.out.println(Arrays.toString(ar));
//count = count + ar[0] * 3 * (ar[1] / ar[0]);
int[] next = {ar[0], (ar[1] % ar[0])};
return func(next);
}
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] line = br.readLine().trim().split(" ");
int[] ar = Stream.of(line).mapToInt(Integer::parseInt).toArray();
Arrays.sort(ar);
ar[1] = ar[1] - ar[0];
//System.out.println(Arrays.toString(ar));
//int[] ar = {3, 2};
//System.out.println(func(ar)[0]);
int poi = func(ar[1]);
int result = poi * 3 * ((ar[0] * ar[1]) / poi);
System.out.println(result);
}
}
|
Main.java:32: error: incompatible types: int cannot be converted to int[]
int poi = func(ar[1]);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
|
s773137502
|
p04048
|
C++
|
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
#define dump(o) { cerr << #o << " " << o << endl; }
#define dumpc(o) { cerr << #o; for (auto &e : (o)) cerr << " " << e; cerr << endl; }
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
vector<long long> a;
vector<long long> b;
long long cnt = 0;
//最大公約数
long long gcd(long long x, long long y) {
if (y) {
cnt++;
a.push_back(y);
b.push_back(x / y);
return gcd(y, x%y);
}
else {
return x;
}
}
long long main() {
long long N, K; cin >> N >> K;
K = max(N - K, K);
gcd(N, K);
long long ans;
if (cnt == 1) {
ans = a[0] * 3;
}
else if (cnt == 2) {
ans = 1 * a[0];
ans += (2 * b[1])*a[1];
}
else {
ans = 1 * a[0];
ans += (2 * b[1] + 1)*a[1];
for (long long i = 2; i < a.size() - 1; i++) {
ans += 2 * b[i] * a[i];
//dump(ans);
}
ans += (2 * b[a.size() - 1] - 1)*a[a.size() - 1];
//dumpc(a);
//dumpc(b);
}
//cout << cnt << endl;
cout << ans << endl;
return 0;
}
|
cc1plus: error: '::main' must return 'int'
|
s573995522
|
p04048
|
C++
|
include <iostream>
using namespace std;
int mod_gcd(int a, int b, int &l){
if(a%b!=0){
l=l+2*( a - (a % b));
return mod_gcd(b,a%b,l);
}
else {
l=l+b*(a/b+1);
}
}
int main(int argc, char *argv[]) {
int n,x,l=0;
cin >> n >> x;
mod_gcd(n-x,x,l);
cout << l+n;
}
|
a.cc:1:1: error: 'include' does not name a type
1 | include <iostream>
| ^~~~~~~
a.cc: In function 'int main(int, char**)':
a.cc:16:9: error: 'cin' was not declared in this scope
16 | cin >> n >> x;
| ^~~
a.cc:18:9: error: 'cout' was not declared in this scope
18 | cout << l+n;
| ^~~~
a.cc: In function 'int mod_gcd(int, int, int&)':
a.cc:11:18: warning: control reaches end of non-void function [-Wreturn-type]
11 | l=l+b*(a/b+1);
| ~^~~~~~~~~~~~
|
s425734590
|
p04048
|
Java
|
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int X = sc.nextInt();
int ans = X + (N - X);
if(N % 2 == 0) {
ans += (X - (N / 2) + 1) * 3;
} else {
ans += ((N - 3) / 2) * 4 + 3;
}
System.out.println(ans);
}
}
|
Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s025543942
|
p04048
|
C++
|
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
using namespace std;
int dx[] ={0,1,0,-1};
int dy[]= {1,0,-1,0};
int c=0;
long long solve(long long N,long long X){
if(c==1){
c++;
if(2*N%X==0){
return X*(2*N/X);
}
int ans = X*(2*N/X);
return ans + solve(X,N%X);
}else if(c%2==0){
c++;
if(N%X==0){
return (N/X)*2*X-X;
}
int an = (N/X)*2*X;
return an+solve(X,N%X);
}else if(c%2==1){
c++;
if(2*N%X==0){
return X*(2*N/X)-X;
}
int ans = X*(2*N/X);
return ans + solve(X,N%X);
}
}
int main(){
long long N,X;
cin>>N>>X;
long long ans=X;
c++;
ans = ans + solve(X,N-X);
c++;
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:39:3: error: 'cin' was not declared in this scope
39 | cin>>N>>X;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 |
a.cc:44:3: error: 'cout' was not declared in this scope
44 | cout<<ans<<endl;
| ^~~~
a.cc:44:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:44:14: error: 'endl' was not declared in this scope
44 | cout<<ans<<endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 |
a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:35:1: warning: control reaches end of non-void function [-Wreturn-type]
35 | }
| ^
|
s845671833
|
p04048
|
C++
|
int dx[] ={0,1,0,-1};
int dy[]= {1,0,-1,0};
int c=0;
long long solve(long long N,long long X){
if(c==1){
c++;
if(2*N%X==0){
return X*(2*N/X);
}
int ans = X*(2*N/X);
return ans + solve(X,N%X);
}else if(c%2==0){
c++;
if(N%X==0){
return (N/X)*2*X-X;
}
int an = (N/X)*2*X;
return an+solve(X,N%X);
}else if(c%2==1){
c++;
if(2*N%X==0){
return X*(2*N/X)-X;
}
int ans = X*(2*N/X);
return ans + solve(X,N%X);
}
}
int main(){
long long N,X;
cin>>N>>X;
long long ans=X;
c++;
ans = ans + solve(X,N-X);
c++;
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:34:3: error: 'cin' was not declared in this scope
34 | cin>>N>>X;
| ^~~
a.cc:39:3: error: 'cout' was not declared in this scope
39 | cout<<ans<<endl;
| ^~~~
a.cc:39:14: error: 'endl' was not declared in this scope
39 | cout<<ans<<endl;
| ^~~~
a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:30:1: warning: control reaches end of non-void function [-Wreturn-type]
30 | }
| ^
|
s658873592
|
p04048
|
C++
|
#include <iostream>
using namespace std;
int main() {
int n,x,length;
int a[2];
cin>>n>>x;
a[0]=n-x;
a[1]=x;
length=x;
while(a[0]!=a[1]){
if(a[0]>a[1]){
length=length+((a[0]-1)/a[1])*a1;
a[0]=(a[0]-1)%a[1]+1;
}
if(a[0]<a[1]){
a[1]=(a[1]-1)%a[0]+1;
}
}
cout<<length*3;
}
|
a.cc: In function 'int main()':
a.cc:13:47: error: 'a1' was not declared in this scope; did you mean 'a'?
13 | length=length+((a[0]-1)/a[1])*a1;
| ^~
| a
|
s702459655
|
p04048
|
C++
|
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<math.h>
using namespace std;
int main() {
unsigned long long n, x;
cin >> n >> x;
if (n / 2 < x) {
cout << 6 * x;
}
else {
cout << 3 * x;
}
return 0;
|
a.cc: In function 'int main()':
a.cc:17:18: error: expected '}' at end of input
17 | return 0;
| ^
a.cc:8:12: note: to match this '{'
8 | int main() {
| ^
|
s119140318
|
p04048
|
C++
|
// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <algorithm>
#include <numeric>
#include <set>
#include <functional>
using namespace std;
typedef long long ll;
int main() {
ll N, X;
scanf("%lld %lld\n", &N, &X);
ll result = 0;
// 明らかな場合を分けておく
if (N % 2 == 0) {
if (X == N / 2) {
printf("%lld\n", X*3);
return;
}
else if (X % 2 == 0) {
// 3手目まで
result += (X + (N - X) + X);
int left = N - 2 * X;
result += left * 2;
printf("%lld", result);
return;
}
}
// 3手目まで
result += (X + (N - X) + X);
// 4手目
result += X;
// ...
return 0;
}
|
a.cc: In function 'int main()':
a.cc:39:25: error: return-statement with no value, in function returning 'int' [-fpermissive]
39 | return;
| ^~~~~~
a.cc:48:25: error: return-statement with no value, in function returning 'int' [-fpermissive]
48 | return;
| ^~~~~~
|
s905614504
|
p04048
|
Java
|
import java.util.Arrays;
import java.util.Scanner;
public class MainB {
MyScanner sc = new MyScanner();
Scanner sc2 = new Scanner(System.in);
long start = System.currentTimeMillis();
long fin = System.currentTimeMillis();
final int MOD = 1000000007;
int[] dx = { 1, 0, 0, -1 };
int[] dy = { 0, 1, -1, 0 };
void run() {
long N = sc.nextLong();
long X = sc.nextLong();
long ans = 0;
if (N % 2 == 0 && N / 2 == X) {
ans += X * 3;
} else if (N / 2.0 > X) {
ans += N;
if ((N - X) % X == 0) {
ans += ((N - X) / X) * X * 2 - X;
} else {
ans += ((N - X) / X) * X * 2;
ans += (N - X) % X * 3;
}
} else {
ans += X;
if (X % (N - X) == 0) {
ans += (X / (N - X)) * (N - X) * 2;
} else {
ans += (N / (N - X)) * (N - X) * 2 - (N - X);
ans += (N %(N - X)) * 3;
}
}
System.out.println(ans);
}
public static void main(String[] args) {
new MainB().run();
}
void debug(Object... o) {
System.out.println(Arrays.deepToString(o));
}
void debug2(char[][] array) {
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
System.out.print(array[i][j]);
}
System.out.println();
}
}
boolean inner(int h, int w, int limH, int limW) {
return 0 <= h && h < limH && 0 <= w && w < limW;
}
void swap(int[] x, int a, int b) {
int tmp = x[a];
x[a] = x[b];
x[b] = tmp;
}
// find minimum i (k <= a[i])
int lower_bound(int a[], int k) {
int l = -1;
int r = a.length;
while (r - l > 1) {
int mid = (l + r) / 2;
if (k <= a[mid])
r = mid;
else
l = mid;
}
// r = l + 1
return r;
}
// find minimum i (k < a[i])
int upper_bound(int a[], int k) {
int l = -1;
int r = a.length;
while (r - l > 1) {
int mid = (l + r) / 2;
if (k < a[mid])
r = mid;
else
l = mid;
}
// r = l + 1
return r;
}
long gcd(long a, long b) {
return a % b == 0 ? b : gcd(b, a % b);
}
long lcm(long a, long b) {
return a * b / gcd(a, b);
}
boolean palindrome(String s) {
for (int i = 0; i < s.length() / 2; i++) {
if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
return false;
}
}
return true;
}
class MyScanner {
int nextInt() {
try {
int c = System.in.read();
while (c != '-' && (c < '0' || '9' < c))
c = System.in.read();
if (c == '-')
return -nextInt();
int res = 0;
do {
res *= 10;
res += c - '0';
c = System.in.read();
} while ('0' <= c && c <= '9');
return res;
} catch (Exception e) {
return -1;
}
}
double nextDouble() {
return Double.parseDouble(next());
}
long nextLong() {
return Long.parseLong(next());
}
String next() {
try {
StringBuilder res = new StringBuilder("");
int c = System.in.read();
while (Character.isWhitespace(c))
c = System.in.read();
do {
res.append((char) c);
} while (!Character.isWhitespace(c = System.in.read()));
return res.toString();
} catch (Exception e) {
return null;
}
}
int[] nextIntArray(int n) {
int[] in = new int[n];
for (int i = 0; i < n; i++) {
in[i] = nextInt();
}
return in;
}
int[][] nextInt2dArray(int n, int m) {
int[][] in = new int[n][m];
for (int i = 0; i < n; i++) {
in[i] = nextIntArray(m);
}
return in;
}
double[] nextDoubleArray(int n) {
double[] in = new double[n];
for (int i = 0; i < n; i++) {
in[i] = nextDouble();
}
return in;
}
long[] nextLongArray(int n) {
long[] in = new long[n];
for (int i = 0; i < n; i++) {
in[i] = nextLong();
}
return in;
}
char[][] nextCharField(int n, int m) {
char[][] in = new char[n][m];
for (int i = 0; i < n; i++) {
String s = sc.next();
for (int j = 0; j < m; j++) {
in[i][j] = s.charAt(j);
}
}
return in;
}
}
}
|
Main.java:4: error: class MainB is public, should be declared in a file named MainB.java
public class MainB {
^
1 error
|
s120202974
|
p04048
|
C++
|
#include <bits/stdc++.h>
using namespace std;
long long n, x, ans, prev, cur;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> n >> x;
x = min(x, n - x);
ans += x;
ans += n - x;
prev = n - x;
cur = x;
while(cur > 0) {
ans += 2 * (prev / cur) * cur;
prev %= cur;
swap(prev, cur);
}
cout << ans - prev << '\n';
return 0;
}
|
a.cc: In function 'int main()':
a.cc:18:9: error: reference to 'prev' is ambiguous
18 | prev = n - x;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:4:22: note: 'long long int prev'
4 | long long n, x, ans, prev, cur;
| ^~~~
a.cc:22:29: error: reference to 'prev' is ambiguous
22 | ans += 2 * (prev / cur) * cur;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:4:22: note: 'long long int prev'
4 | long long n, x, ans, prev, cur;
| ^~~~
a.cc:23:17: error: reference to 'prev' is ambiguous
23 | prev %= cur;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:4:22: note: 'long long int prev'
4 | long long n, x, ans, prev, cur;
| ^~~~
a.cc:24:22: error: reference to 'prev' is ambiguous
24 | swap(prev, cur);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:4:22: note: 'long long int prev'
4 | long long n, x, ans, prev, cur;
| ^~~~
a.cc:27:23: error: reference to 'prev' is ambiguous
27 | cout << ans - prev << '\n';
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:4:22: note: 'long long int prev'
4 | long long n, x, ans, prev, cur;
| ^~~~
|
s979054351
|
p04048
|
C++
|
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define debug(x) cout<<#x<<": "<<x<<endl
#define MOD 1000000007
#define MAX_N 2000
typedef long long ll;
typedef unsigned long long ull;
int main(void)
{
int N, K;
cin >> N >> K;
vector<int> g[MAX_N];
REP(i, N) {
int A, B;
cin >> A >> B;
A--;
B--;
g[A].pb(B);
g[B].pb(A);
}
int ret = MAX_N;
REP(k, N) {
if (true) {
int d[MAX_N];
fill(d, d + N, MAX_N);
queue<int> q;
q.pb(k);
d[k] = 0;
while (!q.empty()) {
int x = q.front();
q.pop();
if (d[x] == K) {
continue;
}
for (int i = 0; g[x].size(); i++) {
int to = g[x][i];
if (d[to] > d[x] + 1) {
d[to] = d[x] + 1;
q.pb(to);
}
}
}
for (int i = 0; g[k].size(); i++) {
int to = g[k][i];
}
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:24:12: error: 'class std::queue<int>' has no member named 'push_back'
24 | #define pb push_back
| ^~~~~~~~~
a.cc:54:15: note: in expansion of macro 'pb'
54 | q.pb(k);
| ^~
a.cc:24:12: error: 'class std::queue<int>' has no member named 'push_back'
24 | #define pb push_back
| ^~~~~~~~~
a.cc:66:27: note: in expansion of macro 'pb'
66 | q.pb(to);
| ^~
a.cc:76:2: error: expected '}' at end of input
76 | }
| ^
a.cc:36:1: note: to match this '{'
36 | {
| ^
|
s831148812
|
p04048
|
C++
|
#include<iostream>
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
void swarp(long long *a,long long *b){
long long c;
c = *a;
*a = *b;
*b = c;
}
long long solve(long long l,long long s){
if (l == (l/s)*s) return 2*(l-s);
else return ((l/s) * 2-1)*s + l % s + solve(s,l%s);
}
int main(){
long long n,x,sum=0;
cin >> n >> x;
sum += n+2*x;
if (n==2*x) {
cout << x*3 << endl;
return 0;
} else if (n>2*x && (n-2*x>=x) && n%x == 0){
sum += 2*n-5*x;
cout << sum << endl;
return 0;
} else if (n>2*x &&(x>n-2*x) x % (n-2*x)==0){
sum += 2*x-(n-2*x);
cout << sum << endl;
return 0;
} else if (n>2*x) {
long long l=n-2*x;
if(x>l) swarp(&l,&x);
sum += 2*(n-2*x);
sum += solve(x,(n-2*x)%x);
cout << sum << endl;
return 0;
} else {
sum += solve(n,n-x);
cout << sum << endl;
return 0;
}
}
|
a.cc: In function 'int main()':
a.cc:33:31: error: expected ')' before 'x'
33 | } else if (n>2*x &&(x>n-2*x) x % (n-2*x)==0){
| ~ ^~
| )
|
s184260761
|
p04048
|
C++
|
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
long long n,x,a,res;
cin >> n >> x;
a = max(n-x,x)
if(n%x == 0)cout << a*3 <<endl;
else cout << a*4 <<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:10:23: error: expected ';' before 'if'
10 | a = max(n-x,x)
| ^
| ;
11 | if(n%x == 0)cout << a*3 <<endl;
| ~~
a.cc:12:9: error: 'else' without a previous 'if'
12 | else cout << a*4 <<endl;
| ^~~~
|
s163807260
|
p04048
|
C
|
#include<stdio.h>
long long gcd(long long a,long long b){
while(b ^= a ^= b ^= a%=b);
return a;
}
long long main(){
long long n,x;
long long i,j,g;
scanf("%lld%lld",&n,&x);
g = gcd(n,x);
n /= g;
x /= g;
prlong longf("%lld\n",(n-1)*3*g);
return 0;
}
|
main.c: In function 'main':
main.c:18:9: error: unknown type name 'prlong'; did you mean 'long'?
18 | prlong longf("%lld\n",(n-1)*3*g);
| ^~~~~~
| long
main.c:18:22: error: expected declaration specifiers or '...' before string constant
18 | prlong longf("%lld\n",(n-1)*3*g);
| ^~~~~~~~
main.c:18:31: error: expected declaration specifiers or '...' before '(' token
18 | prlong longf("%lld\n",(n-1)*3*g);
| ^
|
s938619845
|
p04048
|
C++
|
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)
constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };
constexpr int INF = 1000000000;/* 1e+9a */
constexpr int MODULO = 1000000007;
int main()
{
ios::sync_with_stdio(false);
uint64_t n, x;
cin >> n >> x;
cout << 6 * x << '\n';
else if( 2 * x == n)
cout << 3 * n / 2 << '\n';
else
cout << 3 * x << '\n';
}
|
a.cc: In function 'int main()':
a.cc:31:5: error: 'else' without a previous 'if'
31 | else if( 2 * x == n)
| ^~~~
|
s740009807
|
p04048
|
Java
|
import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long x = sc.nextLong();
System.out.println(x*3 + (n-x-1)*3);
}
}
|
Main.java:3: error: class main is public, should be declared in a file named main.java
public class main {
^
1 error
|
s167833323
|
p04048
|
C++
|
#include<iostream>
#include<vector>
#include<algorithm>
#define REP(i,n) for(int i=0; i<n; ++i)
using namespace std;
typedef long long int ll;
int main(){
ll n, x;
cin >> n >> x;
x = min(x, n-x);
if(n%x){ cout << 3*(n-1) << endl; }
else { cout << 3*(n/x-1)*x << endl; }
return 0;
}
[yuri] 16-07-16 21:37:43> ~/agc
|
a.cc:17:1: error: expected unqualified-id before '[' token
17 | [yuri] 16-07-16 21:37:43> ~/agc
| ^
|
s417025699
|
p04048
|
C++
|
#include<vector>
#include<algorithm>
int main() {
std::size_t N,X;
std::cin >> N >> X;
auto res{0};
if (2 * X < N) {
res = X * 6;
}
else {
res = X * 3;
}
std::cout << res<<"\n";
return 0;
}
|
a.cc: In function 'int main()':
a.cc:6:14: error: 'cin' is not a member of 'std'
6 | std::cin >> N >> X;
| ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include<algorithm>
+++ |+#include <iostream>
3 |
a.cc:14:14: error: 'cout' is not a member of 'std'
14 | std::cout << res<<"\n";
| ^~~~
a.cc:14:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s094535807
|
p04048
|
C++
|
#include<cstdio>
#define ll long long
using namespace std;
int main()
{
ll n,x;
while(~scanf("%I64d%I64d",&n,&x))
{
if(x*2==n)printf("%I64d\n",3*(n/2));
else printf("%I64d\n",3*(n-1));
}
|
a.cc: In function 'int main()':
a.cc:11:2: error: expected '}' at end of input
11 | }
| ^
a.cc:5:1: note: to match this '{'
5 | {
| ^
|
s654128501
|
p04048
|
C++
|
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define FORN(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }
#define MOD 1000000007
#define INF 2000000000
int GLL(LL& x) {
return scanf("%lld", &x);
}
int GI(int& x) {
return scanf("%d", &x);
}
int n, x;
int main() {
GLL(n); GLL(x);
LL res = n;
LL a = x; LL b = n-x; if (a > b) swap(a, b);
while (a > 0) {
LL q = b / a;
LL r = b % a;
if (r > 0) {
res += 2 * q * a;
}
else {
res += (2 * q - 1) * a;
}
b = a;
a = r;
}
cout << res << "\n";
return 0;
}
|
a.cc: In function 'int main()':
a.cc:47:9: error: cannot bind non-const lvalue reference of type 'LL&' {aka 'long long int&'} to a value of type 'int'
47 | GLL(n); GLL(x);
| ^
a.cc:36:13: note: initializing argument 1 of 'int GLL(LL&)'
36 | int GLL(LL& x) {
| ~~~~^
a.cc:47:17: error: cannot bind non-const lvalue reference of type 'LL&' {aka 'long long int&'} to a value of type 'int'
47 | GLL(n); GLL(x);
| ^
a.cc:36:13: note: initializing argument 1 of 'int GLL(LL&)'
36 | int GLL(LL& x) {
| ~~~~^
|
s197658919
|
p04048
|
Java
|
// package atcoder.agc.agc001;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
/**
* Created by hama_du on 2016/07/16.
*/
public class B {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
long n = in.nextLong();
long x = in.nextLong();
long ans = n + dfs(n-x, x);
out.println(ans);
out.flush();
}
private static long dfs(long n, long x) {
long min = Math.min(n, x);
long max = Math.max(n, x);
long cur = max / min;
long ret = 0;
if (max % min == 0) {
ret = min * (cur * 2 - 1);
} else {
ret += dfs(min, max % min) + min * cur * 2;
}
return ret;
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public InputReader(InputStream stream) {
this.stream = stream;
}
private int next() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public char nextChar() {
int c = next();
while (isSpaceChar(c))
c = next();
if ('a' <= c && c <= 'z') {
return (char) c;
}
if ('A' <= c && c <= 'Z') {
return (char) c;
}
throw new InputMismatchException();
}
public String nextToken() {
int c = next();
while (isSpaceChar(c))
c = next();
StringBuilder res = new StringBuilder();
do {
res.append((char) c);
c = next();
} while (!isSpaceChar(c));
return res.toString();
}
public int nextInt() {
int c = next();
while (isSpaceChar(c))
c = next();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = next();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c-'0';
c = next();
} while (!isSpaceChar(c));
return res*sgn;
}
public long nextLong() {
int c = next();
while (isSpaceChar(c))
c = next();
long sgn = 1;
if (c == '-') {
sgn = -1;
c = next();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c-'0';
c = next();
} while (!isSpaceChar(c));
return res*sgn;
}
public boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
static void debug(Object... o) {
System.err.println(Arrays.deepToString(o));
}
}
|
Main.java:12: error: class B is public, should be declared in a file named B.java
public class B {
^
1 error
|
s234946588
|
p04049
|
C++
|
â
|
a.cc:1:1: error: '\U000000e2' does not name a type
1 | â
| ^
|
s020205521
|
p04049
|
C++
|
a
|
a.cc:1:1: error: 'a' does not name a type
1 | a
| ^
|
s991694756
|
p04049
|
C++
|
// It works until it doesn't
#ifndef NOBITS
#include <bits/stdc++.h>
#endif
using namespace std;
// pre
#include "debug/deb.cpp"
#include "io/ion.cpp"
// ctvl, ctvl2, read, write, writeln, ~, div_ceil, div_floor, min_heap, max_heap, d+=d, +-d, --d--, lbi, ubi,
// vecnd, vec1, vec2, vec3, log2_floor, log2_ceil
#include "misc/util.cpp"
// all, rall, forn, ford, for1, forr, trav, eb, pub, pob, fi, se, endl, mp, mt, if0, timit, Fn, pct, ctz, clz, binrep
#include "misc/macros.cpp"
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> using vv = vector<vector<T>>;
// #define int long long
const int N = 200'010;
auto dfs_tree(int root, const vector<vector<int>>& g) {
stack<int> h;
h.push(root);
int n = g.size();
vector<int> dist(n), pi(n, -1);
while(!h.empty()) {
int u = h.top();
h.pop();
for(auto v : g[u]) {
if(pi[u] != v) {
pi[v] = u;
h.push(v);
assert(dist[v] == 0);
dist[v] = dist[u] + 1;
}
}
}
return make_tuple(dist, pi);
}
auto soln() {
auto [n, k] = scan<int, int>();
vpii edge(n - 1);
vvi g(n + 1);
forn(i, n - 1) {
auto [u, v] = scan<int, int>();
edge[i] = make_pair(u, v);
g[u].pub(v);
g[v].pub(u);
}
int res = N;
if (k % 2) {
for (auto &[u, v] : edge) {
int count = 0;
auto [distu, _1] = dfs_tree(u, g);
auto [distv, _2] = dfs_tree(v, g);
for (int i = 1; i <= n; ++i) {
ckmin(distu[i], distv[i]);
count += (distu[i] > k / 2);
}
ckmin(res, count);
}
}
else {
for (int i = 1; i <= n; ++i) {
int count = 0;
auto [dist, _3] = dfs_tree(i, g);
echo(i, dist);
for (int j = 1; j <= n; ++j) {
count += (dist[j] > k / 2);
}
ckmin(res, count);
}
}
cout << res << endl;
}
signed main() {
int t = 1;
#ifndef LOCAL
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#endif
// t = scan<int>();
while (t--)
soln();
return 0;
}
|
a.cc:7:10: fatal error: debug/deb.cpp: No such file or directory
7 | #include "debug/deb.cpp"
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s240175954
|
p04049
|
C++
|
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
int n, k;
vector<int> g[4000];
int cnt(int cur, int prev)
{
// cout << cur << ", " << prev << endl;
int ret = 1;
for (auto &n: g[cur]) {
if (n == prev) continue;
ret += cnt(n, cur);
}
return ret;
}
int solve(int cur, int prev, int dep)
{
// cout << cur << ", " << prev << ", " << dep << endl;
if (dep <= 0) {
return cnt(cur, prev);
}
int ans = 0;
for (int i = 0; i < g[cur].size(); i++) {
if (g[cur][i] == prev) continue;
ans += solve(g[cur][i], cur, dep - 1);
}
return ans;
}
int main()
{
cin >> n >> k;
g.resize(n);
for (int i = 0; i < n-1; i++) {
int a, b; cin >> a >> b;
a--, b--;
g[a].push_back(b);
g[b].push_back(a);
}
int ans = n + 1;
for (int center = 0; center < n; center++) {
for (auto lng: g[center]) {
int tmp = 0;
for (auto root: g[center]) {
tmp += solve(root, center, k / 2 + ((k % 2 == 1 && lng == root) ? 1 : 0));
}
// cout << center + 1 << " -> " << lng + 1 << ": " << tmp << endl;
ans = min(ans, tmp);
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:49:7: error: request for member 'resize' in 'g', which is of non-class type 'std::vector<int> [4000]'
49 | g.resize(n);
| ^~~~~~
|
s269681628
|
p04049
|
C++
|
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
#define mp make_pair
#define pb push_back
#define x first
#define y second
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
int dp[4000][4000],g[4000],head[4000];
int n,k,ans;
bool visited[4000];
vector<int> graph[4000];
void dfs(int x)
{
dp[x][0]=1;
for (int j=1;j<=k+1;j++)
{
dp[x][j]=0;
}
visited[x]=1;
for(int second : graph[x])
{
if(!visited[second])
{
dfs(second);
g[0]=dp[x][0];
for (int j=1;j<=k+1;j++)
{
g[j]=min(g[j-1],dp[x][j]);
}
for (int j=1;j<=k+1;j++)
{
dp[x][j]=n;
}
for (int j=1;j<=min(k+1,dp[x][0]);j++)
{
for (int w=0;w<=min(k,dp[second][0]);w++)
{
if (j-1+w<=k)
{
dp[x][max(j,w+1)]=min(dp[x][max(j,w+1)],g[j]+dp[second][w]);
}
}
}
dp[x][0]+=dp[second][0];
}
}
for (int j=1;j<=k+1;j++)
{
dp[x][j]=min(dp[x][j],dp[x][j-1]);
}
ans=min(ans,n-dp[x][0]+dp[x][k+1]);
}
int main()
{
scanf("%d%d",&n,&k);
for (int i=1;i<n;i++)
{
int x,y;
scanf("%d%d",&x,&y);
//push(2*i-1,x,y);push(2*i,y,x);
graph[x].push_back(y);
graph[y].push_back(x);
}
memset(v,0,sizeof(v));
ans=n;
dfs(1);
printf("%d\n",ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:77:16: error: 'v' was not declared in this scope; did you mean 'vi'?
77 | memset(v,0,sizeof(v));
| ^
| vi
|
s566587615
|
p04049
|
Java
|
import java.util.*;
import java.io.*;
import java.text.*;
class AtCoder_AGC01_C{
//SOLUTION BEGIN
//Into the Hardware Mode
void pre() throws Exception{}
void solve(int TC) throws Exception{
int N = ni(), K = ni();
int[] from = new int[N-1], to = new int[N-1];
for(int i = 0; i< N-1; i++){
from[i] = ni()-1;
to[i] = ni()-1;
}
int[][] g = make(N, N-1, from, to, true);
int[][] DP = new int[N][];
dfs(DP, g, new int[N], 0,-1, K);
int ans = 0;
for(int x:DP[0])ans = Math.max(ans, x);
pn(N-ans);
}
void dfs(int[][] DP, int[][] g, int[] dep, int u, int p, int K){
for(int v:g[u])if(v != p){
dfs(DP, g, dep, v, u, K);
dep[u] = Math.max(dep[u], 1+dep[v]);
}
int[] dp = new int[1];
dp[0] = 1;
int maxD = 0;
for(int v:g[u]){
if(v == p)continue;
maxD = Math.max(maxD, 1+dep[v]);
int[] ndp = new int[1+maxD];
for(int d1 = 0; d1 < dp.length; d1++){
for(int d2 = 0; d2 < DP[v].length && d1+d2 <= K; d2++){
ndp[Math.max(d1, 1+d2)] += DP[v][d2];
}
}
dp = ndp;
}
DP[u] = dp;
}
//SOLUTION END
void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
void exit(boolean b){if(!b)System.exit(0);}
static void dbg(Object... o){System.err.println(Arrays.deepToString(o));}
final long IINF = (long)1e17;
final int INF = (int)1e9+2;
DecimalFormat df = new DecimalFormat("0.00000000000");
double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
static boolean multipleTC = false, memory = true, fileIO = false;
FastReader in;PrintWriter out;
void run() throws Exception{
long ct = System.currentTimeMillis();
if (fileIO) {
in = new FastReader("");
out = new PrintWriter("");
} else {
in = new FastReader();
out = new PrintWriter(System.out);
}
//Solution Credits: Taranpreet Singh
int T = multipleTC? ni():1;
pre();
for (int t = 1; t <= T; t++) solve(t);
out.flush();
out.close();
System.err.println(System.currentTimeMillis() - ct);
}
public static void main(String[] args) throws Exception{
if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
else new Main().run();
}
int[][] make(int n, int e, int[] from, int[] to, boolean f){
int[][] g = new int[n][];int[]cnt = new int[n];
for(int i = 0; i< e; i++){
cnt[from[i]]++;
if(f)cnt[to[i]]++;
}
for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];
for(int i = 0; i< e; i++){
g[from[i]][--cnt[from[i]]] = to[i];
if(f)g[to[i]][--cnt[to[i]]] = from[i];
}
return g;
}
int[][][] makeS(int n, int e, int[] from, int[] to, boolean f){
int[][][] g = new int[n][][];int[]cnt = new int[n];
for(int i = 0; i< e; i++){
cnt[from[i]]++;
if(f)cnt[to[i]]++;
}
for(int i = 0; i< n; i++)g[i] = new int[cnt[i]][];
for(int i = 0; i< e; i++){
g[from[i]][--cnt[from[i]]] = new int[]{to[i], i, 0};
if(f)g[to[i]][--cnt[to[i]]] = new int[]{from[i], i, 1};
}
return g;
}
int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}
int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
void p(Object... o){for(Object oo:o)out.print(oo+" ");}
void pn(Object... o){for(Object oo:o)out.print(oo+" ");out.println();}
void pni(Object... o){for(Object oo:o)out.print(oo+" ");out.println();out.flush();}
String n()throws Exception{return in.next();}
String nln()throws Exception{return in.nextLine();}
int ni()throws Exception{return Integer.parseInt(in.next());}
long nl()throws Exception{return Long.parseLong(in.next());}
double nd()throws Exception{return Double.parseDouble(in.next());}
class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br = new BufferedReader(new InputStreamReader(System.in));
}
public FastReader(String s) throws Exception{
br = new BufferedReader(new FileReader(s));
}
String next() throws Exception{
while (st == null || !st.hasMoreElements()){
try{
st = new StringTokenizer(br.readLine());
}catch (IOException e){
throw new Exception(e.toString());
}
}
return st.nextToken();
}
String nextLine() throws Exception{
String str;
try{
str = br.readLine();
}catch (IOException e){
throw new Exception(e.toString());
}
return str;
}
}
}
|
Main.java:5: error: duplicate class: AtCoder_AGC01_C
class AtCoder_AGC01_C{
^
Main.java:73: error: cannot access Main
if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
^
bad source file: ./Main.java
file does not contain class Main
Please remove or make sure it appears in the correct subdirectory of the sourcepath.
2 errors
|
s970590406
|
p04049
|
C++
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define Rep(i,a,b) for(int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
ll x=0;char f=0;char c=gc();
for(;!isdigit(c);c=gc())f|=(c=='-');
for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);pc('\n');}
IL void wri(ll x){write(x),pc(' ');}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define y1 ____y1
#define hash __hash
#define union _union
#define ramdom ((double)rand() / RAND_MAX)
#define x first
#define y second
const int maxn = 2005+233;
struct Edge{
int to,nxt;
Edge(){}
Edge(int to,int nxt):to(to),nxt(nxt){}
}edge[maxn*2];
int first[maxn],nume;
void Addedge(int a,int b){
edge[nume] = Edge(b,first[a]);
first[a] = nume++;
}
int mxdep[maxn],wson[maxn],size[maxn];
int dfn[maxn],dfx[maxn],n,k;
int dp_array[maxn];
int *f[maxn];
void init(int u,int fa){
mxdep[u] = 0;wson[u] = 0;size[u] = 1;
for(int e=first[u];~e;e=edge[e].nxt){
int v=edge[e].to;
if(v == fa) continue;
init(v,u);
mxdep[u] = max(mxdep[u],mxdep[v] + 1);
size[u] += size[v];
if(!wson[u] || mxdep[v] > mxdep[wson[u]])
wson[u] = v;
}
}
void pre(int u,int fa){
dfx[dfn[u] = ++*dfn] = u;
f[u] = dp_array + dfn[u];
for(int e=first[u];~e;e=edge[e].nxt){
int v=edge[e].to;
if(v==fa) continue;
pre(v,u);
}
}
int g[maxn],h[maxn],ans;
void dfs(int u,int fa){
if(wson[u]) dfs(wson[u],u);
f[u][0] = wson[u] ? size[wson[u]] : 0;
//printf("%d %d\n",u,mxdep[u]);
int m = min(k,mxdep[u]);
for(int e=first[u];~e;e=edge[e].nxt){
int v = edge[e].to;
if(v==wson[u] || v==fa) continue;
dfs(v,u);
int len = min(k,mxdep[v] + 1);
g[0] = size[v];Rep(i,1,len) g[i] = f[v][i-1];
Rep(i,0,len) h[i] = f[u][i];
// puts("~~");
// wri(g[0]),writeln(h[0]);
Rep(i,0,len) f[u][i] = min(g[i]+h[min(i,k-i)],g[min(i,k-i)] + h[i]);
Rep(i,0,len) if(k-i>len && k-i<=m) f[u][k-i] += g[i];
Rep(i,len+1,k-len-1) f[u][i] += g[len];
}
// Rep(i,0,m) wri(f[u][i]);puts("");
ans = min(ans,n - size[u] + f[u][min(k,m)]);
//从root往上搞一格
}
int main(){
mem(first,-1);nume = 0;
n = read();k = read();ans = n;
rep(i,1,n) {
int x = read(),y = read();
Addedge(x,y);
Addedge(y,x);
} init(1,0);
*dfn = 0;
pre(1,0);
dfs(1,0);
writeln(ans);
return 0;
}
|
a.cc: In function 'void init(int, int)':
a.cc:54:34: error: reference to 'size' is ambiguous
54 | mxdep[u] = 0;wson[u] = 0;size[u] = 1;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:49:28: note: 'int size [2238]'
49 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:60:17: error: reference to 'size' is ambiguous
60 | size[u] += size[v];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:49:28: note: 'int size [2238]'
49 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:60:28: error: reference to 'size' is ambiguous
60 | size[u] += size[v];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:49:28: note: 'int size [2238]'
49 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:77:29: error: reference to 'size' is ambiguous
77 | f[u][0] = wson[u] ? size[wson[u]] : 0;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:49:28: note: 'int size [2238]'
49 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:85:24: error: reference to 'size' is ambiguous
85 | g[0] = size[v];Rep(i,1,len) g[i] = f[v][i-1];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:49:28: note: 'int size [2238]'
49 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:94:27: error: reference to 'size' is ambiguous
94 | ans = min(ans,n - size[u] + f[u][min(k,m)]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:49:28: note: 'int size [2238]'
49 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
|
s079297074
|
p04049
|
C++
|
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define Rep(i,a,b) for(int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
ll x=0;char f=0;char c=gc();
for(;!isdigit(c);c=gc())f|=(c=='-');
for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);pc('\n');}
IL void wri(ll x){write(x),pc(' ');}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define y1 ____y1
#define hash __hash
#define union _union
#define ramdom ((double)rand() / RAND_MAX)
#define x first
#define y second
const int maxn = 2005+233;
struct Edge{
int to,nxt;
Edge(){}
Edge(int to,int nxt):to(to),nxt(nxt){}
}edge[maxn*2];
int first[maxn],nume;
void Addedge(int a,int b){
edge[nume] = Edge(b,first[a]);
first[a] = nume++;
}
int mxdep[maxn],wson[maxn],size[maxn];
int dfn[maxn],dfx[maxn],n,k;
int dp_array[maxn];
int *f[maxn];
void init(int u,int fa){
mxdep[u] = 0;wson[u] = 0;size[u] = 1;
for(int e=first[u];~e;e=edge[e].nxt){
int v=edge[e].to;
if(v == fa) continue;
init(v,u);
mxdep[u] = max(mxdep[u],mxdep[v] + 1);
size[u] += size[v];
if(!wson[u] || mxdep[v] > mxdep[wson[u]])
wson[u] = v;
}
}
void pre(int u,int fa){
dfx[dfn[u] = ++*dfn] = u;
f[u] = dp_array + dfn[u];
for(int e=first[u];~e;e=edge[e].nxt){
int v=edge[e].to;
if(v==fa) continue;
pre(v,u);
}
}
int g[maxn],h[maxn],ans;
void dfs(int u,int fa){
if(wson[u]) dfs(wson[u],u);
f[u][0] = wson[u] ? size[wson[u]] : 0;
//printf("%d %d\n",u,mxdep[u]);
int m = min(k,mxdep[u]);
for(int e=first[u];~e;e=edge[e].nxt){
int v = edge[e].to;
if(v==wson[u] || v==fa) continue;
dfs(v,u);
int len = min(k,mxdep[v] + 1);
g[0] = size[v];Rep(i,1,len) g[i] = f[v][i-1];
Rep(i,0,len) h[i] = f[u][i];
// puts("~~");
// wri(g[0]),writeln(h[0]);
Rep(i,0,len) f[u][i] = min(g[i]+h[min(i,k-i)],g[min(i,k-i)] + h[i]);
Rep(i,0,len) if(k-i>len && k-i<=m) f[u][k-i] += g[i];
Rep(i,len+1,k-len-1) f[u][i] += g[len];
}
// Rep(i,0,m) wri(f[u][i]);puts("");
ans = min(ans,n - size[u] + f[u][min(k,m)]);
//从root往上搞一格
}
int main(){
mem(first,-1);nume = 0;
n = read();k = read();ans = n;
rep(i,1,n) {
int x = read(),y = read();
Addedge(x,y);
Addedge(y,x);
} init(1,0);
*dfn = 0;
pre(1,0);
dfs(1,0);
writeln(ans);
return 0;
}
|
a.cc: In function 'void init(int, int)':
a.cc:55:34: error: reference to 'size' is ambiguous
55 | mxdep[u] = 0;wson[u] = 0;size[u] = 1;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:28: note: 'int size [2238]'
50 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:61:17: error: reference to 'size' is ambiguous
61 | size[u] += size[v];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:28: note: 'int size [2238]'
50 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:61:28: error: reference to 'size' is ambiguous
61 | size[u] += size[v];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:28: note: 'int size [2238]'
50 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:78:29: error: reference to 'size' is ambiguous
78 | f[u][0] = wson[u] ? size[wson[u]] : 0;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:28: note: 'int size [2238]'
50 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:86:24: error: reference to 'size' is ambiguous
86 | g[0] = size[v];Rep(i,1,len) g[i] = f[v][i-1];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:28: note: 'int size [2238]'
50 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:95:27: error: reference to 'size' is ambiguous
95 | ans = min(ans,n - size[u] + f[u][min(k,m)]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:28: note: 'int size [2238]'
50 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
|
s324151596
|
p04049
|
C++
|
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
RG ll x=0;char f=0;RG char c=gc();
for(;!isdigit(c);c=gc())f|=(c=='-');
for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
return f?-x:x;
}
IL double readdb(){
RG double x=0,p=0.1;RG char f=0,c=gc();
for(;!isdigit(c);c=gc())f|=(c=='-');
for(;isdigit(c);c=gc())x=x*10+(c^48);
if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);pc('\n');}
IL void wri(ll x){write(x),pc(' ');}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
#define ramdom ((double)rand() / RAND_MAX)
#define x first
#define y second
const int maxn = 2e7+233;
struct Edge{
int to,nxt;
Edge(){}
Edge(int to,int nxt):to(to),nxt(nxt){}
}edge[maxn*2];
int first[maxn],nume;
void Addedge(int a,int b){
edge[nume] = Edge(b,first[a]);
first[a] = nume++;
}
int mxdep[maxn],wson[maxn],size[maxn];
int dfn[maxn],dfx[maxn],n,k;
int dp_array[maxn];
int *f[maxn];
void init(int u,int fa){
mxdep[u] = 0;wson[u] = 0;size[u] = 1;
for(int e=first[u];~e;e=edge[e].nxt){
int v=edge[e].to;
if(v == fa) continue;
init(v,u);
mxdep[u] = max(mxdep[u],mxdep[v] + 1);
size[u] += size[v];
if(!wson[u] || mxdep[v] > mxdep[wson[u]])
wson[u] = v;
}
}
void pre(int u,int fa){
dfx[dfn[u] = ++*dfn] = u;
f[u] = dp_array + dfn[u];
for(int e=first[u];~e;e=edge[e].nxt){
int v=edge[e].to;
if(v==fa) continue;
pre(v,u);
}
}
int g[maxn],h[maxn],ans;
void dfs(int u,int fa){
if(wson[u]) dfs(wson[u],u);
f[u][0] = wson[u] ? size[wson[u]] : 0;
//printf("%d %d\n",u,mxdep[u]);
int m = min(k,mxdep[u]);
for(int e=first[u];~e;e=edge[e].nxt){
int v = edge[e].to;
if(v==wson[u] || v==fa) continue;
dfs(v,u);
int len = min(k,mxdep[v] + 1);
g[0] = size[v];Rep(i,1,len) g[i] = f[v][i-1];
Rep(i,0,len) h[i] = f[u][i];
// puts("~~");
// wri(g[0]),writeln(h[0]);
Rep(i,0,len) f[u][i] = min(g[i]+h[min(i,k-i)],g[min(i,k-i)] + h[i]);
Rep(i,0,len) if(k-i>len && k-i<=m) f[u][k-i] += g[i];
Rep(i,len+1,k-len-1) f[u][i] += g[len];
}
// Rep(i,0,m) wri(f[u][i]);puts("");
ans = min(ans,n - size[u] + f[u][min(k,m)]);
//从root往上搞一格
}
int main(){
mem(first,-1);nume = 0;
n = read();k = read();ans = n;
rep(i,1,n) {
int x = read(),y = read();
Addedge(x,y);
Addedge(y,x);
} init(1,0);
*dfn = 0;
pre(1,0);
dfs(1,0);
writeln(ans);
return 0;
}
|
a.cc: In function 'll read()':
a.cc:18:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
18 | RG ll x=0;char f=0;RG char c=gc();
| ^
a.cc:18:32: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
18 | RG ll x=0;char f=0;RG char c=gc();
| ^
a.cc: In function 'double readdb()':
a.cc:24:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
24 | RG double x=0,p=0.1;RG char f=0,c=gc();
| ^
a.cc:24:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
24 | RG double x=0,p=0.1;RG char f=0,c=gc();
| ^
a.cc:24:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
24 | RG double x=0,p=0.1;RG char f=0,c=gc();
| ^
a.cc:24:37: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
24 | RG double x=0,p=0.1;RG char f=0,c=gc();
| ^
a.cc: In function 'void init(int, int)':
a.cc:67:34: error: reference to 'size' is ambiguous
67 | mxdep[u] = 0;wson[u] = 0;size[u] = 1;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:62:28: note: 'int size [20000233]'
62 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:73:17: error: reference to 'size' is ambiguous
73 | size[u] += size[v];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:62:28: note: 'int size [20000233]'
62 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:73:28: error: reference to 'size' is ambiguous
73 | size[u] += size[v];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:62:28: note: 'int size [20000233]'
62 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:90:29: error: reference to 'size' is ambiguous
90 | f[u][0] = wson[u] ? size[wson[u]] : 0;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:62:28: note: 'int size [20000233]'
62 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:98:24: error: reference to 'size' is ambiguous
98 | g[0] = size[v];Rep(i,1,len) g[i] = f[v][i-1];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:62:28: note: 'int size [20000233]'
62 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc:98:36: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
98 | g[0] = size[v];Rep(i,1,len) g[i] = f[v][i-1];
| ^
a.cc:13:31: note: in definition of macro 'Rep'
13 | #define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
| ^
a.cc:99:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
99 | Rep(i,0,len) h[i] = f[u][i];
| ^
a.cc:13:31: note: in definition of macro 'Rep'
13 | #define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
| ^
a.cc:102:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
102 | Rep(i,0,len) f[u][i] = min(g[i]+h[min(i,k-i)],g[min(i,k-i)] + h[i]);
| ^
a.cc:13:31: note: in definition of macro 'Rep'
13 | #define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
| ^
a.cc:103:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
103 | Rep(i,0,len) if(k-i>len && k-i<=m) f[u][k-i] += g[i];
| ^
a.cc:13:31: note: in definition of macro 'Rep'
13 | #define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
| ^
a.cc:104:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
104 | Rep(i,len+1,k-len-1) f[u][i] += g[len];
| ^
a.cc:13:31: note: in definition of macro 'Rep'
13 | #define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
| ^
a.cc:107:27: error: reference to 'size' is ambiguous
107 | ans = min(ans,n - size[u] + f[u][min(k,m)]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:62:28: note: 'int size [20000233]'
62 | int mxdep[maxn],wson[maxn],size[maxn];
| ^~~~
a.cc: In function 'int main()':
a.cc:113:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
113 | rep(i,1,n) {
| ^
a.cc:12:31: note: in definition of macro 'rep'
12 | #define rep(i,a,b) for(RG int i=(a);i<(b);++i)
| ^
|
s254050543
|
p04049
|
C++
|
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 2020
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
char ch=getchar();
ll s=0,w=1;
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
return s*w;
}
int f[N][N],minn[N][N];
int size[N];
int n,k;
struct edge
{
int next,to;
}e[N<<1];
int head[N],cnt,dist[N],g[N];
inline void add_edge(int from,int to){e[++cnt]=(edge){head[from],to};head[from]=cnt;}
void dfs(int now,int father)
{
size[now]=1;int flag=0;
for(register int i=head[now];i;i=e[i].next)
{
if(e[i].to==father)continue;
dfs(e[i].to,now);flag=1;
size[now]+=size[e[i].to];dist[now]=max(dist[now],dist[e[i].to]+1);
for(register int j=1;j<=k+1;j++)f[now][j]+=f[e[i].to][j];
}
for(register int j=0;j<=k+1;j++)g[j]=0;
for(register int i=head[now];i;i=e[i].next)
{
if(e[i].to==father)continue;
for(register int j=0;j<=k+1;j++)g[j]+=f[e[i].to][j];
}
f[now][0]=size[now];
if(!flag){for(register int i=1;i<=k+1;i++)f[now][i]=0;return ;}
for(register int j=1;j<=k+1;j++)
{
f[now][j]=inf;
for(register int i=head[now];i;i=e[i].next)
{
if(e[i].to==father)continue;
// cout<<"???:"<<now<<" "<<e[i].to<<" "<<j<<" "<<min(j-1,k-(j-1))<<" "<<f[e[i].to][j-1]<<" "<<g[min(j-1,k-(j-1))]-f[e[i].to][min(j-1,k-(j-1))]<<endl;
if(min(j-1,k-(j-1))<0)continue;
f[now][j]=min(f[now][j],f[e[i].to][j-1]+g[min(j-1,k-(j-1))]-f[e[i].to][min(j-1,k-(j-1))]);
}
}
for(register int j=1;j<=k+1;j++)f[now][j]=min(f[now][j],f[now][j-1]);
// cout<<"WTF:"<<now<<" "<<dist[now]<<endl;
// for(register int j=0;j<=k+1;j++)cout<<f[now][j]<<" ";cout<<endl;
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
n=read(),k=read();
for(register int i=1;i<n;i++)
{
int x=read(),y=read();
add_edge(x,y);add_edge(y,x);
}
dfs(1,0);
printf("%d\n",f[1][k+1]);
return 0;
}
|
a.cc: In function 'void dfs(int, int)':
a.cc:39:9: error: reference to 'size' is ambiguous
39 | size[now]=1;int flag=0;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:29:5: note: 'int size [2020]'
29 | int size[N];
| ^~~~
a.cc:40:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
40 | for(register int i=head[now];i;i=e[i].next)
| ^
a.cc:44:17: error: reference to 'size' is ambiguous
44 | size[now]+=size[e[i].to];dist[now]=max(dist[now],dist[e[i].to]+1);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:29:5: note: 'int size [2020]'
29 | int size[N];
| ^~~~
a.cc:44:28: error: reference to 'size' is ambiguous
44 | size[now]+=size[e[i].to];dist[now]=max(dist[now],dist[e[i].to]+1);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:29:5: note: 'int size [2020]'
29 | int size[N];
| ^~~~
a.cc:45:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
45 | for(register int j=1;j<=k+1;j++)f[now][j]+=f[e[i].to][j];
| ^
a.cc:47:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
47 | for(register int j=0;j<=k+1;j++)g[j]=0;
| ^
a.cc:48:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
48 | for(register int i=head[now];i;i=e[i].next)
| ^
a.cc:51:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
51 | for(register int j=0;j<=k+1;j++)g[j]+=f[e[i].to][j];
| ^
a.cc:53:19: error: reference to 'size' is ambiguous
53 | f[now][0]=size[now];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:29:5: note: 'int size [2020]'
29 | int size[N];
| ^~~~
a.cc:54:36: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
54 | if(!flag){for(register int i=1;i<=k+1;i++)f[now][i]=0;return ;}
| ^
a.cc:55:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
55 | for(register int j=1;j<=k+1;j++)
| ^
a.cc:58:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
58 | for(register int i=head[now];i;i=e[i].next)
| ^
a.cc:66:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
66 | for(register int j=1;j<=k+1;j++)f[now][j]=min(f[now][j],f[now][j-1]);
| ^
a.cc: In function 'int main()':
a.cc:75:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
75 | for(register int i=1;i<n;i++)
| ^
|
s251458719
|
p04049
|
C++
|
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 2020
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
char ch=getchar();
ll s=0,w=1;
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
return s*w;
}
int f[N][N],minn[N][N];
int size[N];
int n,k;
struct edge
{
int next,to;
}e[N<<1];
int head[N],cnt,dist[N],g[N];
inline void add_edge(int from,int to){e[++cnt]=(edge){head[from],to};head[from]=cnt;}
void dfs(int now,int father)
{
size[now]=1;int flag=0;
for(register int i=head[now];i;i=e[i].next)
{
if(e[i].to==father)continue;
dfs(e[i].to,now);flag=1;
size[now]+=size[e[i].to];dist[now]=max(dist[now],dist[e[i].to]+1);
for(register int j=1;j<=k+1;j++)f[now][j]+=f[e[i].to][j];
}
for(register int j=0;j<=k+1;j++)g[j]=0;
for(register int i=head[now];i;i=e[i].next)
{
if(e[i].to==father)continue;
for(register int j=0;j<=k+1;j++)g[j]+=f[e[i].to][j];
}
f[now][0]=size[now];
if(!flag){for(register int i=1;i<=k+1;i++)f[now][i]=0;return ;}
for(register int j=1;j<=k+1;j++)
{
f[now][j]=inf;
for(register int i=head[now];i;i=e[i].next)
{
if(e[i].to==father)continue;
// cout<<"???:"<<now<<" "<<e[i].to<<" "<<j<<" "<<min(j-1,k-(j-1))<<" "<<f[e[i].to][j-1]<<" "<<g[min(j-1,k-(j-1))]-f[e[i].to][min(j-1,k-(j-1))]<<endl;
if(min(j-1,k-(j-1))<0)continue;
f[now][j]=min(f[now][j],f[e[i].to][j-1]+g[min(j-1,k-(j-1))]-f[e[i].to][min(j-1,k-(j-1))]);
}
}
for(register int j=1;j<=k+1;j++)f[now][j]=min(f[now][j],f[now][j-1]);
// cout<<"WTF:"<<now<<" "<<dist[now]<<endl;
// for(register int j=0;j<=k+1;j++)cout<<f[now][j]<<" ";cout<<endl;
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
n=read(),k=read();
for(register int i=1;i<n;i++)
{
int x=read(),y=read();
add_edge(x,y);add_edge(y,x);
}
dfs(1,0);
printf("%d\n",f[1][k+1]);
return 0;
}
|
a.cc: In function 'void dfs(int, int)':
a.cc:39:9: error: reference to 'size' is ambiguous
39 | size[now]=1;int flag=0;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:29:5: note: 'int size [2020]'
29 | int size[N];
| ^~~~
a.cc:40:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
40 | for(register int i=head[now];i;i=e[i].next)
| ^
a.cc:44:17: error: reference to 'size' is ambiguous
44 | size[now]+=size[e[i].to];dist[now]=max(dist[now],dist[e[i].to]+1);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:29:5: note: 'int size [2020]'
29 | int size[N];
| ^~~~
a.cc:44:28: error: reference to 'size' is ambiguous
44 | size[now]+=size[e[i].to];dist[now]=max(dist[now],dist[e[i].to]+1);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:29:5: note: 'int size [2020]'
29 | int size[N];
| ^~~~
a.cc:45:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
45 | for(register int j=1;j<=k+1;j++)f[now][j]+=f[e[i].to][j];
| ^
a.cc:47:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
47 | for(register int j=0;j<=k+1;j++)g[j]=0;
| ^
a.cc:48:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
48 | for(register int i=head[now];i;i=e[i].next)
| ^
a.cc:51:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
51 | for(register int j=0;j<=k+1;j++)g[j]+=f[e[i].to][j];
| ^
a.cc:53:19: error: reference to 'size' is ambiguous
53 | f[now][0]=size[now];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:29:5: note: 'int size [2020]'
29 | int size[N];
| ^~~~
a.cc:54:36: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
54 | if(!flag){for(register int i=1;i<=k+1;i++)f[now][i]=0;return ;}
| ^
a.cc:55:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
55 | for(register int j=1;j<=k+1;j++)
| ^
a.cc:58:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
58 | for(register int i=head[now];i;i=e[i].next)
| ^
a.cc:66:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
66 | for(register int j=1;j<=k+1;j++)f[now][j]=min(f[now][j],f[now][j-1]);
| ^
a.cc: In function 'int main()':
a.cc:75:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
75 | for(register int i=1;i<n;i++)
| ^
|
s267515729
|
p04049
|
C++
|
// In the name of god
#include <bits/stdC++.h>
#pragma GCC optimze("02")
using namespace std;
using ll =long long;
const ll maxn=2e3+5,inf=1e18;
ll n,m=inf,k,x,y,h[maxn],num[2][maxn];
bool mark[maxn];
vector <ll> adj[maxn];
pair <ll,ll> p[maxn];
void dfs(int u,int v){
mark[u]=1;
for(int j:adj[u]){
if(!mark[j]&&j!=v){
h[j]=h[u]+1;
num[0][h[u]+1]++;
dfs(j,v);
}
}
}
void dfs2(int u,int v){
mark[u]=1;
for(int j:adj[u]){
if(!mark[j]&&j!=v){
h[j]=h[u]+1;
num[1][h[u]+1]++;
dfs2(j,v);
}
}
}
void dfs3(int u){
mark[u]=1;
for(int j:adj[u]){
if(!mark[j]){
h[j]=h[u]+1;
num[0][h[j]]++;
dfs3(j);
}
}
}
int main(){
ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
cin>>n>>k;
for(int i=1;i<n;i++){
cin>>x>>y;
x--;
y--;
p[i]={x,y};
adj[y].push_back(x);
adj[x].push_back(y);
}
if(k%2==1){
for(int i=1;i<n;i++){
dfs(p[i].first,p[i].second);
dfs2(p[i].second,p[i].first);
x=0;
for(int j=(k+1)/2;j<=n;j++){
x+=num[0][j];
x+=num[1][j];
}
m=min(m,x);
for(int j=0;j<=n;j++){
h[j]=0;
num[0][j]=0;
num[1][j]=0;
mark[j]=0;
}
}
}
else{
for(int i=0;i<n;i++){
dfs3(i);
x=0;
for(int j=(k/2)+1;j<=n;j++){
x+=num[0][j];
}
m=min(m,x);
for(int j=0;j<=n;j++){
h[j]=0;
num[0][j]=0;
num[1][j]=0;
mark[j]=0;
}
}
}
cout<<m;
}
|
a.cc:2:10: fatal error: bits/stdC++.h: No such file or directory
2 | #include <bits/stdC++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s816248367
|
p04049
|
C++
|
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define trill pair<ll,pill>
#define F f
#define S s.f
#define T s.s;
using namespace std;
const ll N = 2011;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;
ll n, k;
bool del[N];
vector<ll> g[N];
trill bfs(ll s) {
queue<pill> x;
x.push({s, 0});
trill rstM = {0, {0, 0}};
bool w[N] = {0};
w[s] = 1;
while(x.size()) {
ll v = x.front().f, rst = x.front().s;
if(rstM.F < rst)
rstM = {rst, {0, 0}};
if(rstM.F == rst)
rstM.T++;
x.pop();
for(auto u : g[v]){
if(!w[u] && !del[u])
w[u] = 1,x.push({u, rst + 1});
}
}
return rstM;
}
pill dia() {
trill g1 = bfs(1);
trill g2 = bfs(g1.S);
trill g3 = bfs(g2.S);
if(g3.T > g2.T)
return g3;
else
return g2;
}
int main() {
speed;
cin >> n >> k;
rep(1, n, 1){
ll a,b;
cin >> a >> b;
g[a].pb(b), g[b].pb(a);
}
rep(0, n, 1) {
pill g1 = dia();
if(g1.f <= k)
cout << i,ex;
del[g1.s] = 1;
}
}
/*
Code written by
Codeforces : I_Love_Trott
mail : dzhon.snoudin@mail.ru
*/
|
a.cc: In function 'std::pair<long long int, std::pair<long long int, long long int> > bfs(long long int)':
a.cc:45:33: error: expected primary-expression before ';' token
45 | rstM.T++;
| ^
a.cc: In function 'std::pair<long long int, long long int> dia()':
a.cc:59:17: error: expected primary-expression before '>' token
59 | if(g3.T > g2.T)
| ^
a.cc:18:14: error: expected ')' before ';' token
18 | #define T s.s;
| ^
a.cc:59:22: note: in expansion of macro 'T'
59 | if(g3.T > g2.T)
| ^
a.cc:59:11: note: to match this '('
59 | if(g3.T > g2.T)
| ^
a.cc:59:23: error: expected primary-expression before ')' token
59 | if(g3.T > g2.T)
| ^
a.cc:61:9: error: 'else' without a previous 'if'
61 | else
| ^~~~
a.cc:62:24: error: could not convert 'g2' from 'pair<[...],std::pair<long long int, long long int>>' to 'pair<[...],long long int>'
62 | return g2;
| ^~
| |
| pair<[...],std::pair<long long int, long long int>>
|
s478627316
|
p04049
|
C++
|
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define trill pair<ll,pill>
#define F f
#define S s.f
#define T s.s;
using namespace std;
const ll N = 2011;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;
ll n, k;
bool del[N];
vector<ll> g[N];
trill bfs(ll s) {
queue<pill> x;
x.push({s, 0});
trill rstM = {0, {0, 0}};
bool w[N] = {0};
w[s] = 1;
while(x.size()) {
ll v = x.front().f, rst = x.front().s;
if(rstM.F < rst)
rstM = {rst, {0, 0}};
if(rstM.F == rst)
rstM.T++;
x.pop();
for(auto u : g[v]){
if(!w[u] && !del[u])
w[u] = 1,x.push({u, rst + 1});
}
}
return rstM;
}
pill dia() {
trill g1 = bfs(1);
trill g2 = bfs(g1.S);
trill g3 = bfs(g2.S);
if(g3.T > g2.T)
return g3;
else
return g2;
}
int main() {
speed;
cin >> n >> k;
rep(1, n, 1){
ll a,b;
cin >> a >> b;
g[a].pb(b), g[b].pb(a);
}
rep(0, n, 1) {
pill g1 = dia();
if(g1.f <= k)
cout << i,ex;
del[g1.s] = 1;
}
}
/*
Code written by
Codeforces : I_Love_Trott
mail : dzhon.snoudin@mail.ru
*/
|
a.cc: In function 'std::pair<long long int, std::pair<long long int, long long int> > bfs(long long int)':
a.cc:45:33: error: expected primary-expression before ';' token
45 | rstM.T++;
| ^
a.cc: In function 'std::pair<long long int, long long int> dia()':
a.cc:59:17: error: expected primary-expression before '>' token
59 | if(g3.T > g2.T)
| ^
a.cc:18:14: error: expected ')' before ';' token
18 | #define T s.s;
| ^
a.cc:59:22: note: in expansion of macro 'T'
59 | if(g3.T > g2.T)
| ^
a.cc:59:11: note: to match this '('
59 | if(g3.T > g2.T)
| ^
a.cc:59:23: error: expected primary-expression before ')' token
59 | if(g3.T > g2.T)
| ^
a.cc:61:9: error: 'else' without a previous 'if'
61 | else
| ^~~~
a.cc:62:24: error: could not convert 'g2' from 'pair<[...],std::pair<long long int, long long int>>' to 'pair<[...],long long int>'
62 | return g2;
| ^~
| |
| pair<[...],std::pair<long long int, long long int>>
|
s779725992
|
p04049
|
C++
|
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define trill pair<ll,pill>
#define F f
#define S s.f
#define T s.s;
using namespace std;
const ll N = 2011;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;
ll n, k;
bool del[N];
vector<ll> g[N];
trill bfs(ll s) {
queue<pill> x;
x.push({s, 0});
trill rstM = {0, {0, 0}};
bool w[N] = {0};
w[s] = 1;
while(x.size()) {
ll v = x.front().f, rst = x.front().s;
if(rstM.F < rst)
rstM = {rst, {0, 0}};
if(rstM.F == rst)
rstM.T++;
x.pop();
for(auto u : g[v]){
if(!w[u] && !del[u])
w[u] = 1,x.push({u, rst + 1});
}
}
return rstM;
}
pill dia() {
trill g1 = bfs(1);
trill g2 = bfs(g1.s);
trill g3 = bfs(g2.s);
if(g3.T > g2.T)
return g3;
else
return g2;
}
int main() {
speed;
cin >> n >> k;
rep(1, n, 1){
ll a,b;
cin >> a >> b;
g[a].pb(b), g[b].pb(a);
}
rep(0, n, 1) {
pill g1 = dia();
if(g1.f <= k)
cout << i,ex;
del[g1.s] = 1;
}
}
/*
Code written by
Codeforces : I_Love_Trott
mail : dzhon.snoudin@mail.ru
*/
|
a.cc: In function 'std::pair<long long int, std::pair<long long int, long long int> > bfs(long long int)':
a.cc:45:33: error: expected primary-expression before ';' token
45 | rstM.T++;
| ^
a.cc: In function 'std::pair<long long int, long long int> dia()':
a.cc:8:11: error: cannot convert 'std::pair<long long int, long long int>' to 'long long int'
8 | #define s second
| ^
| |
| std::pair<long long int, long long int>
a.cc:57:27: note: in expansion of macro 's'
57 | trill g2 = bfs(g1.s);
| ^
a.cc:8:11: note: initializing argument 1 of 'std::pair<long long int, std::pair<long long int, long long int> > bfs(long long int)'
8 | #define s second
| ^
a.cc:34:14: note: in expansion of macro 's'
34 | trill bfs(ll s) {
| ^
a.cc:8:11: error: cannot convert 'std::pair<long long int, long long int>' to 'long long int'
8 | #define s second
| ^
| |
| std::pair<long long int, long long int>
a.cc:58:27: note: in expansion of macro 's'
58 | trill g3 = bfs(g2.s);
| ^
a.cc:8:11: note: initializing argument 1 of 'std::pair<long long int, std::pair<long long int, long long int> > bfs(long long int)'
8 | #define s second
| ^
a.cc:34:14: note: in expansion of macro 's'
34 | trill bfs(ll s) {
| ^
a.cc:59:17: error: expected primary-expression before '>' token
59 | if(g3.T > g2.T)
| ^
a.cc:18:14: error: expected ')' before ';' token
18 | #define T s.s;
| ^
a.cc:59:22: note: in expansion of macro 'T'
59 | if(g3.T > g2.T)
| ^
a.cc:59:11: note: to match this '('
59 | if(g3.T > g2.T)
| ^
a.cc:59:23: error: expected primary-expression before ')' token
59 | if(g3.T > g2.T)
| ^
a.cc:61:9: error: 'else' without a previous 'if'
61 | else
| ^~~~
a.cc:62:24: error: could not convert 'g2' from 'pair<[...],std::pair<long long int, long long int>>' to 'pair<[...],long long int>'
62 | return g2;
| ^~
| |
| pair<[...],std::pair<long long int, long long int>>
|
s802978187
|
p04049
|
C++
|
s
|
a.cc:2:1: error: 's' does not name a type
2 | s
| ^
|
s374143347
|
p04049
|
C++
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
namespace io
{
#define SIZ (1 << 21 | 1)
#define gc() (io::iS == io::iT ? (io::iT= (io::iS= io::ibuff) + fread(io::ibuff, 1, SIZ, stdin), (io::iS == io::iT ? EOF : *io::iS++)) : *io::iS++)
#define putc(x) (io::oS == io::oT ? (fwrite(io::obuff, 1, io::oS - io::obuff, stdout), io::oS= io::obuff, (*io::oS++= x)) : *io::oS++= x)
#define exit \
fwrite(io::obuff, 1, io::oS - io::obuff, stdout); \
return 0;
char *iS, *iT, ibuff[SIZ], obuff[SIZ], *oS= obuff, *oT= oS + SIZ - 1, fu[110], c;
int fr;
template <class Type>
inline void read(Type &x)
{
x= 0;
Type y= 1;
for(c= gc(); (c > '9' || c < '0') && c != '-'; c= gc())
;
c == '-' ? y= -1 : x= (c & 15);
for(c= gc(); c >= '0' && c <= '9'; c= gc()) x= x * 10 + (c & 15);
x*= y;
}
inline void reads(char *x)
{
for(c= gc(); c == ' ' || c == '\n'; c= gc())
;
for(; c != ' ' && c != '\n' && c != EOF; *x= c, c= gc(), ++x)
;
}
template <class Type>
inline void print(Type x, char text= '\n')
{
if(x < 0) putc('-'), x*= -1;
if(x == 0) putc('0');
while(x) fu[++fr]= x % 10 + '0', x/= 10;
while(fr) putc(fu[fr--]);
putc(text);
}
inline void prints(char *x, char *y= NULL, char text= '\n')
{
for(; *x && x != y; ++x) putc(*x);
putc(text);
}
} // namespace io
using io::print;
using io::prints;
using io::read;
using io::reads;
#define N 2001
int n, k, head[N], cnt, dis[N], ans= 2147483647;
struct Edge
{
int a, b;
} e[N << 1];
inline void add(int a, int b) { e[++cnt].a= head[a], e[cnt].b= b, head[a]= cnt; }
inline void dfs(int x, int y, int z)
{
dis[x]= dis[y] + 1;
for(int i= head[x]; i; i= e[i].a)
{
if(e[i].b == y || e[i].b == z) continue;
dfs(e[i].b, x);
}
}
signed main()
{
read(n), read(k);
for(int i= 1, a, b; i < n; i++) read(a), read(b), add(a, b), add(b, a);
dis[0]= -1;
if(k & 1)
{
for(int i= 1; i < n; i++)
{
int a= e[(i << 1) - 1].b, b= e[i << 1].b;
dfs(a, 0, b), dfs(b, 0, a);
int x= 0;
for(int j= 1; j <= n; j++)
if(dis[j] >= (k >> 1)) ++x;
ans= min(ans, x);
}
}
else
{
for(int i= 1; i <= n; i++)
{
dfs(i, 0, 0);
int x= 0;
for(int j= 1; j <= n; j++)
if(dis[j] > (k >> 1)) ++x;
ans= min(ans, x);
}
}
print(ans);
exit;
}
|
a.cc: In function 'void dfs(int, int, int)':
a.cc:75:20: error: too few arguments to function 'void dfs(int, int, int)'
75 | dfs(e[i].b, x);
| ~~~^~~~~~~~~~~
a.cc:69:13: note: declared here
69 | inline void dfs(int x, int y, int z)
| ^~~
|
s549959540
|
p04049
|
C++
|
#include <iostream>
//#include <bits/stdc++.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb(x) push_back(x)
#define F first
#define S second
using namespace std;
const int N=2000;
vector<int> g[N];
int n;
int ok;
//int lvl[N];
//int parent[N];
bool used[N];
int k;
dfs(int u,int level){
// lvl[u]=level;
// parent[u]=p;
if(level>k/2){
ok++;
}
used[u]=true;
for(auto x:g[u]){
if(used[x]==false){
dfs(x,level+1);
}
}
}
void solve(){
scanf("%d%d",&n,&k);
int x,y;
loop(i,1,n){
scanf("%d%d",&x,&y);
x--;
y--;
g[y].pb(x);
g[x].pb(y);
}
//distance kitna hai k/2
vector<int> ans;
loop(i,0,n){
ok=0;
memset(used,0,sizeof(used));
dfs(i,0);
ans.pb(ok);
}
cout<<*min_element(ans.begin(),ans.end());
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}
|
a.cc:22:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
22 | dfs(int u,int level){
| ^~~
a.cc: In function 'int dfs(int, int)':
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
34 | }
| ^
|
s898531467
|
p04049
|
C++
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
#define maxn 5000010
void read(int &x) {
int f = 1;
x = 0;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
x *= f;
}
struct node {
int to;
int nxt;
} edge[maxn];
int tot, head[maxn], maxx, vis[maxn], ans, cnt;
void add(int x, int y) {
edge[cnt].to = y;
edge[cnt].nxt = head[x];
head[x] = cnt++;
}
void dfs(int now, int fa, int stp) {
tot++;
if (stp == 0) return;
for (int i = head[now]; ~i; i = edge[i].nxt) {
if (edge[i].to == fa) {
continue;
}
dfs(edge[i].to, now, stp - 1);
}
}
int n, k;
int main() {
read(n), read(k);
int u, v, del;
for (int i = 0; i <= n; i++) head[i] = -1;
for (int i = 0; i < n - 1; i++) {
read(u), read(v);
add(u, v);
add(v, u);
}
ans = 0;
if (k % 2 == 0) { // k为偶数,枚举点,跑k/2的边
for (int i = 1; i <= n; i++) {
tot = 0;
dfs(i, 0, k / 2);
ans = max(tot, ans);
}
} else { // k为奇数,枚举边,跑k/2的点for (u = 1; u <= n; u++) {
for (int j = head[u]; ~j; j = edge[j].nxt) {
tot = 0;
int t = edge[j].to;
dfs(t, u, k / 2);
dfs(u, t, k / 2);
ans = max(tot, ans);
}
}
}
cout << n - ans << endl;
}
|
a.cc:73:1: error: 'cout' does not name a type
73 | cout << n - ans << endl;
| ^~~~
a.cc:74:1: error: expected declaration before '}' token
74 | }
| ^
|
s115842694
|
p04049
|
C++
|
#include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 7;
int n, k, mindel[N][N], dep[N][N];
vector<int> g[N];
bool vis[N];
void dfs(int a) {
mindel[a][0] = 1;
vector<int> kids;
vis[a] = 1;
for (auto &b : g[a]) {
if (vis[b] == 0) {
dfs(b);
mindel[a][0] += mindel[b][0];
kids.push_back(b);
}
}
if (kids.empty()) {
for (int i = 1; i <= k; i++) {
mindel[a][i] = 0;
}
return;
}
for (int len = 1; len <= k; len++) {
mindel[a][len] = mindel[a][i - 1];
int other = k - len;
other = min(other, len - 1);
for (auto &power : kids) {
int cur = mindel[power][len - 1];
for (auto &b : kids) {
if (b != power) {
cur += mindel[b][other];
}
}
mindel[a][len] = min(mindel[a][len], cur);
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
k++;
for (int i = 1; i < n; i++) {
int x, y;
cin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
dfs(1);
int ans = (int) 1e9;
for (int i = 1; i <= n; i++) {
ans = min(ans, mindel[i][k] + n - mindel[i][0]);
}
cout << ans << "\n";
}
|
a.cc: In function 'void dfs(int)':
a.cc:28:32: error: 'i' was not declared in this scope
28 | mindel[a][len] = mindel[a][i - 1];
| ^
|
s970249183
|
p04049
|
C++
|
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;
template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
int main() {
int n, k; scanf("%d%d", &n, &k);
std::vector<int> a(n - 1), b(n - 1);
std::vector<std::vector<int>> g(n);
for(int i = 0; i < n - 1; i++) {
scanf("%d%d", &a[i], &b[i]);
a[i]--; b[i]--;
g[a[i]].push_back(i);
g[b[i]].push_back(i);
}
int ans = n;
for(int i = 0; i < n; i++) {
int v = a[id] ^ b[id] ^ i;
auto dfs = [&](auto&& dfs, int v, int par, int d) -> int {
if(d > k / 2) return 0;
int ret = 1;
for(auto id: g[v]) {
int to = a[id] ^ b[id] ^ v;
ret += dfs(dfs, to, v, d + 1);
}
return ret;
};
if(k & 1) {
// 中心が二つ
for(auto id: g[i]) {
int to = a[id] ^ b[id] ^ i;
int ret = dfs(dfs, to, i, 0) + dfs(dfs, i, to, 0);
ans = std::min(ans, n - ret);
}
} else {
int ret = dfs(dfs, i, -1, 0);
ans = std::min(ans, n - ret);
}
}
printf("%d\n", ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:31:27: error: 'id' was not declared in this scope; did you mean 'i'?
31 | int v = a[id] ^ b[id] ^ i;
| ^~
| i
|
s866680360
|
p04049
|
C++
|
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 2010;
bool bye[maxn];
vector<int> edge[maxn];
int n, k;
vector<int> dp[maxn];
int sz[maxn];
void dfs1(int now, int last = -1){
sz[now] = 1;
for(int u : edge[now])if(u != last)
dfs1(u, now), sz[now] += sz[u];
}
//
//void dfs2(int now, int last = -1){
// for(int u : edge[now])if(u != last){
// dfs2(u, now);
// if(dp[u].size() > dp[now].size())
// swap(dp[u], dp[now]);
// for(int i = (int)dp[now].size()-1;i > 0;--i){
// auto get = [&](const vector<int> &a, const vector<int> &b){
// if(a.size() <= i)return maxn;
// int p = min({max(k-i, 0), i});
// return a[i] + (p >= b.size() ? 0 : b[p]);
// };
// dp[now][i] = min( get(dp[u], dp[now]), get(dp[now], dp[u]) );
// }
// for(int i = 1;i < dp[now].size();++i)
// dp[now][i] = min(dp[now][i-1], dp[now][i]);
// }
// auto tmp = dp[now];
// vector<int> &dp = ::dp[now];
// dp.resize( max(2, (int)tmp.size()+1) );
// dp[0] = sz[now];
// for(int i = 0;i < tmp.size();++i)
// dp[i+1] = tmp[i];
// //for(int i= 1;i < dp.size();++i)
// //assert(dp[i] <= dp[i-1]);
// //cerr << "now " << now << ' ' << dp.size() << '\n';
//}
void dfs2(int now, int last = -1){
dp[now] = {0};
for(int u : edge[now])if(u != last){
dfs2(u, now)
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> k;
for(int i = 1, a, b;i < n;++i){
cin >> a >> b;
edge[a].pb(b);
edge[b].pb(a);
}
dfs1(1);
dfs2(1);
cout << (dp[1].size() <= k+1 ? dp[1].back() : dp[1][k+1]) << '\n';
}
|
a.cc: In function 'void dfs2(int, int)':
a.cc:46:29: error: expected ';' before 'signed'
46 | dfs2(u, now)
| ^
| ;
47 | signed main(){
| ~~~~~~
a.cc:58:2: error: expected '}' at end of input
58 | }
| ^
a.cc:45:44: note: to match this '{'
45 | for(int u : edge[now])if(u != last){
| ^
a.cc:58:2: error: expected '}' at end of input
58 | }
| ^
a.cc:43:34: note: to match this '{'
43 | void dfs2(int now, int last = -1){
| ^
|
s672684745
|
p04049
|
C++
|
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read()
{
ll ans=0;ll a=1;char c=getchar();
for(;c<'0'||c>'9';c=getchar())if(c=='-')a=-1;
for(;c>='0'&&c<='9';c=getchar())ans=ans*10+c-48;
return ans*a;
}
ll a[2001][2001],maxx;
vector<ll> p[2001];
ll se[2001],fi[2001],n,k,cnt;
void dfs(ll root,ll fa,ll poi,ll s)
{
a[root][poi]=s;
for(ll i=0;i<p[poi].size();i++)
{
ll x=p[poi][i];
if(x==fa)
{
continue ;
}
dfs(root,poi,x,s+1);
}
}
int main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
maxx=ll_MAX;
n=read();
k=read();
for(ll i=1;i<n;i++)
{
ll x=read();
ll y=read();
p[x].push_back(y);
p[y].push_back(x);
fi[i]=y;
se[i]=x;
}
for(ll i=1;i<=n;i++)
{
dfs(i,0,i,0);
}
for(ll i=1;i<=n;i++)
{
ll cnt=0;
for(ll j=1;j<=n;j++)
{
if(2*a[i][j]>k)cnt++;
}
maxx=min(maxx,cnt);
}
for(ll i=1;i<n;i++)
{
cnt=0;
for(ll j=1;j<=n;j++)
{
if(2*(min(a[j][fi[i]],a[j][se[i]])+1)>k)
cnt++;
}
maxx=min(maxx,cnt);
}
cout<<maxx<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:31:14: error: 'll_MAX' was not declared in this scope
31 | maxx=ll_MAX;
| ^~~~~~
|
s119212965
|
p04049
|
C++
|
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
vvi graph(100);
vvi lineDistances(100, vi(100));
vvb visited(100, vb(100, false));
vi vertexA, vertexB;
int number, diameter;
void dfs(int root, int start, int distanceInLines)
{
//preVisitRecursion.
visited[root][start]=true;
lineDistances[root][start]=distanceInLines;
for(int next : graph[start])
{
if(!visited[root][next])
{
dfs(root, next, distanceInLines+1);
}
}
//postVisitRecursion.
return;
}
void usingDFS()
{
cin>>number>>diameter;
int vertex0, vertex1;
for(int i=1; i<number; ++i)
{
cin>>vertex0>>vertex1;
graph[vertex0].push_back(vertex1);
graph[vertex1].push_back(vertex0);
vertexA.push_back(vertex0);
vertexB.push_back(vertex1);
}
for(int vertex=1; vertex<=number; ++vertex)
{
dfs(vertex, vertex, 0);
}
int minimum=40000;
for(int i=1; i<=number; ++i)
{
int counter=0;
for(int j=1; j<=number; ++j)
{
if(lineDistances[i][j]>diameter/2)
{
++counter;
}
}
minimum=min(minimum, counter);
}
int dotA, dotB, tempMaxDist;
for(int i=0; i<vertexA.size(); ++i)
{
int counter=0;
dotA=vertexA[i];
dotB=vertexB[i];
for(int j=1; j<=number; ++j)
{
tempMaxDist=min(lineDistances[j][dotA], lineDistances[j][dotB]);
if(tempMaxDist>(diameter-1)/2)
{
++counter;
}
}
minimum=min(minimum, counter);
}
cout<<endl<<minimum<<endl;
return;
}
/*
template<typename Type>
void showContent(Type inputVector)
{
for(int i=1; i<=number; ++i)
{
for(int j=1; j<=number; ++j)
{
cout<<"["<<i<<"]["<<j<<"] <- "<<inputVector[i][j]<<endl;
}
}
return;
}
*/
int main()
{
ios :: sync_with_stdio(false);
cout << fixed << setprecision(16);
usingDFS();
//cout<<endl;
//showContent(visited);
//cout<<endl;
//showContent(lineDistances);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:93:26: error: 'setprecision' was not declared in this scope
93 | cout << fixed << setprecision(16);
| ^~~~~~~~~~~~
a.cc:3:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
2 | #include <vector>
+++ |+#include <iomanip>
3 | using namespace std;
|
s516442803
|
p04049
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main() {
int V, K; cin >> V >> K;
vector<vector<int>> g(n);
for (int i = 0; i < V-1; i++) {
int u, v; cin >> u >> v; u--; v--;
g[u].push_back(v);
g[v].push_back(u);
}
int res = 0;
auto dfs = [&](auto f, int n, int p, int d) -> int {
if (d == 0) return 0;
int cnt = 1;
for (auto x : g[n]) {
if (x == p) continue;
cnt += f(f, x, n, d-1);
}
return cnt;
};
for (int i = 0; i < V; i++) {
for (auto x : g[i]) {
res = max(res, V - dfs(dfs, i, x, K) + 1);
}
}
cout << res << endl;
}
|
a.cc: In function 'int main()':
a.cc:5:25: error: 'n' was not declared in this scope
5 | vector<vector<int>> g(n);
| ^
|
s129970063
|
p04049
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);
template<class T> inline bool chmin(T &a,T b){
if (a>b){a=b; return true;}
return false;
}
template<class T> inline bool chmax(T &a,T b){
if (a<b){a=b; return true;}
return false;
}
const int MAX_N=2010;
int N,K,ans=0,c=0;
vector<vector<int>> G(MAX_N);
vector<vector<int>> d(MAX_N,vector<int>(MAX_N));
void dfs(int v,int p,int r,int &cnt){
for (auto nv:G[v]){
if (nv==p) continue;
d[r][nv]=d[r][v]+1;
if (d[r][nv]<=K) ++c;
dfs(nv,v,r,c);
}
if (p==r) chmax(ans,cnt),cnt=0;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> K;
rep(i,N-1){
int a,b; cin >> a >> b; --a,--b;
G[a].push_back(b);
G[b].push_back(a);
}
rep(i,N) d[i][i]=0;
rep(i,N) dfs(i,-1,i,c);
cout << N-ans-1 << endl;
}
|
a.cc:39:30: error: stray '\16' in program
39 | if (p==r) chmax(ans,cnt),<U+000E>cnt=0;
| ^~~~~~~~
|
s292964027
|
p04049
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;cin>>N>>K;
vector<vector<int>> A(N);
for(int i=0;i<N;i++){
int a,b;cin>>a>>b;
A[a-1].push_back(b-1);
A[b-1].push_back(a-1);
}
int diameter=0,best_s=-1;
for(int s=0;s<N;s++){
queue<int> q;
vector<int> dist(N,-1);
q.push(s);dist[s]=0;
while(q.size()){
int attend=q.front();q.pop();
for(int next=0;next<A[attend].size();next++){
if(dist[next]==-1){
q.push(next);dist[next]=dist[attend]+1;
if(diameter<dist[next]+1){
diameter=dist[next]+1;best_s=s;
}
}
}
}
}
int centor[2]={-1,-1};
queue<int> q;
vector<int> dist(N,-1);
q.push(best_s);dist[best_s]=0;
while(q.size()){
int attend=q.front();q.pop();
for(int next=0;next<A[attend].size();next++){
if(dist[next]==-1){
q.push(next);dist[next]=dist[attend]+1;
if(dist[next]==(diameter-1)/2)centor[0]=next;
if(dist[next]==(diameter)/2)centor[1]=next;
}
}
}
vector<int> dist2(2*N,-1);
for(int i=0;i<2;i++){
queue<int> q;q.push(centor[i]);
dist2[centor[i]+N*i]=0;
while(q.size()){
int attend=q.front();q.pop();
for(int next=0;next<A[attend].size();next++){
if(dist2[next+N*i]==-1){
q.push(next);dist2[next+N*i]=dist2[attend+N*i]+1;
}
}
}
}
int ans=0;
int t=K/2;
for(int i=0;i<N;i++){
if(dist2[i]>t||dist2[i+N]>t)ans++
}
if((K+diameter)%2=1)ans--;
cout<<ans;
}
|
a.cc: In function 'int main()':
a.cc:63:38: error: expected ';' before '}' token
63 | if(dist2[i]>t||dist2[i+N]>t)ans++
| ^
| ;
64 | }
| ~
a.cc:65:18: error: lvalue required as left operand of assignment
65 | if((K+diameter)%2=1)ans--;
| ~~~~~~~~~~~~^~
|
s070195508
|
p04049
|
C++
|
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
#include <bits/stdc++.h>
#include <windows.h>
#define ll long long
#define X first
#define Y second
#define MP make_pair
using namespace std;
/*
const int MAX_MEM = 1e8;
int mpos=0;
char mem[MAX_MEM];
inline void * operator new(size_t n){
char *res = mem + mpos;
mpos += n;
assert(mpos <= MAX_MEM);
return (void *)res;
}
inline void operator delete(void *){}
*/
const int N = 2e3 + 1;
int n, k, ans[N], t;
vector<int> g[N];
void dfs(int v, int pr=0, int d=0){
if(d > k / 2){
ans[t] += 1;
}
for(int u: g[v]){
if(pr == u)
continue;
dfs(u, v, d + 1);
}
}
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for(int i = 1;i < n;i++){
int x, y;
cin >> x >> y;
g[x].push_back(y), g[y].push_back(x);
}
for(int i = 1;i <= n;i++){
t = i;
dfs(i);
}
int res = n;
for(int i = 1;i <= n;i++)
res = min(res, ans[i]);
cout << res;
}
|
a.cc:11:10: fatal error: windows.h: No such file or directory
11 | #include <windows.h>
| ^~~~~~~~~~~
compilation terminated.
|
s005815628
|
p04049
|
C++
|
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define y1 y_golabi
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
typedef pair<int , string> pis;
typedef pair<int , pair<int , int> > piii;
const int MAXN = 2e3 + 10;
int n , k , u , v , mn , h[MAXN];
pii edge[MAXN];
vector<int> adj[MAXN];
int dfs(int u)
{
int ans = (k / 2 < h[u]);
for(auto v : adj[u])
if(h[v] == -1)
h[v] = h[u] + 1 , ans += dfs(v);
return ans;
}
void input()
{
cin >> n >> k;
for(int i = 0 ; i < n - 1 ; i ++)
cin >> u >> v , u -- , v -- , adj[u].pb(v) , adj[v].pb(u) , edge[i] = mp(u , v);
return;
}
int32_t main()
{
input() , mn = INT_MAX;
/*for(int i = 0 ; i < n - 1 ; i ++)
cout << edge[i].f << " " << edge[i].s << " ";
cout << endl;*/
/*for(int i = 0 ; i < n ; i ++)
{
for(auto j : adj[i])
cout << "adj[i][j]: " << j << " ";
cout << endl;
}*/
if(!(k % 2))
for(int i = 0 ; i < n ; i ++)
mem(h , -1) , h[i] = 0 , mn = min(mn , dfs(i));
else
for(int i = 0 ; i < n - 1 ; i ++)
mem(h , -1) , h[edge[i].f] = h[edge[i].s] = 0 , mn = min(mn , dfs(edge[i].f) + dfs(edge[i].s));
return cout << mn << endl , 0;
}
|
a.cc: In function 'int32_t main()':
a.cc:63:24: error: 'INT_MAX' was not declared in this scope
63 | input() , mn = INT_MAX;
| ^~~~~~~
a.cc:23:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
22 | #include <complex>
+++ |+#include <climits>
23 | using namespace std;
|
s626406921
|
p04049
|
C++
|
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2005;
int n,m,t,p,ans;
int d[N],first[N],v[N],w[N],next[N];
struct Node{
int u,v;
}e[N];
void add(int x,int y)
{
t++;
next[t]=first[x];
first[x]=t;
v[t]=y;
}
void dfs(int x,int father)
{
int i,j;
for(i=first[x];i;i=next[i])
{
j=v[i];
if(j==father)
continue;
d[j]=d[x]+1;
dfs(j,x);
}
}
int main()
{
int x,y,z,i,k,u;
scanf("%d%d",&n,&k);
m=k/2;
ans=0x3f3f3f3f;
for(i=2;i<=n;++i)
{
scanf("%d%d",&x,&y);
e[i].u=x;
e[i].v=y;
add(x,y);
add(y,x);
}
if ((k&1)==0){
int res=0;
for (int i=1;i<=n;i++){
res = d[i] = 0;
dfs(i,i);
for (int j=1;j<=n;j++) if(d[j]>m) ++res;
ans = min(ans,res);
}
}
else{
int res = 0;
for (int i=2;i<=n;i++){
d[e[i].u] = d[e[i].v] = res = 0;
dfs(e[i].u,e[i].v);
dfs(e[i].v,e[i].u);
for (int j=1;j<=n;j++) if(d[j]>m) ++res;
ans = min(ans,res);
}
}
printf("%d\n",ans);
return 0;
}
|
a.cc: In function 'void add(int, int)':
a.cc:14:9: error: reference to 'next' is ambiguous
14 | next[t]=first[x];
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from a.cc:3:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:29: note: 'int next [2005]'
7 | int d[N],first[N],v[N],w[N],next[N];
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:21:28: error: reference to 'next' is ambiguous
21 | for(i=first[x];i;i=next[i])
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:29: note: 'int next [2005]'
7 | int d[N],first[N],v[N],w[N],next[N];
| ^~~~
|
s055557354
|
p04049
|
C++
|
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2005;
int n,m,t,p,ans;
int d[N],first[N],v[N],w[N],next[N];
struct Node{
int u,v;
}e[N];
void add(int x,int y)
{
t++;
next[t]=first[x];
first[x]=t;
v[t]=y;
}
void dfs(int x,int father)
{
int i,j;
for(i=first[x];i;i=next[i])
{
j=v[i];
if(j==father)
continue;
d[j]=d[x]+1;
dfs(j,x);
}
}
int main()
{
int x,y,z,i,k,u;
scanf("%d%d",&n,&k);
m=k/2;
ans=0x3f3f3f3f;
for(i=2;i<=n;++i)
{
scanf("%d%d",&x,&y);
e[i].u=x;
e[i].v=y;
add(x,y);
add(y,x);
}
if ((k&1)==0){
int res=0;
for (int i=1;i<=n;i++){
res = d[i] = 0;
dfs(i,i);
for (int j=1;j<=n;j++) if(d[j]>m) ++res;
ans = min(ans,res);
}
}
else{
int res = 0;
for (int i=2;i<=n;i++){
d[e[i].u] = d[e[i].v] = res = 0;
dfs(e[i].u,e[i].v);
dfs(e[i].v,e[i].u);
for (int j=1;j<=n;j++) if(d[j]>m) ++res;
ans = min(ans,res);
}
}
printf("%d\n",ans);
return 0;
}
|
a.cc: In function 'void add(int, int)':
a.cc:14:9: error: reference to 'next' is ambiguous
14 | next[t]=first[x];
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from a.cc:3:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:29: note: 'int next [2005]'
7 | int d[N],first[N],v[N],w[N],next[N];
| ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:21:28: error: reference to 'next' is ambiguous
21 | for(i=first[x];i;i=next[i])
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:29: note: 'int next [2005]'
7 | int d[N],first[N],v[N],w[N],next[N];
| ^~~~
|
s305320909
|
p04049
|
C++
|
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
typedef long long int ll;
int n,k;
vector<int> G[2100];
int dfs(int t,int f,int k,int depth=0){
int cnt=0;
if(depth>=k)cnt++;
for(auto d:G[t]){
if(d==f)continue;
cnt+=dfs(d,t,k,depth+1);
}
return cnt;
}
int main(){
cin >> n >> k;
for(int i=0;i<n-1;i++){
int a,b; cin >> a >> b;
a--; b--;
G[a].push_back(b);
G[b].push_back(a);
}
int ans=n;
for(int i=0;i<n;i++){
int cnt=0;
for(int t:G[i]){
cnt+=dfs(t,i,k/2);
}
ans=min(ans,cnt);
}
for(int i=0;i<n;i++){
for(int t:G[i]){
int cnt=dfs(t,i,(k+1)/2)+dfs(t,s,(k+1)/2);
ans=min(ans,cnt);
}
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:40:56: error: 's' was not declared in this scope
40 | int cnt=dfs(t,i,(k+1)/2)+dfs(t,s,(k+1)/2);
| ^
|
s306229540
|
p04049
|
C++
|
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long
int N, K;
vector<vector<int>> tree;
void rec(int v, int p, int d, vector<int> &depth) {
depth[v] = d;
for(auto u : tree[v]) {
if(u == p) continue;
rec(u, v, d + 1, depth);
}
}
void solve() {
cin >> N >> K;
tree.assign(N, vector<int>());
rep(i, N - 1) {
int a, b; cin >> a >> b; a --; b --;
tree[a].push_back(b); tree[b].push_back(a);
}
vector<int> depth(N);
if(K % 2 == 0) {
int ans = N;
rep(v, N) {
rec(v, -1, 0, depth);
int cnt = 0;
rep(u, N) {
if(depth[u] > K / 2) cnt ++;
}
ans = min(ans, res);
}
cout << ans << endl;
} else {
int ans = N;
rep(v, N) {
for(auto u : tree[v]) {
rec(u, v, 0, depth); rec(v, u, 0, depth);
int cnt = 0;
rep(w, N) {
if(depth[w] > K / 2) cnt ++;
}
ans = min(ans, cnt);
}
cout << ans << endl;
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
//cout << fixed << setprecision(10);
//init();
solve();
//cout << "finish" << endl;
return 0;
}
|
a.cc: In function 'void solve()':
a.cc:76:28: error: 'res' was not declared in this scope; did you mean 'rec'?
76 | ans = min(ans, res);
| ^~~
| rec
|
s911513904
|
p04049
|
C++
|
#include <bits/stdc++.h>
#include <random>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
//#define int unsigned __int128
//#define ll unsigned __int128
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;
#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif
const double PI = 2 * acos(0.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
return out << "{" << a.first << ", " << a.second << "}";
}
template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}
template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}";
}
template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
out << "[";
fori (i, a.size())
out << a[i] << vector<string>{", ", "] "}[i + 1 == a.size()];
return out;
}
void smain();
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
freopen("input.txt", "r", stdin);
clock_t start = clock();
#else
//freopen("dictionary.in", "r", stdin);
//freopen("dictionary.out", "w", stdout);
#endif
cout << setprecision(12) << fixed;
smain();
#ifdef RUS_HOME
cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) / CLOCKS_PER_SEC << endl;
#endif
return 0;
}
const int N = 2e3 + 100, oo = 1e9;
vi g[N];
vector <bool> us(N);
vi nm(N);
multiset <int> st[N];
int n, k;
void dfs(int v) {
st[v].insert(0);
set <pii> s;
for (int i = 0; i < g[v].size(); i++) {
int to = g[v][i];
if (!us[to]) {
us[to] = true;
nm[to] = v;
dfs(to);
if (st[to].size()) {
auto it = st[to].end();
it--;
s.insert({*it, to});
}
}
}
while (s.size() >= 2) {
auto it = s.end(); it--;
auto p1 = *it;
it--;
auto p2 = *it;
if (p1.first + p2.first + 2 > k) {
auto it2 = st[p1.second].end();
it2--;
st[p1.second].erase(it2);
s.erase(p1);
if (st[p1.second].size()) {
it2 = st[p1.second].end();
it2--;
s.insert({*it2, p1.second});
}
} else
break;
}
for (int i = 0; i < g[v].size(); i++) {
int to = g[v][i];
if (nm[to] == v) {
for (auto p : st[to]) {
if (p < k - 1) {
st[v].insert(p + 1);
}
}
st[to].clear();
}
}
}
void smain() {
cin >> n >> k;
for (int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
int ans = oo;
for (int i = 1; i <= n; i++) {
us[i] = true;
dfs(i);
ans = min(ans, n - st[i].size());
st[i].clear();
fill(ALL(us), 0);
fill(ALL(nm), 0);
}
cout << ans;
}
|
a.cc: In function 'void smain()':
a.cc:179:18: error: no matching function for call to 'min(ll&, long long unsigned int)'
179 | ans = min(ans, n - st[i].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:179:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
179 | ans = min(ans, n - st[i].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:179:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
179 | ans = min(ans, n - st[i].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
|
s934899211
|
p04049
|
C++
|
#include <bits/stdc++.h>
#include <random>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
//#define int unsigned __int128
//#define ll unsigned __int128
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;
#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif
const double PI = 2 * acos(0.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
return out << "{" << a.first << ", " << a.second << "}";
}
template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}
template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}";
}
template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
out << "[";
fori (i, a.size())
out << a[i] << vector<string>{", ", "] "}[i + 1 == a.size()];
return out;
}
void smain();
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
freopen("input.txt", "r", stdin);
clock_t start = clock();
#else
//freopen("dictionary.in", "r", stdin);
//freopen("dictionary.out", "w", stdout);
#endif
cout << setprecision(12) << fixed;
smain();
#ifdef RUS_HOME
cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) / CLOCKS_PER_SEC << endl;
#endif
return 0;
}
const int N = 2e3 + 100, oo = 1e9;
vi g[N];
vector <bool> us(N);
vi nm(N);
multiset <int> st[N];
int n, k;
void dfs(int v) {
st[v].insert(0);
set <pii> s;
for (int i = 0; i < g[v].size(); i++) {
int to = g[v][i];
if (!us[to]) {
us[to] = true;
nm[to] = v;
dfs(to);
if (st[to].size()) {
auto it = st[to].end();
it--;
s.insert({*it, to});
}
}
}
while (s.size() >= 2) {
auto it = s.end(); it--;
auto p1 = *it;
it--;
auto p2 = *it;
if (p1.first + p2.first + 2 > k) {
auto it2 = st[p1.second].end();
it2--;
st[p1.second].erase(it2);
s.erase(p1);
if (st[p1.second].size()) {
it2 = st[p1.second].end();
it2--;
s.insert({*it2, p1.second});
}
} else
break;
}
for (int i = 0; i < g[v].size(); i++) {
int to = g[v][i];
if (nm[to] == v) {
for (auto p : st[to]) {
if (p < k - 1) {
st[v].insert(p + 1);
}
}
st[to].clear();
}
}
}
void smain() {
cin >> n >> k;
for (int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
int ans = oo;
for (int i = 1; i <= n; i++) {
us[i] = true;
dfs(i);
inmin(ans, n - st[i].size());
st[i].clear();
fill(ALL(us), 0);
fill(ALL(nm), 0);
}
cout << ans;
}
|
a.cc: In function 'void smain()':
a.cc:31:28: error: no matching function for call to 'min(ll&, long long unsigned int)'
31 | #define inmin(a, b) a = min(a, (b))
| ~~~^~~~~~~~
a.cc:179:9: note: in expansion of macro 'inmin'
179 | inmin(ans, n - st[i].size());
| ^~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:31:28: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
31 | #define inmin(a, b) a = min(a, (b))
| ~~~^~~~~~~~
a.cc:179:9: note: in expansion of macro 'inmin'
179 | inmin(ans, n - st[i].size());
| ^~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:31:28: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
31 | #define inmin(a, b) a = min(a, (b))
| ~~~^~~~~~~~
a.cc:179:9: note: in expansion of macro 'inmin'
179 | inmin(ans, n - st[i].size());
| ^~~~~
|
s510905105
|
p04049
|
C++
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
using namespace std;
const int Maxn = 4000 + 100;
int Begin[Maxn], To[Maxn], Next[Maxn], e;
int sum[Maxn], dis[Maxn];
int n, K, maxi;
vector<int> graph[Maxn];
void add_edge(int x, int y)
{
To[++e] = y;
Next[e] = Begin[x];
Begin[x] = e;
}
void dfs (int x, int fa)
{
maxi = max(maxi, dis[x]);
sum[dis[x]] ++;
for (int i = 0; i < graph[x].size(); i++)
{
int y = graph[x][i];
if (y == fa)
continue;
dis[y] = dis[x] + 1;
dfs(y, x);
}
}
int main()
{
cin >> n >> K;
for (int i = 1; i < n; ++i)
{
int x, y;
cin >> x >> y;
graph[x].push_back(y);
graph[y].push_back(x);
add_edge(x, y);
add_edge(y, x);
}
int ans = 1000 * 1000 * 1000;
for (int i = 1; i <= n; ++i)
{
memset(sum, 0, sizeof(sum));
memset(dis, 0, sizeof(dis));
maxi = 0;
dfs(i, 0);
int cnt = 0;
for (int j = K / 2 + 1; j <= maxi; ++j)
cnt += sum[j];
if (!(K & 1))
{
ans = min(ans, cnt);
}
else
{
for (int j = Begin[i]; j; j = Next[j])
{
int y = To[j];
int tmp = 0;
memset(sum, 0, sizeof(sum));
memset(dis, 0, sizeof(dis));
maxi = 0;
dfs(i, y);
for (int k = K / 2 + 1; k <= maxi; ++k)
{
tmp += sum[k];
}
memset(sum, 0, sizeof(sum));
memset(dis, 0, sizeof(dis));
maxi = 0;
dfs(y, i);
for (int k = K / 2 + 1; k <= maxi; k++)
{
tmp += sum[k];
}
ans = min(ans, tmp);
}
}
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:59:9: error: 'memset' was not declared in this scope
59 | memset(sum, 0, sizeof(sum));
| ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
13 | #include<numeric>
+++ |+#include <cstring>
14 |
|
s351829924
|
p04049
|
C++
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
using namespace std;
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int N = 5 * 1000 + 5;
int n, k;
int ans = 0;
vector<int> graph[N];
int dis[N];
bool mark[N];
int jvb = mod;
void input()
{
cin >> n >> k;
for (int i = 0 ; i < n - 1; i++)
{
int u, v;
cin >> u >> v;
graph[u - 1].push_back(v - 1);
graph[v - 1].push_back(u -1 );
}
}
void dfs(int v)
{
mark[v] = true;
for (int i = 0; i < graph[v].size(); i++)
{
if (!mark[graph[v][i]])
{
dfs(graph[v][i]);
dis[i] = dis[v] + 1;
if (dis[i] > k / 2)
{
ans++;
}
}
}
}
int main()
{
input();
for (int i = 0; i < n; i++)
{
memset(mark, 0, sizeof mark);
ans = 0;
dfs(i);
jvb = min(jvb, ans);
}
cout << jvb << endl;
}
|
a.cc: In function 'int main()':
a.cc:59:17: error: 'memset' was not declared in this scope
59 | memset(mark, 0, sizeof mark);
| ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
13 | #include<numeric>
+++ |+#include <cstring>
14 |
|
s730233535
|
p04049
|
C
|
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e9;
vector<int> dist[2020];
vector<int> edge[2020];
int vis[2020];
int e[2020];
int N,K;
int dfs(int pos,int dis)
{
int res = 0;
vis[pos] = 1;
if(dis>K/2) res++;
for(int i = 0;i < dist[pos].size();i++){
if(!vis[dist[pos][i]]){
res += dfs(dist[pos][i],dis+1);
//cout<<"res:"<<res<<endl;
}
}
return res;
}
int main()
{
cin>>m;
scanf("%d%d",&N,&K);
for(int i = 1;i <= N-1;i++){
int a,b;
scanf("%d%d",&a,&b);
dist[a].push_back(b);
dist[b].push_back(a);
edge[a].push_back(i);
edge[b].push_back(i);
}
for(int i = 1;i <= N;i++){
if(edge[i].size()>=2){
for(int j = 0;j < edge[i].size();j++){
for(int k = )
}
}
}
if(K%2==0){
int ans = INF;
for(int i = 1;i <= N;i++){
memset(vis,0,sizeof(vis));
ans = min(dfs(i,0),ans);
}
cout<<ans<<endl;
}
else{
K = K + 1;
}
return 0;
}
|
main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s442984377
|
p04049
|
C++
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 2010;
vector<int> edge[N];
pair<int,int> e[N];
bool vis[N];
int cnt;
void dfs(int n,int k){
vis[n]=1;cnt++;
if(k==0) return ;
for(int i=0;i<edge[n].size();i++){
if(!vis[edge[n][i]]) dfs(edge[n][i],k-1);
}
}
int main(){
int n,k;cin>>n>>k;
for(int i=1;i<=n-1;i++){
int a,b;cin>>a>>b;
e[i].first=a;e[i].second=b;
edge[a].push_back(b);
edge[b].push_back(a);
}
int ans=n;
if(k&1){
for(int i=1;i<=n-1;i++){
cnt=0;
memset(vis,0,sizeof vis);
vis[e[i].second]=1;
dfs(e[i].first,k/2);
dfs(e[i].second,k/2);
int tmp=n-cnt;
ans=min(tmp,ans);
}
}else{
for(int i=1;i<=n;i++){
cnt=0;
memset(vis,0,sizeof vis);
dfs(i,k/2);
cout<<cnt<<endl;
int tmp=n-cnt;
ans=min(tmp,ans);
}
}
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:30:13: error: 'memset' was not declared in this scope
30 | memset(vis,0,sizeof vis);
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <cmath>
+++ |+#include <cstring>
5 | using namespace std;
a.cc:40:13: error: 'memset' was not declared in this scope
40 | memset(vis,0,sizeof vis);
| ^~~~~~
a.cc:40:13: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s583083431
|
p04049
|
C++
|
#include<iostream>
#include<vector>
#include<algorithm>
#using namespace std;
struct Unionfind{
vector<int> par;
Unionfind(int n):par(n){
for(int i=0;i<n;i++){
par[i]=i;
}
}
/*int root(int x){
if(par[x]==x) return x;
return par[x]=root(par[x]);
}*/
int root(int x){
int p=x;
//int q=n;
int i=0;
while(p!=par[p]){
//q=par[p];
p=par[p];
i++;
}
return par[x];
}
int root_dist(int x){
int p=x;
//int q=n;
int i=0;
while(p!=par[p]){
//q=par[p];
p=par[p];
i++;
}
return i;
}
void unite(int x,int y){
int rx=root(x);
int ry=root(y);
if(rx==ry) return;
par(rx)=ry;
}
}
int main(){
int n,k;
Unionfind tree(n);
int a,b;
for(int i=0;i<n-1;i++){
cin>>a>>b;
tree.unite(a-1, b-1);
}
vector<int> dist;
int r=tree.root(n-1);
for(int j=0;j<n;j++){
dist[j]=tree.root_dist(r);
}
sort(dist.begin(),dist.end());
int ans=dist[0]+dist[1];
cout<<ans<<endl;
return 0;
}
|
a.cc:4:2: error: invalid preprocessing directive #using
4 | #using namespace std;
| ^~~~~
a.cc:7:3: error: 'vector' does not name a type
7 | vector<int> par;
| ^~~~~~
a.cc:45:4: error: expected ';' after struct definition
45 | }
| ^
| ;
a.cc: In constructor 'Unionfind::Unionfind(int)':
a.cc:8:20: error: class 'Unionfind' does not have any field named 'par'
8 | Unionfind(int n):par(n){
| ^~~
a.cc:10:7: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
10 | par[i]=i;
| ^~~
| __pstl::execution::v1::par
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
from /usr/include/c++/14/algorithm:86,
from a.cc:3:
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
| ^~~
a.cc: In member function 'int Unionfind::root(int)':
a.cc:21:16: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
21 | while(p!=par[p]){
| ^~~
| __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
| ^~~
a.cc:26:14: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
26 | return par[x];
| ^~~
| __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
| ^~~
a.cc: In member function 'int Unionfind::root_dist(int)':
a.cc:32:16: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
32 | while(p!=par[p]){
| ^~~
| __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
| ^~~
a.cc: In member function 'void Unionfind::unite(int, int)':
a.cc:43:9: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
43 | par(rx)=ry;
| ^~~
| __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
| ^~~
a.cc: In function 'int main()':
a.cc:51:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
51 | cin>>a>>b;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:54:3: error: 'vector' was not declared in this scope
54 | vector<int> dist;
| ^~~~~~
a.cc:54:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'std::vector'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/vector:93:13: note: 'std::pmr::vector'
93 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
| ^~~~~~
a.cc:54:10: error: expected primary-expression before 'int'
54 | vector<int> dist;
| ^~~
a.cc:57:5: error: 'dist' was not declared in this scope
57 | dist[j]=tree.root_dist(r);
| ^~~~
a.cc:59:8: error: 'dist' was not declared in this scope
59 | sort(dist.begin(),dist.end());
| ^~~~
a.cc:59:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
59 | sort(dist.begin(),dist.end());
| ^~~~
| std::sort
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
| ^~~~
a.cc:61:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
61 | cout<<ans<<endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:61:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
61 | cout<<ans<<endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s761212225
|
p04049
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int n,d,hed[2010],cnt,k,fa[2010],dep[2010],ans=2e9,book[2010];
struct node
{
int from,to,next;
}a[100010];
void add(int from,int to)
{
a[cnt++].to=to;
a[cnt].from=from;
a[cnt].next=hed[from];
hed[from]=cnt;
}
void dfs(int x)
{
for(int i=hed[x];i;i=a[i].next)
{
int y=a[i].to;
if(fa[x]==y||book[y])
continue;
dep[y]=dep[x]+1;
fa[y]=x;
dfs(y);
}
}
int main()
{
cin>>n>>k;
cnt=1;
for(int i=1;i<n;i++)
{
int ls,lss;
cin>>ls>>lss;
add(ls,lss);
add(lss,ls);
}
if(k%2)
{
for(int i=2;i<=cnt;i++)
{
memset(fa,0,sizeof(fa));
memset(dep,0,sizeof(dep));
book[a[i].to]=1;
dfs(a[i].from);
int ji=0;
for(int j=1;j<=n;j++)
{
if(dep[j]>k/2)
j++i;
}
memset(fa,0,sizeof(fa));
memset(dep,0,sizeof(dep));
book[a[i].from]=1;
book[a[i].to]=0;
dfs(a[i].to);
for(int j=1;j<=n;j++)
{
if(dep[j]>k/2)
j++i;
}
book[a[i].from]=0;
ans=min(ans,ji);
}
}
else
{
for(int i=1;i<=n;i++)
{
memset(fa,0,sizeof(fa));
memset(dep,0,sizeof(dep));
dfs(i);
int ji=0;
for(int j=1;j<=n;j++)
{
if(dep[j]>k/2)
ji++;
}
ans=min(ans,ji);
}
}
cout<<ans;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:51:36: error: expected ';' before 'i'
51 | j++i;
| ^
| ;
a.cc:61:36: error: expected ';' before 'i'
61 | j++i;
| ^
| ;
|
s135064672
|
p04049
|
C++
|
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,k,d[2005],m,sum[2005],ans,ans2;
pair<int,int> a[2005];
bool l[2005],u[2005];
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++)
l[i]=true;
while(cin>>a[++m].first>>a[m].second);
for(int i=1;i<=m;i++)
{
l[a[i].first]=false;
if(a[i].first==1)
d[a[i].second]=2,sum[2]++;
else
d[a[i].second]=d[a[i].first]+1,sum[d[a[i].second]]++;
}
queue<int> q;
while(!q.empty())
{
q.push(x);
for()
}
for()
ans=99999;
k/=2;
for(int i=1;i<=n;i++)
if(d[i]>k)
ans2++;
cout<<ans2;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:36:24: error: 'x' was not declared in this scope
36 | q.push(x);
| ^
a.cc:37:21: error: expected primary-expression before ')' token
37 | for()
| ^
a.cc:38:9: error: expected primary-expression before '}' token
38 | }
| ^
a.cc:37:22: error: expected ';' before '}' token
37 | for()
| ^
| ;
38 | }
| ~
a.cc:38:9: error: expected primary-expression before '}' token
38 | }
| ^
a.cc:37:22: error: expected ')' before '}' token
37 | for()
| ~ ^
| )
38 | }
| ~
a.cc:38:9: error: expected primary-expression before '}' token
38 | }
| ^
a.cc:39:13: error: expected primary-expression before ')' token
39 | for()
| ^
a.cc:42:9: error: expected primary-expression before 'for'
42 | for(int i=1;i<=n;i++)
| ^~~
a.cc:41:14: error: expected ')' before 'for'
41 | k/=2;
| ^
| )
42 | for(int i=1;i<=n;i++)
| ~~~
a.cc:39:12: note: to match this '('
39 | for()
| ^
|
s272183171
|
p04049
|
C++
|
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
const int MAX = 1010;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
typedef pair<int, int>P;
int dx[4] = { 1,0,-1,0 };//D,R,U,L
int dy[4] = { 0,1,0,-1 };
const int MAX_N = 1 << 17;
const int MAX_V = 2020;
int n, dat[2 * MAX_N - 1];
int id[MAX_V];
void init2(int n_) {
n = 1;
while (n < n_)n *= 2;
for (int i = 0; i < 2 * n - 1; i++)dat[i] = INT_MAX;
}
void update(int k, int a) {
k += n + 1;
dat[k] = a;
while (k > 0) {
k = (k - 1) / 2;
dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
void rmq_init(int depth[], int n) {
init2(n);
REP(i, n) {
update(i, depth[i]);
}
}
int query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)return INT_MAX;
if (a <= l && r <= b)return dat[k];
else {
int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return min(vl, vr);
}
}
vector<int>G[MAX_V];
int root;
int vs[MAX_V * 2 - 1];
int depth[MAX_V * 2 - 1];
int V;
void dfs(int v, int p, int d, int &k) {
id[v] = k;
vs[k] = v;
depth[k++] = d;
for (int i = 0; i < G[v].size(); i++) {
if (G[v][i] != p) {
dfs(G[v][i], v, d + 1, k);
vs[k] = v;
depth[k++] = d;
}
}
}
void init(int V) {
int k = 0;
dfs(root, -1, 0, k);
rmq_init(depth, V * 2 - 1);
}
int lca(int u, int v) {
return vs[query(min(id[u], id[v]), max(id[u], id[v]) + 1, (ll)0, (ll)0, 2*V-1)];
}
int dist(int a, int b) {
int par = lca(a, b);
return depth[id[a]] + depth[id[b]] - 2 * depth[id[par]];
}
int A[2020], B[2020];
signed main() {
int N, K; cin >> N >> K;
V = N;
root = 0;
//G[0].pb(1); G[1].pb(0);
REP(i, N-1) {
int a, b; cin >> a >> b;
a--, b--;
A[i] = a, B[i] = b;
G[a].pb(b);
G[b].pb(a);
}
init(N);
int ans = INF;
if (K % 2 == 0) {
REP(i, N) {
pe(i);
int res = 0;
REP(j, N) {
if (j == i)continue;
if (dist(i, j) > K / 2)res++;
}
ans = min(ans, res);
print(res);
}
}
else {
REP(i, N - 1) {
int res = 0;
pe(i);
int l = A[i], r = B[i];
REP(j, N) {
if (j == l || j == r)continue;
int d = min(dist(l, j), dist(r, j));
if (d > (K - 1) / 2)res++;
}
print(res);
ans = min(ans, res);
}
}
print(ans);
int x, y; cin >> x >> y;
x--, y--;
print(lca(x, y));
print(dist(x, y));
}
|
a.cc: In function 'void init2(long long int)':
a.cc:55:53: error: 'INT_MAX' was not declared in this scope
55 | for (int i = 0; i < 2 * n - 1; i++)dat[i] = INT_MAX;
| ^~~~~~~
a.cc:15:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
14 | #include<bitset>
+++ |+#include <climits>
15 |
a.cc: In function 'long long int query(long long int, long long int, long long int, long long int, long long int)':
a.cc:75:37: error: 'INT_MAX' was not declared in this scope
75 | if (r <= a || b <= l)return INT_MAX;
| ^~~~~~~
a.cc:75:37: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
|
s734993467
|
p04049
|
C++
|
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const double pi=acos(-1);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
int n,k;
vector<int>g[2005];
int dfs(int x,int p,int deepth,int mx)
{
int ans=1;
if(deepth!=mx)
{
for(int i=0;i<g[x].size();i++)
if(i!=p)
ans+=dfs(i,x,deepth+1,mx);
}
return ans;
}
int main()
{
cin>>n>>k;
for(int i=0;i<n-1;i++)
{
int x,y;
cin>>x>>y;
g[x].pb(y);
g[y].pb(x);
}
int ans=0;
if(k%2==0)
for(int i=1;i<=n;i++)
ans=max(ans,dfs(i,-1,0,k/2));
else
{
for(int i=1;i<=n;i++)
for(int j=0;j<g[i].size();j++)
ans=max(ans,dfs(i,g[i][j],0,k/2)+dfs(g[i][j],i,0,k/2));
}
cout<<n-ans;
return 0;
}
|
a.cc:5:17: error: 'acos' was not declared in this scope
5 | const double pi=acos(-1);
| ^~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.