submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s224816126 | p03837 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#define MAX 100000007
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;
ll ans=0;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int N,M;
int a[100]={0},b[100]={0},c[100]={0};
int dist[1000][1000]=100000000;
cin >> N >> M;
for(int i=0;i<M;i++){
cin >> a[i] >> b[i] >> c[i];
a[i]--,b[i]--;
}
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(i==j){
dist[i][j]=0;
}else {
dist[i][j]=100000000;
}
}
}
for(int i=0;i<M;i++){
dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
}
for(int k = 0; k < N; ++k){
for(int i = 0; i < N; ++i){
for(int j = 0; j < N; ++j){
dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
}
}
}
int ans=M;
for(int i = 0; i < M; ++i){
bool shortest=false;
for(int j = 0; j < N; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
if(shortest==true){
ans=ans-1;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:29:24: error: array must be initialized with a brace-enclosed initializer
29 | int dist[1000][1000]=100000000;
| ^~~~~~~~~
|
s221012171 | p03837 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#define MAX 100000007
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;
ll ans=0;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int N,M;
int a[100]={0},b[100]={0},c[100]={0};
int dist[1000][1000]=MAX;
cin >> N >> M;
for(int i=0;i<M;i++){
cin >> a[i] >> b[i] >> c[i];
a[i]--,b[i]--;
}
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(i==j){
dist[i][j]=0;
}else {
dist[i][j]=MAX;
}
}
}
for(int i=0;i<M;i++){
dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
}
for(int k = 0; k < N; ++k){
for(int i = 0; i < N; ++i){
for(int j = 0; j < N; ++j){
dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
}
}
}
int ans=M;
for(int i = 0; i < M; ++i){
bool shortest=false;
for(int j = 0; j < N; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
if(shortest==true){
ans=ans-1;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:15:13: error: array must be initialized with a brace-enclosed initializer
15 | #define MAX 100000007
| ^~~~~~~~~
a.cc:29:24: note: in expansion of macro 'MAX'
29 | int dist[1000][1000]=MAX;
| ^~~
|
s448311891 | p03837 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#define MAX 100000007
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;
ll ans=0;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int N,M;
int a[100]={0},b[100]={0},c[1000]={0};
int dist[1000][1000]={0};
cin >> N >> M;
for(int i=0;i<M;i++){
cin >> a[i] >> b[i] >> c[i];
a[i]--,b[i]--;
}
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(i==j){
dist[i][j]=0;
}else {
dist[i][j]=MAX;
}
}
}
for(int i=0;i<M;i++){
dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
dist[b[i]][a[i]]=dist[a[i]][b[i]];
}
for(int k = 0; k < N; ++k){
for(int i = 0; i < N; ++i){
for(int j = 0; j < N; ++j){
dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
}
}
}
int ans=M;
for(int i = 0; i < M; ++i){
bool shortest=false;
for(int j = 0; j < N; ++j) if(dist[j][a[i]]+c[i]=<=dist[j][b[i]]) shortest=true;
if(shortest==true){
ans=ans-1;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:58:54: error: expected primary-expression before '<=' token
58 | for(int j = 0; j < N; ++j) if(dist[j][a[i]]+c[i]=<=dist[j][b[i]]) shortest=true;
| ^~
|
s272890932 | p03837 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#define MAX 100000007
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;
ll ans=0;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int N,M;
int a[100]={0},b[100]={0},c[1000]={0};
int dist[1000][1000]={0};
cin >> N >> M;
for(int i=0;i<M;i++){
cin >> a[i] >> b[i] >> c[i];
a[i]--,b[i]--;
}
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(i==j){
dist[i][j]=0;
}else {
dist[i][j]=MAX;
}
}
}
for(int i=0;i<M;i++){
dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
dist[b[i]][a[i]]=dist[a[i]][b[i]];
}
for(int k = 0; k < n; ++k){
for(int i = 0; i < n; ++i){
for(int j = 0; j < n; ++j){
dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
}
}
}
int ans=m;
for(int i = 0; i < m; ++i){
bool shortest=false;
for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]=<=dist[j][b[i]]) shortest=true;
if(shortest==true){
ans=ans-1;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:48:22: error: 'n' was not declared in this scope
48 | for(int k = 0; k < n; ++k){
| ^
a.cc:55:11: error: 'm' was not declared in this scope
55 | int ans=m;
| ^
a.cc:58:24: error: 'n' was not declared in this scope
58 | for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]=<=dist[j][b[i]]) shortest=true;
| ^
a.cc:58:54: error: expected primary-expression before '<=' token
58 | for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]=<=dist[j][b[i]]) shortest=true;
| ^~
|
s809836866 | p03837 | C++ | //#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())
using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;
ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
const int MAX_V = 110;
int d[MAX_V][MAX_V];
void setCost(int d[MAX_V][MAX_V], int s, int e, int cost){
d[s][e] = d[e][s] = cost;
}
int
main(void){
int n, m;
cin >> n >> m;
const int V = n;
REP(i, V){
REP(j, V){
if (i == j) d[i][j] = 0;
else d[i][j] = MOD;
}
}
ll a[n], b[n], c[n];
REP(i, m){
cin >> a[i] >> b[i] >> c[i];
setCost(d, a[i]-1, b[i]-1, c[i]);
}
// Warshall Floyd
REP(k, V){
REP(i, V){
REP(j, V){
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
}
int ans=0;
FOr(i, 1, m+1){
if(d[a[i]][b[i]] < c[i]) ++ans;
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:75:7: error: 'i' was not declared in this scope
75 | FOr(i, 1, m+1){
| ^
a.cc:75:3: error: 'FOr' was not declared in this scope; did you mean 'FOR'?
75 | FOr(i, 1, m+1){
| ^~~
| FOR
|
s616862218 | p03837 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 110;
const ll MAX_N = 100010;
const ll INF = 1e12;
vector<pair<ll, ll> > g[MAX_N]; // firstに最短距離, secondに頂点番号
ll d[MAX_N];
int n; // 頂点数
bool used[MAX_N][MAX_N];
int pr[MAX_N]; // 最短路の直前の頂点
// bellman ford法で負辺がない場合。計算量はO(|E|log|V|)
void dijkstra(int s){
priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > PQ;
for(int i=1;i<=n;i++) d[i] = INF;
for(int i=1;i<=n;i++) pr[i] = -1;
d[s] = 0;
PQ.push(make_pair(0, s));
while(!PQ.empty()){
pair<ll, ll> p = PQ.top(); PQ.pop();
int v = p.second;
if(d[v] < p.first) continue;
for(auto gvi: g[v]){
ll cost = gvi.first;
int u = gvi.second;
if(d[u] > d[v] + cost){
d[u] = d[v] + cost;
PQ.push(make_pair(d[u], u));
pr[u] = v;
}
}
}
}
// 頂点tへの最短路
void get_path(int t){
for(;t!=-1;t=pr[t]){
used[t][pr[t]] = true;
used[pr[t]][t] = true;
}
}
int main(){
cin.tie(0);
ios_base::sync_with_stdio(false);
int m; cin >> n >> m;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
used[i][j] = true;
}
}
for(int i=0;i<m;i++){
ll a, b, c; cin >> a >> b >> c;
g[a].push_back(make_pair(c, b));
g[b].push_back(make_pair(c, a));
used[a][b] = false;
used[b][a] = false;
}
for(int i=1;i<=n;i++){
dijkstra(i);
for(int j=i+1;j<=n;j++){
// cout << i << " " << j << " " << d[j] << endl;
get_path(j);
}
}
int cnt = 0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
if(used[i][j] == false) cnt++;
}
}
cout << cnt << endl;
} | /tmp/ccIoRXMM.o: in function `dijkstra(int)':
a.cc:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `pr' defined in .bss section in /tmp/ccIoRXMM.o
a.cc:(.text+0x2d6): relocation truncated to fit: R_X86_64_PC32 against symbol `pr' defined in .bss section in /tmp/ccIoRXMM.o
/tmp/ccIoRXMM.o: in function `get_path(int)':
a.cc:(.text+0x37d): relocation truncated to fit: R_X86_64_PC32 against symbol `pr' defined in .bss section in /tmp/ccIoRXMM.o
a.cc:(.text+0x3b3): relocation truncated to fit: R_X86_64_PC32 against symbol `pr' defined in .bss section in /tmp/ccIoRXMM.o
a.cc:(.text+0x3e9): relocation truncated to fit: R_X86_64_PC32 against symbol `pr' defined in .bss section in /tmp/ccIoRXMM.o
collect2: error: ld returned 1 exit status
|
s174770094 | p03837 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 110;
const ll MAX_N = 100010;
const ll INF = 1e12;
vector<pair<ll, ll> > g[MAX_N]; // firstに最短距離, secondに頂点番号
ll d[MAX_N];
int n; // 頂点数
bool used[MAX_N][MAX_N];
int pr[MAX_N]; // 最短路の直前の頂点
// bellman ford法で負辺がない場合。計算量はO(|E|log|V|)
void dijkstra(int s){
priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > PQ;
for(int i=1;i<=n;i++) d[i] = INF;
for(int i=1;i<=n;i++) pr[i] = -1;
d[s] = 0;
PQ.push(make_pair(0, s));
while(!PQ.empty()){
pair<ll, ll> p = PQ.top(); PQ.pop();
int v = p.second;
if(d[v] < p.first) continue;
for(auto gvi: g[v]){
ll cost = gvi.first;
int u = gvi.second;
if(d[u] > d[v] + cost){
d[u] = d[v] + cost;
PQ.push(make_pair(d[u], u));
pr[u] = v;
}
}
}
}
// 頂点tへの最短路
void get_path(int t){
for(;t!=-1;t=pr[t]){
used[t][pr[t]] = true;
used[pr[t]][t] = true;
}
}
int main(){
cin.tie(0);
ios_base::sync_with_stdio(false);
int m; cin >> n >> m;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
used[i][j] = true;
}
}
for(int i=0;i<m;i++){
ll a, b, c; cin >> a >> b >> c;
g[a].push_back(make_pair(c, b));
g[b].push_back(make_pair(c, a));
used[a][b] = false;
used[b][a] = false;
}
for(int i=1;i<=n;i++){
dijkstra(i);
for(int j=i+1;j<=n;j++){
// cout << i << " " << j << " " << d[j] << endl;
get_path(j);
}
}
int cnt = 0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
if(used[i][j] == false) cnt++;
}
}
cout << cnt << endl;
} | /tmp/cc4VS7b2.o: in function `dijkstra(int)':
a.cc:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `pr' defined in .bss section in /tmp/cc4VS7b2.o
a.cc:(.text+0x2d6): relocation truncated to fit: R_X86_64_PC32 against symbol `pr' defined in .bss section in /tmp/cc4VS7b2.o
/tmp/cc4VS7b2.o: in function `get_path(int)':
a.cc:(.text+0x37d): relocation truncated to fit: R_X86_64_PC32 against symbol `pr' defined in .bss section in /tmp/cc4VS7b2.o
a.cc:(.text+0x3b3): relocation truncated to fit: R_X86_64_PC32 against symbol `pr' defined in .bss section in /tmp/cc4VS7b2.o
a.cc:(.text+0x3e9): relocation truncated to fit: R_X86_64_PC32 against symbol `pr' defined in .bss section in /tmp/cc4VS7b2.o
collect2: error: ld returned 1 exit status
|
s204218974 | p03837 | C++ | n,m = list(map(int,input().split()))
d = []
for i in range(m):
a,b,c = list(map(int,input().split()))
d.append([a-1,b-1,c])
e = [[100000 for i in range(n)] for j in range(n)]
for i in range(n):
e[i][i] = 0
for i in d:
e[i[0]][i[1]] = i[2]
e[i[1]][i[0]] = i[2]
for k in range(n):
for i in range(n):
for j in range(n):
e[i][j] = min(e[i][j],e[i][k]+e[k][j])
ans = 0
for i in d:
if e[i[0]][i[1]] != i[2]:
ans += 1
print(ans) | a.cc:1:1: error: 'n' does not name a type
1 | n,m = list(map(int,input().split()))
| ^
|
s168702438 | p03837 | C++ | c++.h"
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
#define MOD 1e9 + 7
#define PAI 3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;
ll gcd(ll a,ll b){
if(a < b)swap(a , b);
if(a % b == 0) return b;
else gcd(b, a%b);
}
ll lcm(ll a,ll b){
if(a < b)swap(a , b);
return (a/gcd(a , b))*b;
}
int main(){
int n,m;
cin >> n >> m;
int a[1000],b[1000],c[1000],dist[100][100] = {0};
for(int i = 0 ; i < m ; i++){
cin >> a[i] >> b[i] >> c[i];
a[i]--; b[i]--;
}
rep(i,n){
rep(j,n){
if(i != j)dist[i][j] = inf;
}
}
rep(i,m){
dist[a[i]][b[i]] = min(dist[a[i]][b[i]] , c[i]);
dist[b[i]][a[i]] = min(dist[b[i]][a[i]] , c[i]);
}
rep(k,n){
rep(i,n){
rep(j,n){
dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
}
}
}
int ans = m;
rep(i,m){
bool flag = false;
rep(j,n) if(dist[j][a[i]]+c[i] == dist[j][b[i]])flag = true;
if(flag) ans--;
}
pr(ans);
return 0;
}
| a.cc:1:6: warning: missing terminating " character
1 | c++.h"
| ^
a.cc:1:6: error: missing terminating " character
a.cc:1:1: error: 'c' does not name a type
1 | c++.h"
| ^
a.cc: In function 'long long int gcd(long long int, long long int)':
a.cc:28:12: error: 'swap' was not declared in this scope
28 | if(a < b)swap(a , b);
| ^~~~
a.cc: In function 'long long int lcm(long long int, long long int)':
a.cc:34:12: error: 'swap' was not declared in this scope
34 | if(a < b)swap(a , b);
| ^~~~
a.cc: In function 'int main()':
a.cc:41:3: error: 'cin' was not declared in this scope
41 | cin >> n >> m;
| ^~~
a.cc:57:24: error: 'min' was not declared in this scope; did you mean 'main'?
57 | dist[a[i]][b[i]] = min(dist[a[i]][b[i]] , c[i]);
| ^~~
| main
a.cc:64:22: error: 'min' was not declared in this scope; did you mean 'main'?
64 | dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
| ^~~
| main
a.cc:16:15: error: 'cout' was not declared in this scope
16 | #define pr(x) cout << x << endl
| ^~~~
a.cc:76:3: note: in expansion of macro 'pr'
76 | pr(ans);
| ^~
a.cc:16:28: error: 'endl' was not declared in this scope; did you mean 'Endl'?
16 | #define pr(x) cout << x << endl
| ^~~~
a.cc:76:3: note: in expansion of macro 'pr'
76 | pr(ans);
| ^~
a.cc: In function 'long long int gcd(long long int, long long int)':
a.cc:30:11: warning: control reaches end of non-void function [-Wreturn-type]
30 | else gcd(b, a%b);
| ~~~^~~~~~~~
|
s508275188 | p03837 | C++ | // 無向グラフにしてある.
#include <bits/stdc++.h>
using namespace std;
/* define const */
const int Nmax = 100;
const int M = 10000;
/* finish defineing const */
int graph[Nmax+10][Nmax+10];
int g_tmp[Nmax+10][Nmax+10];
int a[Nmax+10];
int b[Nmax+10];
int c[Nmax+10];
int n,m;
int main()
{
for (int i = 0; i < Nmax+10; i++) {
for (int j = 0; j < Nmax+10; j++) {
d[i][j] = M;
if (i != j) {
graph[i][j] = M;
g_tmp[i][j] = M;
}
else {
graph[i][j] = 0;
g_tmp[i][j] = 0;
}
}
}
cin >> n >> m;
for (int i = 1; i <= m; i++) cin >> a[i] >> b[i] >> c[i];
for (int i = 1; i <= m; i++) {
graph[a[i]][b[i]] = c[i];
g_tmp[a[i]][b[i]] = c[i];
graph[b[i]][a[i]] = c[i]; // 有効グラフならこの行はコメントアウト
g_tmp[b[i]][a[i]] = c[i]; // 有効グラフならこの行はコメントアウト
}
for (int k = 1; k <= n; k++) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (g_tmp[i][j] > g_tmp[i][k]+g_tmp[k][j])
g_tmp[i][j] = g_tmp[i][k]+g_tmp[k][j];
}
}
}
long cnt = 0;
for (int i = 1; i <= n; i++) {
for (int j = i+1; j <= n; j++) {
if (graph[i][j] < M && graph[i][j] > g_tmp[i][j]) {
++cnt;
}
}
}
cout << cnt << endl;
}
| a.cc: In function 'int main()':
a.cc:21:7: error: 'd' was not declared in this scope
21 | d[i][j] = M;
| ^
|
s717388959 | p03837 | C++ | #include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <string>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
struct edge { int to, cost; };
typedef vector<vector<edge>> AdjList;
AdjList graph;
typedef pair<int, int> P;
const int INF = 10000000;
vector<int> dist;
vector<int> prever;
int index[100][100];
void dijkstra(int n, int s) {
dist = vector<int>(n, INF);
prever = vector<int>(n, -1);
dist[s] = 0;
priority_queue<P, vector<P>, greater<P>> que;
que.push(P(0, s));
while (!que.empty()) {
P p = que.top();
que.pop();
int v = p.second;
if (dist[v] < p.first) {
continue;
}
for (int i = 0; i < graph[v].size(); i++) {
edge e = graph[v][i];
if (dist[e.to] > dist[v] + e.cost) {
dist[e.to] = dist[v] + e.cost;
prever[e.to] = v;
que.push(P(dist[e.to], e.to));
}
}
}
}
vector<int> get_path(int t) {
vector<int> path;
for (; t != -1; t = prever[t]) {
path.push_back(t);
}
reverse(path.begin(), path.end());
return path;
}
int main(void) {
int N, M;
cin >> N >> M;
graph = AdjList(N);
bool used[1000];
for (int i = 0; i < M; i++) {
int a, b, c;
cin >> a >> b >> c;
a--; b--;
graph[a].push_back({ b, c });
graph[b].push_back({ a, c });
used[i] = false;
index[a][b] = i;
}
for (int i = 0; i < N; i++) {
dijkstra(N, i);
for (int j = 0; j < N; j++) {
vector<int> ans = get_path(j);
for (int k = 0; k < ans.size() - 1; k++) {
used[index[ans[k]][ans[k + 1]]] = true;
}
}
}
int result = M;
for (int i = 0; i < M; i++) {
if (used[i]) {
result--;
}
}
cout << result << endl;
return 0;
} | a.cc:84:19: error: 'int index [100][100]' redeclared as different kind of entity
84 | int index[100][100];
| ^
In file included from /usr/include/string.h:462,
from /usr/include/c++/14/cstring:43,
from a.cc:15:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
50 | extern const char *index (const char *__s, int __c)
| ^~~~~
a.cc: In function 'int main()':
a.cc:128:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
128 | index[a][b] = i;
| ^
a.cc:135:43: error: invalid types '<unresolved overloaded function type>[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
135 | used[index[ans[k]][ans[k + 1]]] = true;
| ^
|
s624111897 | p03837 | C++ | #include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <string>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
struct edge { int to, cost; };
typedef vector<vector<edge>> AdjList;
AdjList graph;
typedef pair<int, int> P;
const int INF = 10000000;
vector<int> dist;
vector<int> prever;
int index[100][100];
void dijkstra(int n, int s) {
dist = vector<int>(n, INF);
prever = vector<int>(n, -1);
dist[s] = 0;
priority_queue<P, vector<P>, greater<P>> que;
que.push(P(0, s));
while (!que.empty()) {
P p = que.top();
que.pop();
int v = p.second;
if (dist[v] < p.first) {
continue;
}
for (int i = 0; i < graph[v].size(); i++) {
edge e = graph[v][i];
if (dist[e.to] > dist[v] + e.cost) {
dist[e.to] = dist[v] + e.cost;
prever[e.to] = v;
que.push(P(dist[e.to], e.to));
}
}
}
}
vector<int> get_path(int t) {
vector<int> path;
for (; t != -1; t = prever[t]) {
path.push_back(t);
}
reverse(path.begin(), path.end());
return path;
}
int main(void) {
int N, M;
cin >> N >> M;
graph = AdjList(N);
bool used[1000];
for (int i = 0; i < M; i++) {
int a, b, c;
cin >> a >> b >> c;
a--; b--;
graph[a].push_back({ b, c });
graph[b].push_back({ a, c });
used[i] = false;
index[a][b] = i;
}
for (int i = 0; i < N; i++) {
dijkstra(N, i);
for (int j = 0; j < N; j++) {
vector<int> ans = get_path(j);
for (int k = 0; k < ans.size() - 1; k++) {
used[index[ans[k]][ans[k + 1]]] = true;
}
}
}
int result = M;
for (int i = 0; i < M; i++) {
if (used[i]) {
result--;
}
}
cout << result << endl;
return 0;
} | a.cc:84:19: error: 'int index [100][100]' redeclared as different kind of entity
84 | int index[100][100];
| ^
In file included from /usr/include/string.h:462,
from /usr/include/c++/14/cstring:43,
from a.cc:15:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
50 | extern const char *index (const char *__s, int __c)
| ^~~~~
a.cc: In function 'int main()':
a.cc:128:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
128 | index[a][b] = i;
| ^
a.cc:135:43: error: invalid types '<unresolved overloaded function type>[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
135 | used[index[ans[k]][ans[k + 1]]] = true;
| ^
|
s146140194 | p03837 | C++ | 3 2
1 2 1
2 3 1 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 3 2
| ^
|
s987148171 | p03837 | C++ | #include<bits/stdc++.h>
using namespace std;
#define INF 10000000
int main(){
int n, m; cin >> n >> m;
vector<vector<int> > dist(n, vector<int> (n, INF));
for(int i = 0; i < n; i++) dist[i][i] = 0;
vector<int> a(m);
vector<int> b(m);
vector<int> c(m);
for(int i = 0; i < m; i++){
cin >> a[i] >> b[i] >> c[i];
a[i]--;
b[i]--;
c[i];
dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
}
//わー
for(int k = 0; k < n; k++){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
}
int ans = 0;
for(int i = 0; i < m; i++){
if(dist[a[i]][b[i]] == c[i]) ans++;
}
cout << m - ans << endl;
return 0;
}#include<bits/stdc++.h>
using namespace std;
#define INF 10000000
int main(){
int n, m; cin >> n >> m;
vector<vector<int> > dist(n, vector<int> (n, INF));
for(int i = 0; i < n; i++) dist[i][i] = 0;
vector<int> a(m);
vector<int> b(m);
vector<int> c(m);
for(int i = 0; i < m; i++){
cin >> a[i] >> b[i] >> c[i];
a[i]--;
b[i]--;
c[i];
dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
}
//わー
for(int k = 0; k < n; k++){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
}
int ans = 0;
for(int i = 0; i < m; i++){
if(dist[a[i]][b[i]] == c[i]) ans++;
}
cout << m - ans << endl;
return 0;
} | a.cc:42:2: error: stray '#' in program
42 | }#include<bits/stdc++.h>
| ^
a.cc: In function 'int main()':
a.cc:19:12: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
19 | c[i];
| ^
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: declared here
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ^~~~~~~~
a.cc: At global scope:
a.cc:42:3: error: 'include' does not name a type
42 | }#include<bits/stdc++.h>
| ^~~~~~~
a.cc:47:5: error: redefinition of 'int main()'
47 | int main(){
| ^~~~
a.cc:6:5: note: 'int main()' previously defined here
6 | int main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:60:12: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
60 | c[i];
| ^
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: declared here
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ^~~~~~~~
|
s417122352 | p03837 | C++ | int main(void){
const int inf = 100000000;
int n,m; cin>>n>>m;
int a[1000],b[1000],c[1000],dist[100][100];
for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--;
}
for(inti=0;i< for(int j = 0;
m; ++i){
b[i] >> c[i];
n; ++i){ j<n;++j){
} }
if(i==j)
dist[i][j]=0;
else
dist[i][j]=inf;
for(inti=0;i<m;++i){ dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]); dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
}
for(intk=0;k<n;++k){ for(int i = 0; i < n; ++i){
for(int j = 0; j < n; ++j){
dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
} }
}
int ans=m; for(inti=0;i<m;++i){
bool shortest=false;
for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
if(shortest==true){
ans=ans-1; }
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:4:10: error: 'cin' was not declared in this scope
4 | int n,m; cin>>n>>m;
| ^~~
a.cc:6:5: error: 'inti' was not declared in this scope; did you mean 'int'?
6 | for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--;
| ^~~~
| int
a.cc:6:12: error: 'i' was not declared in this scope
6 | for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--;
| ^
a.cc:7:1: error: expected primary-expression before '}' token
7 | }
| ^
a.cc:6:44: error: expected ')' before '}' token
6 | for(inti=0;i< cin >> a[i] >> a[i]--,b[i]--;
| ~ ^
| )
7 | }
| ~
a.cc:7:1: error: expected primary-expression before '}' token
7 | }
| ^
a.cc: At global scope:
a.cc:8:1: error: expected unqualified-id before 'for'
8 | for(inti=0;i< for(int j = 0;
| ^~~
a.cc:8:12: error: 'i' does not name a type
8 | for(inti=0;i< for(int j = 0;
| ^
a.cc:9:1: error: 'm' does not name a type
9 | m; ++i){
| ^
a.cc:9:4: error: expected unqualified-id before '++' token
9 | m; ++i){
| ^~
|
s944542637 | p03837 | C++ |
/*#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
//#define __int64 long long
#define P pair<int,int>
string s;
int n,m;
vector<P>G[1005];
bool ok[105][105];
bool is[105][105];
int dist[105];
int d[105][105];
const int INF=100000000;
void daiku(int from,int to){
priority_queue<P,vector<P>,greater<P> >bfs;
bfs.push(mp(0,from));
rep(i,n)dist[i]=INF;
while(!bfs.empty()){
P t=bfs.top();
bfs.pop();
int next=t.second,cost=t.first;
if(dist[next]!=INF)continue;
dist[next]=cost;
rep(i,G[next].size()){
bfs.push(mp(cost+G[next][i].second,G[next][i].first));
}
}
//cout<<from<<" "<<to<<" "<<dist[to]<<endl;
int now=to;
rep(i,n)d[from][i]=dist[i];
}
int main(){
cin>>n>>m;
int a,b,c;
rep(i,m){
cin>>a>>b>>c;
a--;b--;
G[a].pb(mp(b,c));
G[b].pb(mp(a,c));
is[a][b]=is[b][a]=1;
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i!=j)daiku(i,j);
}
}
int ans=0;
rep(i,n){
rep(j,n)cout<<d[i][j]<<" ";
cout<<endl;
}
cout<<ans<<endl;
}
*/ | /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s266028515 | p03837 | C++ | #include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
//#define __int64 long long
#define P pair<int,int>
string s;
int n,m;
vector<P>G[1000];
bool ok[100][100];
int dist[100];
const int INF=100000000;
void daiku(int from,int to){
priority_queue<P,vector<P>,greater<P>()>bfs;
bfs.push(mp(0,from));
rep(i,n)dist[i]=INF;
while(!bfs.empty()){
P t=bfs.top();
bfs.pop();
int next=t.second,cost=t.first;
if(dist[next]!=INF)continue;
dist[next]=cost;
rep(i,G[next].size()){
bfs.push(mp(cost+G[next][i].second,G[next][i].first));
}
}
//cout<<from<<" "<<to<<" "<<dist[to]<<endl;
int now=to;
rep(co,n){
if(now==from)break;
rep(i,G[now].size()){
int next=G[now][i].first,cost=G[now][i].second;
if(dist[next]+cost==dist[now]){
ok[now][next]=ok[next][now]=1;
//cout<<now<<" "<<next<<endl;
now=next;
}
}
}
//cout<<"B"<<endl;
}
int main(){
cin>>n>>m;
int a,b,c;
rep(i,m){
cin>>a>>b>>c;
a--;b--;
G[a].pb(mp(b,c));
G[b].pb(mp(a,c));
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
daiku(i,j);
}
}
int ans=0;
rep(i,n){
rep(j,G[i].size())if(!ok[i][G[i][j].first])ans++;
}
if(ans>0)ans/=2;
cout<<ans<<endl;
}
| In file included from /usr/include/c++/14/queue:66,
from a.cc:3:
/usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> >()>':
a.cc:28:42: required from here
28 | priority_queue<P,vector<P>,greater<P>()>bfs;
| ^~~
/usr/include/c++/14/bits/stl_queue.h:538:18: error: data member 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> >()>::comp' invalidly declared function type
538 | _Compare comp;
| ^~~~
a.cc: In function 'void daiku(int, int)':
a.cc:28:49: error: no matching function for call to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> >()>::priority_queue()'
28 | priority_queue<P,vector<P>,greater<P>()>bfs;
| ^~~
/usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate: 'template<class _InputIterator, class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&, const _Alloc&) [with _Alloc = _InputIterator; _Requires = _Alloc; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
691 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate expects 5 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
679 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate expects 5 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
671 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
663 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
649 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
638 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
629 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
594 | priority_queue(priority_queue&& __q, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
590 | priority_queue(const priority_queue& __q, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
585 | priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
579 | priority_queue(const _Compare& __x, const _Sequence& __c,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
573 | priority_queue(const _Compare& __x, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
569 | priority_queue(const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:554:9: note: candidate: 'template<class _Seq, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Requires = _Seq; _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
554 | priority_queue()
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:554:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_queue.h:551:43: error: no type named 'type' in 'struct std::enable_if<false, void>'
551 | template<typename _Seq = _Sequence, typename _Requires = typename
| ^~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >()]'
563 | priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, |
s715973700 | p03837 | C++ | #include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
//#define __int64 long long
#define P pair<ll,ll>
string s;
int n,m;
vector<P>G[1000];
bool ok[100][100];
int dist[100];
const int INF=100000000;
void daiku(int from,int to){
priority_queue<P,vector<P>,greater<P>()>bfs;
bfs.push(mp(0,from));
rep(i,n)dist[i]=INF;
while(!bfs.empty()){
P t=bfs.top();
bfs.pop();
int next=t.second,cost=t.first;
if(dist[next]!=INF)continue;
dist[next]=cost;
rep(i,G[next].size()){
bfs.push(mp(cost+G[next][i].second,G[next][i].first));
}
}
//cout<<from<<" "<<to<<" "<<dist[to]<<endl;
int now=to;
rep(co,n){
if(now==from)break;
rep(i,G[now].size()){
int next=G[now][i].first,cost=G[now][i].second;
if(dist[next]+cost==dist[now]){
ok[now][next]=ok[next][now]=1;
//cout<<now<<" "<<next<<endl;
now=next;
}
}
}
//cout<<"B"<<endl;
}
int main(){
cin>>n>>m;
int a,b,c;
rep(i,m){
cin>>a>>b>>c;
a--;b--;
G[a].pb(mp(b,c));
G[b].pb(mp(a,c));
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
daiku(i,j);
}
}
int ans=0;
rep(i,n){
rep(j,G[i].size())if(!ok[i][G[i][j].first])ans++;
}
if(ans>0)ans/=2;
cout<<ans<<endl;
} | a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:18:16: note: in expansion of macro 'll'
18 | #define P pair<ll,ll>
| ^~
a.cc:22:8: note: in expansion of macro 'P'
22 | vector<P>G[1000];
| ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:18:19: note: in expansion of macro 'll'
18 | #define P pair<ll,ll>
| ^~
a.cc:22:8: note: in expansion of macro 'P'
22 | vector<P>G[1000];
| ^
a.cc:18:21: error: template argument 1 is invalid
18 | #define P pair<ll,ll>
| ^
a.cc:22:8: note: in expansion of macro 'P'
22 | vector<P>G[1000];
| ^
a.cc:18:21: error: template argument 2 is invalid
18 | #define P pair<ll,ll>
| ^
a.cc:22:8: note: in expansion of macro 'P'
22 | vector<P>G[1000];
| ^
a.cc:22:9: error: template argument 1 is invalid
22 | vector<P>G[1000];
| ^
a.cc:22:9: error: template argument 2 is invalid
a.cc: In function 'void daiku(int, int)':
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:18:16: note: in expansion of macro 'll'
18 | #define P pair<ll,ll>
| ^~
a.cc:28:24: note: in expansion of macro 'P'
28 | priority_queue<P,vector<P>,greater<P>()>bfs;
| ^
a.cc:18:21: error: template argument 1 is invalid
18 | #define P pair<ll,ll>
| ^
a.cc:28:24: note: in expansion of macro 'P'
28 | priority_queue<P,vector<P>,greater<P>()>bfs;
| ^
a.cc:28:34: error: template argument 1 is invalid
28 | priority_queue<P,vector<P>,greater<P>()>bfs;
| ^
a.cc:28:34: error: template argument 2 is invalid
a.cc:28:45: error: template argument 1 is invalid
28 | priority_queue<P,vector<P>,greater<P>()>bfs;
| ^
a.cc:28:48: error: template argument 1 is invalid
28 | priority_queue<P,vector<P>,greater<P>()>bfs;
| ^
a.cc:28:48: error: template argument 2 is invalid
a.cc:28:48: error: template argument 3 is invalid
a.cc:29:13: error: request for member 'push' in 'bfs', which is of non-class type 'int'
29 | bfs.push(mp(0,from));
| ^~~~
a.cc:32:20: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
32 | while(!bfs.empty()){
| ^~~~~
a.cc:33:25: error: request for member 'top' in 'bfs', which is of non-class type 'int'
33 | P t=bfs.top();
| ^~~
a.cc:34:21: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
34 | bfs.pop();
| ^~~
a.cc:35:28: error: request for member 'second' in 't', which is of non-class type 'int'
35 | int next=t.second,cost=t.first;
| ^~~~~~
a.cc:37:28: error: 'cost' was not declared in this scope; did you mean 'const'?
37 | dist[next]=cost;
| ^~~~
| const
a.cc:38:31: error: request for member 'size' in 'G[next]', which is of non-class type 'int'
38 | rep(i,G[next].size()){
| ^~~~
a.cc:13:32: note: in definition of macro 'rep'
13 | #define rep(i,a) for(int i=0;i<a;i++)
| ^
a.cc:39:29: error: request for member 'push' in 'bfs', which is of non-class type 'int'
39 | bfs.push(mp(cost+G[next][i].second,G[next][i].first));
| ^~~~
a.cc:39:49: error: invalid types 'int[int]' for array subscript
39 | bfs.push(mp(cost+G[next][i].second,G[next][i].first));
| ^
a.cc:39:67: error: invalid types 'int[int]' for array subscript
39 | bfs.push(mp(cost+G[next][i].second,G[next][i].first));
| ^
a.cc:47:30: error: request for member 'size' in 'G[now]', which is of non-class type 'int'
47 | rep(i,G[now].size()){
| ^~~~
a.cc:13:32: note: in definition of macro 'rep'
13 | #define rep(i,a) for(int i=0;i<a;i++)
| ^
a.cc:48:40: error: invalid types 'int[int]' for array subscript
48 | int next=G[now][i].first,cost=G[now][i].second;
| ^
a.cc:49:39: error: 'cost' was not declared in this scope; did you mean 'const'?
49 | if(dist[next]+cost==dist[now]){
| ^~~~
| const
a.cc: In function 'int main()':
a.cc:15:12: error: request for member 'push_back' in 'G[a]', which is of non-class type 'int'
15 | #define pb push_back
| ^~~~~~~~~
a.cc:66:22: note: in expansion of macro 'pb'
66 | G[a].pb(mp(b,c));
| ^~
a.cc:15:12: error: request for member 'push_back' in 'G[b]', which is of non-class type 'int'
15 | #define pb push_back
| ^~~~~~~~~
a.cc:67:22: note: in expansion of macro 'pb'
67 | G[b].pb(mp(a,c));
| ^~
a.cc:76:28: error: request for member 'size' in 'G[i]', which is of non-class type 'int'
76 | rep(j,G[i].size())if(!ok[i][G[i][j].first])ans++;
| ^~~~
a.cc:13:32: note: in definition of macro 'rep'
13 | #define rep(i,a) for(int i=0;i<a;i++)
| ^
a.cc:76:49: error: invalid types 'int[int]' for array subscript
76 | rep(j,G[i].size())if(!ok[i][G[i][j].first])ans++;
| ^
|
s782263762 | p03837 | C++ | #include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1e9;
typedef long long ll;
#define MAX_V 10000
struct edge {
int to;
int cost;
};
int V;
vector<edge> G[MAX_V];
int d[MAX_V];
void dijkstra(int s) {
priority_queue<P, vector<P>, greater<P> > que;
fill(d, d+V, INF);
d[s] = 0;
que.push(P(0, s));
while (!que.empty()) {
P p = que.top();
que.pop();
int v = p.second;
if (d[v] < p.first) continue;
for (int i=0; i<G[v].size(); ++i) {
edge e = G[v][i];
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(P(d[e.to], e.to));
}
}
}
}
int main(){
int E,r;
cin >> V >> E;
REP(i,E){
int f,t,c;
cin >> f >> t >> c;
f--;
t--;
edge e = {t,c};
G[f].pb(e);
e = {f,c}
G[t].pb(e);
}
ll path[V][V];
REP(i,V){
dijkstra(i);
REP(j,V){
path[i][j] = d[j];
}
}
ll sum = 0;
REP(i,V){
for(int j = i+1;j < V;j++){
REP(k,G[j].size()){
ll p = path[i][j]+G[j][k].cost;
if(path[i][G[j][k].to] != p)
sum++;
}
}
}
cout << sum << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:58:14: error: expected ';' before 'G'
58 | e = {f,c}
| ^
| ;
59 | G[t].pb(e);
| ~
|
s342693124 | p03837 | C++ | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 110
#define M 1100
ll g[N][N], n, m;
ll a[M], b[M], c[M];
int main(){
cin>n>>m;
rep(i, N) fill(g[i], g[i]+N, INF);
rep(i, n) g[i][i] = 0;
rep(i, m){
cin>>a[i]>>b[i]>>c[i]; a[i]--; b[i]--;
g[a[i]][b[i]] = g[b[i]][a[i]] = c[i];
}
rep(k, n) rep(i, n) rep(j, n) chmin(g[i][j], g[i][k]+g[k][j]);
int res = 0;
rep(i, m){
int r = 1;
rep(j, n) if(g[a[i]][j]==c[i]+g[b[i]][j] || g[b[i]][j]==c[i]+g[a[i]][j]) r = 0;
res += r;
}
cout<<res<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:45:12: error: no match for 'operator>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'll' {aka 'long long int'})
45 | cin>n>>m;
| ~~~^~~~~
| | |
| | ll {aka long long int}
| std::istream {aka std::basic_istream<char>}
a.cc:45:12: note: candidate: 'operator>(int, ll {aka long long int})' (built-in)
45 | cin>n>>m;
| ~~~^~~~~
a.cc:45:12: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>'
45 | cin>n>>m;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
462 | operator>(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
45 | cin>n>>m;
| ^
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
507 | operator>(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
45 | cin>n>>m;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1714 | operator>(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
45 | cin>n>>m;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1774 | operator>(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
45 | cin>n>>m;
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:7:
/usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
695 | operator> (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
45 | cin>n>>m;
| ^
/usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
702 | operator> (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
45 | cin>n>>m;
| ^
/usr/include/c++/14/string_view:710:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int'
45 | cin>n>>m;
| ^
/usr/include/c++/14/bits/basic_string.h:3915:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
45 | cin>n>>m;
| ^
/usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3929:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
45 | cin>n>>m;
| ^
/usr/include/c++/14/bits/basic_string.h:3942:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3942 | operator>(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3942:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>'
45 | cin>n>>m;
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2619 | operator>(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>'
45 | cin>n>>m;
| ^
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from a.cc:9:
/usr/include/c++/14/bits/stl_vector.h:2102:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator>(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)'
2102 | operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:2102:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::vector<_Tp, _Alloc>'
45 | cin>n>>m;
| ^
In file included from /usr/include/c++/14/functional:65:
/usr/include/c++/14/array:349:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> bool std::operator>(const array<_Tp, _Nm>&, const array<_Tp, _Nm>&)'
349 | operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
| ^~~~~~~~
/usr/include/c++/14/array:349:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::array<_Tp, _Nm>'
45 | cin>n>>m;
| ^
In file included from /usr/include/c++/14/map:63,
from a.cc:10:
/usr/include/c++/14/bits/stl_map.h:1564:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator>(const map<_Key, _Tp, _Compare, _Allocator>&, const map<_Key, _Tp, _Compare, _Allocator>&)'
1564 | operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1564:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::map<_Key, _Tp, _Compare, _Allocator>'
45 | cin>n>>m;
| ^
In file included from /usr/include/c++/14/map:64:
/usr/include/c++/14/bits/stl_multimap.h:1186:5: n |
s165742296 | p03837 | C++ | #include <cstdio>
#define INF 10000000;
using namespace std;
int n,m;
long long dp[100][100];
int a[1000],b[1000],c[1000];
void initialize(void){
for(int lp1=0;lp1<100;lp1++){
for(int lp2=0;lp2<100;lp2++){
if(lp1==lp2){
dp[lp1][lp2]=0;
}else{
dp[lp1][lp2]=INF;
}
}
}
}
void input(void){
int edge_a,edge_b,edge_c;
scanf("%d %d",&n,&m);
for(int lp1=0;lp1<m;lp1++){
scanf("%d %d %d",&edge_a,&edge_b,&edge_c);
a[lp1]=edge_a;
b[lp1]=edge_b;
c[lp1]=edge_c;
dp[edge_a-1][edge_b-1]=edge_c;
dp[edge_b-1][edge_a-1]=edge_c;
}
}
void shortestpath(void){
for(int lp1=0;lp1<n;lp1++){
for(int lp2=0;lp2<n;lp2++){
for(int lp3=0;lp3<n;lp3++){
dp[lp2][lp3]=std:min(dp[lp2][lp3],dp[lp2][lp1]+dp[lp1][lp3]);
}
}
}
}
void pathprint(void){
printf("pathprint called\n");
for(int lp1=0;lp1<n;lp1++){
for(int lp2=0;lp2<n;lp2++){
printf("%d to %d is %d\n",lp1,lp2,dp[lp1][lp2]);
}
}
}
int solve(void){
bool shortest=false;
int answer=0;
for(int lp1=0;lp1<m;lp1++){
if(c[lp1]>dp[a[lp1]-1][b[lp1]-1]) answer++;
}
return answer;
}
int main(void){
initialize();
input();
//pathprint();
shortestpath();
//printf("going to call pathprint2\n");
//pathprint();
printf("%d\n",solve());
return 0;
}
| a.cc: In function 'void shortestpath()':
a.cc:37:49: error: found ':' in nested-name-specifier, expected '::'
37 | dp[lp2][lp3]=std:min(dp[lp2][lp3],dp[lp2][lp1]+dp[lp1][lp3]);
| ^
| ::
a.cc:37:50: error: 'min' is not a member of 'std'
37 | dp[lp2][lp3]=std:min(dp[lp2][lp3],dp[lp2][lp1]+dp[lp1][lp3]);
| ^~~
|
s494817072 | p03837 | C++ | #include <cstdio>
#define INF 10000000;
using namespace std;
int n,m;
long long dp[100][100];
int a[1000],b[1000],c[1000];
void initialize(void){
for(int lp1=0;lp1<100;lp1++){
for(int lp2=0;lp2<100;lp2++){
if(lp1==lp2){
dp[lp1][lp2]=0;
}else{
dp[lp1][lp2]=INF;
}
}
}
}
void input(void){
int edge_a,edge_b,edge_c;
scanf("%d %d",&n,&m);
for(int lp1=0;lp1<m;lp1++){
scanf("%d %d %d",&edge_a,&edge_b,&edge_c);
a[lp1]=edge_a;
b[lp1]=edge_b;
c[lp1]=edge_c;
dp[edge_a-1][edge_b-1]=edge_c;
dp[edge_b-1][edge_a-1]=edge_c;
}
}
void shortestpath(void){
for(int lp1=0;lp1<n;lp1++){
for(int lp2=0;lp2<n;lp2++){
for(int lp3=0;lp3<n;lp3++){
dp[lp2][lp3]=min(dp[lp2][lp3],dp[lp2][lp1]+dp[lp1][lp3]);
}
}
}
}
void pathprint(void){
printf("pathprint called\n");
for(int lp1=0;lp1<n;lp1++){
for(int lp2=0;lp2<n;lp2++){
printf("%d to %d is %d\n",lp1,lp2,dp[lp1][lp2]);
}
}
}
int solve(void){
bool shortest=false;
int answer=0;
for(int lp1=0;lp1<m;lp1++){
if(c[lp1]>dp[a[lp1]-1][b[lp1]-1]) answer++;
}
return answer;
}
int main(void){
initialize();
input();
//pathprint();
shortestpath();
//printf("going to call pathprint2\n");
//pathprint();
printf("%d\n",solve());
return 0;
}
| a.cc: In function 'void shortestpath()':
a.cc:37:46: error: 'min' was not declared in this scope
37 | dp[lp2][lp3]=min(dp[lp2][lp3],dp[lp2][lp1]+dp[lp1][lp3]);
| ^~~
|
s228290521 | p03837 | C++ | #include <iostream>
#include <tuple>
#include <queue>
#include <algorithm>
using namespace std;
typedef tuple<int, int, int> tiii;
const int INF = 1 << 29;
int N, M;
int A[100][100];
int a, b, c;
queue<tiii> q;
int main(void) {
cin >> N >> M;
fill_n(A, N * N, INF);
for (int i = 0; i < M; ++i) {
cin >> a >> b >> c;
--a; --b;
A[a][b] = A[b][a] = c;
q.push(tiii(a, b, c));
}
for (int k = 0; k < N; ++k) for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
int ans = M;
while (!q.empty()) {
tie(a, b, c) = q.front(); q.pop();
if (A[a][b] == c) --M;
}
cout << ans << endl;
return 0;
} | In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[100]; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:998:21: required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int (*)[100]; _Tp = int]'
998 | { std::__fill_a1(__first, __last, __value); }
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1154:20: required from '_OutputIterator std::__fill_n_a(_OutputIterator, _Size, const _Tp&, random_access_iterator_tag) [with _OutputIterator = int (*)[100]; _Size = int; _Tp = int]'
1154 | std::__fill_a(__first, __first + __n, __value);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1183:29: required from '_OI std::fill_n(_OI, _Size, const _Tp&) [with _OI = int (*)[100]; _Size = int; _Tp = int]'
1183 | return std::__fill_n_a(__first, std::__size_to_integer(__n), __value,
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1184 | std::__iterator_category(__first));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:14:8: required from here
14 | fill_n(A, N * N, INF);
| ~~~~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const int' to 'int [100]'
952 | *__first = __tmp;
| ~~~~~~~~~^~~~~~~
|
s547992644 | p03837 | C++ | #include <iostream>
#include <tuple>
#include <queue>
#include <algorithm>
using namespace std;
typedef tuple<int, int, int> tiii;
const int INF = 1 << 29;
int N, M,
int A[100][100];
int a, b, c;
queue<tiii> q;
int main(void) {
cin >> N >> M;
fill_n(A, N * N, INF);
for (int i = 0; i < M; ++i) {
cin >> a >> b >> c;
--a; --b;
A[a][b] = A[b][a] = c;
q.push(tiii(a, b, c));
}
for (int k = 0; k < N; ++k) for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
int ans = M;
while (!q.empty()) {
tie(a, b, c) = q.front(); q.pop();
if (A[a][b] == c) --M;
}
cout << ans << endl;
return 0;
} | a.cc:9:1: error: expected unqualified-id before 'int'
9 | int A[100][100];
| ^~~
a.cc: In function 'int main()':
a.cc:14:16: error: 'A' was not declared in this scope
14 | fill_n(A, N * N, INF);
| ^
|
s346025491 | p03837 | Java | import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class Main {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni();
int m = ni();
long[][] dist = new long[n][n];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
dist[i][j] = Integer.MAX_VALUE;
}
}
int[] from = new int[m];
int[] to = new int[m];
int[] c = new int[m];
int[][] a = new int[n][n];
for(int i = 0; i < m; i++){
int v = ni()-1;
int w = ni()-1;
int x = ni();
from[i] = v;
to[i] = w;
c[i] = x;
a[v][w] = x;
a[w][v] = x;
dist[v][w] = x;
dist[w][v] = x;
}
for (int k = 0; k < n; k++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (dist[i][j] > dist[i][k] + dist[k][j]) {
dist[i][j] = dist[i][k] + dist[k][j];
}
}
}
}
// for(int i = 0; i < n; i++){
// for(int j = 0; j < n; j++){
// out.print(a[i][j]);
// }
// out.println();
// }
long res = m;
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
if(a[from[i]][to[i]] + dist[to[i][j]] == dist[from[i]][to[i]]){
res --;
}
}
}
out.println(res);
}
private static void dp(){
}
void run() throws Exception
{
is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
out = new PrintWriter(System.out);
long s = System.currentTimeMillis();
solve();
out.flush();
if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
}
public static void main(String[] args) throws Exception { new Main().run(); }
private byte[] inbuf = new byte[1024];
private int lenbuf = 0, ptrbuf = 0;
private int readByte()
{
if(lenbuf == -1)throw new InputMismatchException();
if(ptrbuf >= lenbuf){
ptrbuf = 0;
try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
if(lenbuf <= 0)return -1;
}
return inbuf[ptrbuf++];
}
private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
private double nd() { return Double.parseDouble(ns()); }
private char nc() { return (char)skip(); }
private String ns()
{
int b = skip();
StringBuilder sb = new StringBuilder();
while(!(isSpaceChar(b) && b != ' ')){
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
private char[] ns(int n)
{
char[] buf = new char[n];
int b = skip(), p = 0;
while(p < n && !(isSpaceChar(b))){
buf[p++] = (char)b;
b = readByte();
}
return n == p ? buf : Arrays.copyOf(buf, p);
}
private char[][] nm(int n, int m)
{
char[][] map = new char[n][];
for(int i = 0;i < n;i++)map[i] = ns(m);
return map;
}
private int[] na(int n)
{
int[] a = new int[n];
for(int i = 0;i < n;i++)a[i] = ni();
return a;
}
private int ni()
{
int num = 0, b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-'){
minus = true;
b = readByte();
}
while(true){
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
b = readByte();
}
}
private long nl()
{
long num = 0;
int b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-'){
minus = true;
b = readByte();
}
while(true){
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
b = readByte();
}
}
private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}
| Main.java:58: error: array required, but int found
if(a[from[i]][to[i]] + dist[to[i][j]] == dist[from[i]][to[i]]){
^
Main.java:58: error: bad operand types for binary operator '+'
if(a[from[i]][to[i]] + dist[to[i][j]] == dist[from[i]][to[i]]){
^
first type: int
second type: long[]
2 errors
|
s246104209 | p03837 | C++ | #include <bits/stdc++.h>
using namespace std;
/*てんぷれぞーん!*/
struct edge {int to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<edge> VE;
//static const int INF = 2147483647;
static const int INF = 1000000000;
static const long long llINF = 9223372000000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
/* t y p o っ て 知 っ て る ゥ ! ? */
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll
//#define INF llINF
const int NMAX = 120;
int n,m; //nが頂点の数、mが辺の数
bool rinsetsu[NMAX][NMAX]; //最後に使うよ
int d[NMAX][NMAX]; //WF用テーブル
int prev[NMAX][NMAX]; //prev[i][j]はiからjへの最短路におけるjの手前の頂点
void WF(){
for(int k=0;k<n;k++){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(d[i][j]>d[i][k]+d[k][j]){
d[i][j] = d[i][k] + d[k][j];
prev[i][j] = prev[k][j];
}
}
}
}
}
void delete_path(int start,int goal){
VI path;
int via=0,current;
for(current=goal;current!=start;current=prev[start][current]){
path.pb(current);
}
path.pb(start);
for(int i=0;i<path.size()-1;i++){
rinsetsu[path[i]][path[i+1]] = rinsetsu[path[i+1]][path[i]] = false;
}
}
void debug(){
printf("\n");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++) printf("%d ",d[i][j]);
printf("\n");
}
printf("\n");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++) printf("%d ",prev[i][j]);
printf("\n");
}
printf("\n");
}
void initializer(){
memset(d,INF,sizeof(d));
memset(rinsetsu,false,sizeof(rinsetsu));
for(int i=0;i<NMAX;i++) d[i][i] = 0;
for(int i=0;i<NMAX;i++){
for(int j=0;j<NMAX;j++) prev[i][j] = i;
}
}
signed main(){
initializer();
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++){
int tmp1,tmp2,tmp3;
scanf("%d%d%d",&tmp1,&tmp2,&tmp3);
tmp1--; tmp2--;
rinsetsu[tmp1][tmp2] = rinsetsu[tmp1][tmp2] = true;
d[tmp1][tmp2] = d[tmp2][tmp1] = tmp3;
}
//debug();
WF();
//debug();
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++) delete_path(i,j);
}
int ans = 0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(rinsetsu[i][j]) ans++;
}
}
printf("%d\n",ans);
} | a.cc: In function 'void WF()':
a.cc:47:21: error: reference to 'prev' is ambiguous
47 | prev[i][j] = prev[k][j];
| ^~~~
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:39:5: note: 'int prev [120][120]'
39 | int prev[NMAX][NMAX]; //prev[i][j]はiからjへの最短路におけるjの手前の頂点
| ^~~~
a.cc:47:34: error: reference to 'prev' is ambiguous
47 | prev[i][j] = prev[k][j];
| ^~~~
/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:39:5: note: 'int prev [120][120]'
39 | int prev[NMAX][NMAX]; //prev[i][j]はiからjへの最短路におけるjの手前の頂点
| ^~~~
a.cc: In function 'void delete_path(int, int)':
a.cc:57:45: error: reference to 'prev' is ambiguous
57 | for(current=goal;current!=start;current=prev[start][current]){
| ^~~~
/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:39:5: note: 'int prev [120][120]'
39 | int prev[NMAX][NMAX]; //prev[i][j]はiからjへの最短路におけるjの手前の頂点
| ^~~~
a.cc: In function 'void debug()':
a.cc:75:43: error: reference to 'prev' is ambiguous
75 | for(int j=0;j<n;j++) printf("%d ",prev[i][j]);
| ^~~~
/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:39:5: note: 'int prev [120][120]'
39 | int prev[NMAX][NMAX]; //prev[i][j]はiからjへの最短路におけるjの手前の頂点
| ^~~~
a.cc: In function 'void initializer()':
a.cc:86:33: error: reference to 'prev' is ambiguous
86 | for(int j=0;j<NMAX;j++) prev[i][j] = i;
| ^~~~
/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:39:5: note: 'int prev [120][120]'
39 | int prev[NMAX][NMAX]; //prev[i][j]はiからjへの最短路におけるjの手前の頂点
| ^~~~
|
s201297410 | p03837 | C++ | #include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン!!!!
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
ll to, cost;
};
struct S {//辺の情報を入れる変数
int from, to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
if (i > j) swap(i, j);
if (i == 0) return j;
return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, m;
int a[101][101];
S b[5000];
signed main() {
cin >> n >> m;
rep(i, 101)
rep(j, 101)
a[i][j] = inf;
for (int i = 0; i <= 101; i++)
a[i][i] = 0;
for (int i = 0; i < m; i++) {
cin >> b[i].from >> b[i].to >> b[i].cost;
a[b[i].from][b[i].to] = b[i].cost;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= n; k++) {
a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
a[j][i] = a[i][j];
}
}
}
int sum = 0;
for (int i = 0; i < m; i++) {
bool l = 1;
for (int j = 1; j <= n; j++) {
if (a[b[i].from][j] + b[i].cost == a[b[i].to][j])
l = 0;
if (a[b[i].to] + b[i].cost == a[b[i].from][j])
l = 0;
}
if (l)
sum++;
}
cout << sum << endl;
getchar(); getchar();
} | a.cc: In function 'int main()':
a.cc:69:52: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
69 | if (a[b[i].to] + b[i].cost == a[b[i].from][j])
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
|
s686120147 | p03837 | Java | import java.util.Scanner;
public class Main2{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] a = new int[m];
int[] b = new int[m];
int[] c = new int[m];
int[][] dist = new int[n][n];
for(int i = 0; i < n; i++){
for(int j =0; j<n; j++){
if(i==j) dist[i][j] = 0;
else dist[i][j] = (int)1e9;
}
}
for(int i=0; i<m; i++){
a[i] = sc.nextInt()-1;
b[i] = sc.nextInt()-1;
c[i] = sc.nextInt();
dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
}
for(int k=0; k<n; k++){
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
dist[i][j] = Math.min(dist[i][k] + dist[k][j], dist[i][j]);
}
}
}
int count =0;
for(int i=0; i<m; i++){
if(c[i] > dist[a[i]][b[i]]) count++;
}
System.out.println(count);
}
} | Main.java:3: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2{
^
1 error
|
s413697927 | p03837 | Java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class <Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int[][] edge = new int[m][3];
int[][] cost = new int[n][n];
ArrayList<Integer>[][] minEdgeList = new ArrayList[n][n];
for (int i = 0; i < m; i++) {
edge[i][0] = scanner.nextInt()-1;
edge[i][1] = scanner.nextInt()-1;
edge[i][2] = scanner.nextInt();
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
minEdgeList[i][j] = new ArrayList<>();
}
Arrays.fill(cost[i], Integer.MAX_VALUE);
}
for (int i = 0; i < n; i++) {
cost[i][i] = 0;
}
// ベルマンフォード法?
for (int startIndex = 0; startIndex < n; startIndex++) {
while (true) {
boolean isUpdated = false;
for (int edgeIndex = 0; edgeIndex < m; edgeIndex++) {
int viaNode = edge[edgeIndex][0];
int targetNode = edge[edgeIndex][1];
int viaCost = edge[edgeIndex][2];
if (cost[startIndex][targetNode] > cost[startIndex][viaNode] + viaCost) {
isUpdated = true;
cost[startIndex][targetNode] = cost[startIndex][viaNode] + viaCost;
minEdgeList[startIndex][targetNode].clear();
minEdgeList[startIndex][targetNode].addAll(minEdgeList[startIndex][viaNode]);
minEdgeList[startIndex][targetNode].add(edgeIndex);
}
viaNode = edge[edgeIndex][1];
targetNode = edge[edgeIndex][0];
if (cost[startIndex][targetNode] > cost[startIndex][viaNode] + viaCost) {
isUpdated = true;
cost[startIndex][targetNode] = cost[startIndex][viaNode] + viaCost;
minEdgeList[startIndex][targetNode].clear();
minEdgeList[startIndex][targetNode].addAll(minEdgeList[startIndex][viaNode]);
minEdgeList[startIndex][targetNode].add(edgeIndex);
}
}
if(!isUpdated) {
break;
}
}
}
boolean[] used = new boolean[m];
Arrays.fill(used, false);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int edgeIndex : minEdgeList[i][j]) {
used[edgeIndex] = true;
}
}
}
int ans = 0;
for (boolean isUsed : used) {
if (!isUsed) ans++;
}
System.out.println(ans);
}
}
| Main.java:5: error: <identifier> expected
public class <Main {
^
Main.java:5: error: > expected
public class <Main {
^
2 errors
|
s099415624 | p03837 | C++ | // kurikazu
#include<iostream>
#include<vector>
#include<queue>
#include<set>
// #include<unordered_set>
using namespace std;
typedef pair<int, int> pii;
int main(){
int n, m;
std::cin >> n >> m;
vector<vector<pii> > g(n);
set<pii> s;
for (int i = 0; i < m; i++) {
int a, b, c;
std::cin >> a >> b >> c;
a--, b--;
g[a].push_back(pii(b, c));
g[b].push_back(pii(a, c));
}
for (int i = 0; i < n; ++i) sort(g[i].begin(), g[i].end());
priority_queue<pii, vector<pii>, greater<pii> > que;
for (int i = 0; i < n; i++) {
vector<int> cost(n, 1e9);
vector<int> parent(n, -1);
que.push(pii(0, i));
while(not que.empty()){
int v = que.top().second;
int c = que.top().first;
que.pop();
for (int i = 0; i < g[v].size(); i++) {
int to = g[v][i].first;
if(cost[to] > c + g[v][i].second){
cost[to] = c + g[v][i].second;
que.push(pii(cost[to], to));
parent[to] = v;
}
}
}
for (int j = 0; j < n; j++) {
if(i == j)continue;
s.insert(pii(j, parent[j]));
s.insert(pii(parent[j], j));
}
}
std::cout << m - s.size()/2 << std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:31: error: 'sort' was not declared in this scope; did you mean 'short'?
22 | for (int i = 0; i < n; ++i) sort(g[i].begin(), g[i].end());
| ^~~~
| short
|
s513122559 | p03837 | C++ | #include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
int main() {
int g[128][128]={};
for (size_t i=0; i<128; ++i)
for (size_t j=0; j<128; ++j)
g[i][j] = 5e8;
size_t N;
int M;
scanf("%zu %d", &N, &M);
std::map<std::pair<size_t, size_t>, int> edges;
std::vector<std::pair<size_t, size_t>> orig;
for (int i=0; i<M; ++i) {
size_t a, b;
int c;
scanf("%zu %zu %d", &a, &b, &c);
--a, --b;
g[a][b] = g[b][a] = c;
edges[std::make_pair(a, b)] = 1;
edges[std::make_pair(b, a)] = 1;
if (a > b) std::swap(a, b);
orig.emplace_back(a, b);
}
for (size_t k=0; k<N; ++k)
for (size_t i=0; i<N; ++i)
for (size_t j=0; j<N; ++j)
if (g[i][j] > g[i][k] + g[k][j]) {
g[i][j] = g[i][k] + g[k][j];
--edges[std::make_pair(i, j)];
++edges[std::make_pair(i, k)];
++edges[std::make_pair(k, j)];
}
int cnt=0;
for (const auto &e: orig)
if (!edges[e] && !edges[std::make_pair(e.second, e.first)) ++cnt;
printf("%d\n", cnt);
return 0;
}
| a.cc: In function 'int main()':
a.cc:48:66: error: expected ']' before ')' token
48 | if (!edges[e] && !edges[std::make_pair(e.second, e.first)) ++cnt;
| ^
| ]
|
s994272087 | p03837 | Java | import java.io.*;
import java.util.*;
public class Main {
private static MyScanner scanner;
private boolean[][] path;
private int[][] distance;
public static void main (String[] args){
Main instance = new Main();
scanner = instance.new MyScanner();
instance.solve();
}
private void solve() {
try {
int N = scanner.nextInt();
int M = scanner.nextInt();
int[] a = new int[M];
int[] b = new int[M];
int[] c = new int[M];
int[][] dist = new int[M][M];
for (int i = 0; i < M; i++) {
a[i] = scanner.nextInt();
b[i] = scanner.nextInt();
c[i] = scanner.nextInt();
}
for (int i = 0; i < m; i++) {
dist[a[i]][b[i]] = Math.min(dist[a[i]][b[i]], c[i]);
dist[b[i]][a[i]] = Math.min(dist[b[i]][a[i]], c[i]);
}
for (int k = 0; k < n; k++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
}
int ans = M;
for (int i = 0; i < M; i++) {
boolean shortest = false;
for (int j = 0; j < M; j++) {
if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
shortest = true;
}
if (shortest) {
ans--;
}
}
}
System.out.println(ans);
} catch (Exception e) {
e.printStackTrace();
}
}
private void shortestPath (int i, int j) {
int now = i;
while (now != j) {
int index = now + 1;
int min = distance[now][index];
for (int n = index; n < distance[now].length; n++) {
if (distance[now][n] != 0 && n == j) {
path[now][n] = true;
return;
}
if (distance[now][n] < min) {
min = distance[now][n];
index = n;
}
}
path[now][index] = true;
now = index;
}
}
private class MyScanner {
String[] s;
int i;
BufferedReader br;
String reg = " ";
MyScanner () {
s = new String[0];
i = 0;
br = new BufferedReader(new InputStreamReader(System.in));
}
public String next() throws IOException {
if (i < s.length) return s[i++];
String line = br.readLine();
while (line.equals("")) {
line = br.readLine();
}
s = line.split(reg, 0);
i = 0;
return s[i++];
}
public int nextInt() throws NumberFormatException, IOException {
return Integer.parseInt(next());
}
public double nextDouble() throws NumberFormatException, IOException {
return Double.parseDouble(next());
}
public long nextLong() throws NumberFormatException, IOException {
return Long.parseLong(next());
}
}
} | Main.java:28: error: cannot find symbol
for (int i = 0; i < m; i++) {
^
symbol: variable m
location: class Main
Main.java:33: error: cannot find symbol
for (int k = 0; k < n; k++) {
^
symbol: variable n
location: class Main
Main.java:34: error: cannot find symbol
for (int i = 0; i < n; i++) {
^
symbol: variable n
location: class Main
Main.java:35: error: cannot find symbol
for (int j = 0; j < n; j++) {
^
symbol: variable n
location: class Main
4 errors
|
s826076970 | p03837 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int[] a = new int[M];
int[] b = new int[M];
int[] c = new int[M];
for(int i = 0; i < M; i++) {
a[i] = sc.nextInt() - 1;
b[i] = sc.nextInt() - 1;
c[i] = sc.nextInt();
}
int[][] dp = new int[N][N];
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++) {
if(i != j) {
dp[0][i][j] = Integer.MAX_VALUE;
} else {
dp[0][i][j] = 0;
}
}
}
for(int i = 0; i < M; i++) {
dp[0][a[i]][b[i]] = c[i];
dp[0][b[i]][a[i]] = c[i];
}
for(int k = 0; k < N; k++) {
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++) {
dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k][j]);
}
}
}
int ans = 0;
for(int i = 0; i < M; i++) {
if(dp[N][a[i]][b[i]] < c[i]) ans++;
}
System.out.println(ans);
}
} | Main.java:20: error: array required, but int found
dp[0][i][j] = Integer.MAX_VALUE;
^
Main.java:22: error: array required, but int found
dp[0][i][j] = 0;
^
Main.java:27: error: array required, but int found
dp[0][a[i]][b[i]] = c[i];
^
Main.java:28: error: array required, but int found
dp[0][b[i]][a[i]] = c[i];
^
Main.java:39: error: array required, but int found
if(dp[N][a[i]][b[i]] < c[i]) ans++;
^
5 errors
|
s961124768 | p03837 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int[] a = new int[M];
int[] b = new int[M];
int[] c = new int[M];
for(int i = 0; i < M; i++) {
a[i] = sc.nextInt() - 1;
b[i] = sc.nextInt() - 1;
c[i] = sc.nextInt();
}
int[][][] dp = new int[N][N][N];
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++) {
if(i != j) {
dp[0][i][j] = Integer.MAX_VALUE;
} else {
dp[0][i][j] = 0;
}
}
}
for(int i = 0; i < M; i++) {
dp[0][a[i]][b[i]] = c[i];
dp[0][b[i]][a[i]] = c[i];
}
for(int k = 0; k < N; k++) {
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++) {
dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k][j]);
}
}
}
int ans = 0;
for(int i = 0; i < M; i++) {
if(dp[N][a[i]][b[i]] < c[i]) ans++;
}
System.out.println(ans);
}
} | Main.java:33: error: bad operand types for binary operator '+'
dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k][j]);
^
first type: int[]
second type: int[]
1 error
|
s105341773 | p03837 | C++ | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;
int n, m;
int adj[200][200];
bool useE[200][200];
bool used[200];
int prev[200];
int d[200];
void dijkstra(int s){
fill(d, d + n, INF);
fill(used, used + n, false);
for(int i=0; i<n; i++){
prev[i] = -1;
}
d[s] = 0;
while(true){
int v = -1;
for(int u=0; u < n; u++){
if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
}
if(v == -1) break;
used[v] = true;
for(int u = 0; u < n; u++){
if(d[u] > d[v] + adj[v][u]){
d[u] = d[v] + adj[v][u];
prev[u] = v;
}
}
}
}
vector<int> get_path(int t, int s){
vector<int> path;
for(; t != -1; t = prev[t]){
path.push_back(t);
}
reverse(path.begin(), path.end());
for(int i=0; i < path.size()-1; i++){
useE[path[i]][path[i+1]] = useE[path[i+1]][path[i]] = true;
}
return path;
}
int main(void) {
//ios_base::sync_with_stdio(false);
//cin.tie(0);
cin >> n >> m;
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
adj[i][j] = adj[j][i] = INF;
}
}
for(int i=0; i<m; i++){
int a, b, c;
cin >> a >> b >> c;
a--;
b--;
adj[a][b] = adj[b][a] = c;
}
for(int i=1; i<n; i++){
dijkstra(i);
for(int j=0; j<n; j++){
if(i == j) continue;
get_path(j, i);
}
}
ll ans = 0;
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
if(adj[i][j] != INF && useE[i][j] == false) ans++;
}
}
/*
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
if(adj[i][j] != INF){
printf("%d ", adj[i][j]);
}else{
printf("# ");
}
}
puts("");
}
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
printf("%d ", useE[i][j]);
}
puts("");
}
*/
cout << ans/2 << endl;
return 0;
}
| a.cc: In function 'void dijkstra(int)':
a.cc:22:17: error: reference to 'prev' is ambiguous
22 | prev[i] = -1;
| ^~~~
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:15:5: note: 'int prev [200]'
15 | int prev[200];
| ^~~~
a.cc:38:33: error: reference to 'prev' is ambiguous
38 | prev[u] = v;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:15:5: note: 'int prev [200]'
15 | int prev[200];
| ^~~~
a.cc: In function 'std::vector<int> get_path(int, int)':
a.cc:46:28: error: reference to 'prev' is ambiguous
46 | for(; t != -1; t = prev[t]){
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:15:5: note: 'int prev [200]'
15 | int prev[200];
| ^~~~
|
s628026275 | p03837 | C++ | #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
signed main() {
int n, m; cin >> n >> m; vector<vector<int>>d(n, vector<int>(n, INF));
vector<int>a(m), b(m), c(m);
rep(i, 0, n)d[i][i] = 0;
rep(i, 0, m) {
cin >> a[i] >> b[i] >> c[i];
a[i]--; b[i]--;
d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
}
rep(k, 0, n) {
rep(i, 0, n) {
rep(j, 0, n) {
d[i][j] = min(d[i][j], d[i][k], d[k][j]);
}
}
}
int ans = m;
rep(i, 0, m) {
bool check = false;
rep(j, 0, n) {
if (d[j][a[i]] + c[i] == d[j][b[i]])check = true;
}
if (check)ans--;
}
cout << ans << endl;
return 0;
} | 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:2:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:29:18: required from here
29 | d[i][j] = min(d[i][j], d[i][k], d[k][j]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
284 | if (__comp(__b, __a))
| ~~~~~~^~~~~~~~~~
|
s772524144 | p03837 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main() {
int a[1000], b[1000], c[1000];
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> a[i] >> b[i] >> c[i];
}
for (int i = 0; i < m; i++) {
a[i]--;
b[i]--;
}
int d[100][128] = {};
for (int i = 0; i < m; i++) {
d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
}
int k = 0;
for (int i = 0; i < m; i++) {
int vl[100] = {};
int v0[200][2] = { a[i], 0 }, u1 = 1, u2, f = 0;
int (*v1)[2] = v0, (*v2)[2] = v0 + 100;
vl[a[i]] = 1;
for (;;) {
memset(v2, 0, n * sizeof *v0);
u2 = 0;
for (int u = 0; u < u1; u++) {
const int v3 = v1[u][0];
const int d3 = v1[u][1];
for (int v4 = 0; v4 < 100; v4++) {
if (vl[v4] || (f == 0 && v4 == b[i])) continue;
int d4 = d[v3][v4];
if (d4 == 0) continue;
d4 += d3;
if (d4 >= c[i]) continue;
v2[u2][0] = v4;
v2[u2][1] = d4;
vl[v4] = 1;
u2++;
if (v4 == b[i]) goto break3;
}
}
if (u2 == 0) break;
std::swap(v1, v2);
std::swap(u1, u2);
f = 1;
}
continue;
break3:
k++;
}
cout << k << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:31:13: error: 'memset' was not declared in this scope
31 | memset(v2, 0, n * sizeof *v0);
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <cstdlib>
+++ |+#include <cstring>
5 | using namespace std;
|
s957347620 | p03837 | C++ | #include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int g[101][101];
int es[101][101];
int main() {
int N, M; cin >> N >> M;
rep(i, N) rep(j, N) g[i][j] = 1 << 29;
rep(i, M) {
int a, b, c; cin >> a >> b >> c;
a--; b--;
es[a][b] = es[b][a] = g[a][b] = g[b][a] = c;
}
rep(k, N) rep(i, N) rep(j, N) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
rep(i, N) rep(j, i + 1, N) if (es[i][j] == g[i][j]) M--;
cout << M << endl;
} | a.cc:15:34: error: macro "rep" passed 3 arguments, but takes just 2
15 | rep(i, N) rep(j, i + 1, N) if (es[i][j] == g[i][j]) M--;
| ^
a.cc:3:9: note: macro "rep" defined here
3 | #define rep(i, n) for (int i = 0; i < n; i++)
| ^~~
a.cc: In function 'int main()':
a.cc:15:19: error: 'rep' was not declared in this scope
15 | rep(i, N) rep(j, i + 1, N) if (es[i][j] == g[i][j]) M--;
| ^~~
|
s151376760 | p03837 | C++ | #include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
struct Vertex;
struct Edge {
int w;
Vertex *s, *t;
};
struct Vertex {
int n;
vector<Edge*> neighbor;
int d = INT_MAX;
Vertex *pre = NULL;
int visited = 0;
};
struct comparator {
bool operator()(Vertex* p1, Vertex* p2) {
return p1->d > p2->d;
}
};
void djs(vector<Vertex*>v, int s) {
vector<Vertex*>pq(v);
pq[s]->d = 0;
make_heap(pq.begin(),pq.end(),comparator());
while(pq.size() > 0) {
Vertex* sv = pq.front();
sv->visited = 1;
pop_heap(pq.begin(),pq.end(),comparator());
pq.pop_back();
for(auto e: sv->neighbor) {
Vertex* tv = e->t;
if (tv->visited) continue;
if (sv->d + e->w < tv->d) {
tv->d = sv->d + e->w;
tv->pre = sv;
}
}
make_heap(pq.begin(),pq.end(),comparator());
}
}
int main() {
int n, m;
cin >> n >> m;
vector<Vertex*>v;
map<pair<int,int>, bool>mark;
for (int i = 1; i <= n; i++) {
Vertex *v1 = new Vertex();
v1->n = i;
v.push_back(v1);
}
for (int i = 0; i < m; i++) {
int s,t,w;
cin >> s >> t >> w;
Vertex* sv = v[s-1];
Vertex* tv = v[t-1];
Edge* e = new Edge();
e->s = sv;
e->t = tv;
e->w = w;
sv->neighbor.push_back(e);
Edge* e1 = new Edge();
e1->s = tv;
e1->t = sv;
e1->w = w;
tv->neighbor.push_back(e1);
mark[make_pair(s,t)] = false;
mark[make_pair(t,s)] = false;
}
for (int i = 0; i < n; i++) {
for (auto v1: v) {
v1->d = INT_MAX;
v1->pre = NULL;
v1->visited = 0;
}
djs(v,i);
for (auto v1:v) {
Vertex *travel = v1;
while(travel->pre != NULL) {
int t = travel->n;
int s = travel->pre->n;
mark[make_pair(s,t)] = true;
mark[make_pair(t,s)] = true;
travel = travel->pre;
}
}
}
int out = 0;
for (auto m : mark) {
if (m.second == false) out++;
}
cout << out/2 << endl;
// djs(v,1);
// for (auto v1:v) {
// cout << v1->n << ": " << v1->d << endl;
// Vertex *travel = v1;
// while(travel->pre != NULL) {
// int t = travel->n;
// int s = travel->pre->n;
// mark[make_pair(s,t)] = true;
// mark[make_pair(t,s)] = true;
// travel = travel->pre;
// }
// }
// for (auto m: mark) {
// cout << "(" << m.first.first << "," << m.first.second << ")" << ": " << m.second << endl;
// }
return 0;
} | a.cc:18:13: error: 'INT_MAX' was not declared in this scope
18 | int d = INT_MAX;
| ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
4 | #include <map>
+++ |+#include <climits>
5 | using namespace std;
a.cc: In function 'int main()':
a.cc:99:21: error: 'INT_MAX' was not declared in this scope
99 | v1->d = INT_MAX;
| ^~~~~~~
a.cc:99:21: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
|
s012522850 | p03837 | Java | import java.util.ArrayList;
import java.util.Scanner;
public class CandidatesOfNoShortestPaths {
static ArrayList[] gragh;
static int n, m;
static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
init();
for(int i = 0;i < n;i++){
dijkstra(i);
}
int count = 0;
for(int i = 0;i < n;i++){
for(int j = 0;j < gragh[i].size();j++){
Ed edge = (Ed)gragh[j].get(j);
if(!edge.used)count++;
}
}
System.out.println(count/2);
}
static void dijkstra(int a) {// node aからの各nodeまでの最短を計算
boolean used[] = new boolean[n];
int shortest[] = new int[n];
Ed myEdge[] = new Ed[n];
for (int i = 0; i < n; i++) {
shortest[i] = 999999999;
}
shortest[a] = 0;
for (int i = 0; i < n; i++) {
int next = 999999999;
int nextN = a;
for (int j = 0; j < n; j++) {
if (!used[j] && shortest[j] < next) {
next = shortest[j];
nextN = j;
}
}
used[nextN] = true;
if(nextN != a){
myEdge[nextN].used = true;
for(int j = 0;j < gragh[nextN].size();j++){
Ed e = (Ed)gragh[nextN].get(j);
if(shortest[nextN]-e.cost == shortest[e.node]){
e.used = true;
}
}
}
for (int j = 0; j < gragh[nextN].size(); j++) {
Ed edge = (Ed) gragh[nextN].get(j);
if (shortest[edge.node] > shortest[nextN] + edge.cost) {
shortest[edge.node] = shortest[nextN] + edge.cost;
myEdge[edge.node] = edge;
}
}
}
return;
}
static void init() {
gragh = new ArrayList[n];
for (int i = 0; i < n; i++) {
gragh[i] = new ArrayList<Ed>();
}
for (int i = 0; i < m; i++) {
int a = sc.nextInt() - 1;
int b = sc.nextInt() - 1;
int c = sc.nextInt();
gragh[a].add(new Ed(b, c));
gragh[b].add(new Ed(a, c));
}
}
}
class Ed {
int node;
int cost;
boolean used;
Ed(int node, int cost) {
this.node = node;
this.cost = cost;
used = false;
}
} | Main.java:4: error: class CandidatesOfNoShortestPaths is public, should be declared in a file named CandidatesOfNoShortestPaths.java
public class CandidatesOfNoShortestPaths {
^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
|
s828214736 | p03837 | Java | import java.util.*;
import java.io.*;
public class Dijkstra {
static final int INF = (int) Math.pow(10, 9);
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());;
//頂点の数
int v = Integer.parseInt(st.nextToken());
//枝の数
int m = Integer.parseInt(st.nextToken());
//それぞれの枝の出発点と到着点とそのコスト(a_i→b_iにかかるコストc_i)
int[] a = new int[m];
int[] b = new int[m];
int[] c = new int[m];
for (int i = 0; i < m; i++) {
st = new StringTokenizer(br.readLine());
a[i] = Integer.parseInt(st.nextToken()) - 1;
b[i] = Integer.parseInt(st.nextToken()) - 1;
c[i] = Integer.parseInt(st.nextToken());
}
/*
//-----------------------------ダイクストラ法 O(V+M+logV)?-------------------------
double start=System.nanoTime();
node[] nodes=new node[v];
for(int i=0;i<v;i++){
nodes[i]=new node();
nodes[i].point=i;
nodes[i].cost=INF;
}
for(int j=0;j<m;j++){
nodes[a[j]].next_list.add(b[j]); nodes[a[j]].next_cost.add(c[j]);
nodes[b[j]].next_list.add(a[j]); nodes[b[j]].next_cost.add(c[j]);
}
PriorityQueue<node> pq=new PriorityQueue(new my());
//スタートをセット
nodes[0].cost=0;
nodes[0].hist.add(0);
pq.offer(nodes[0]);
//最短経路探索
while(!pq.isEmpty()){
node n=pq.poll();
for(int i=0;i<n.next_list.size();i++){
int next=n.next_list.get(i);
int cost=n.cost+n.next_cost.get(i);
if(cost<nodes[next].cost){
nodes[next].cost=cost;
nodes[next].hist=new ArrayList<>(n.hist);
nodes[next].hist.add(next);
if(!pq.contains(nodes[next])) pq.offer(nodes[next]);
}
}
}System.out.println(nodes[v-1].cost);
System.out.println("処理時間:"+(System.nanoTime()-start)/1000000+"ms");
//------------------------------------------------------------------------
*/
//------------------ワーシャルフロイド法------------------------------------
//double start=System.nanoTime();
int[][] dp=new int[v][v];
for(int i=0;i<v;i++){ Arrays.fill(dp[i],INF); }
for(int i=0;i<m;i++){
dp[a[i]][b[i]]=c[i];
dp[b[i]][a[i]]=c[i];
}
for(int k=0;k<v;k++){
for(int i=0;i<v;i++){
for(int j=0;j<v;j++){
dp[i][j]=(int)Math.min(dp[i][j],(dp[i][k]+dp[k][j]));
}
}
}//System.out.println(dp[0][v-1]);
//System.out.println("処理時間:"+(System.nanoTime()-start)/1000000+"ms");
int count=0;
for(int i=0;i<m;i++){
if(dp[a[i]][b[i]] < c[i]) count++;
}System.out.println(count);
}
}
class node {
int point;
int cost;
List<Integer> hist = new ArrayList<>();
List<Integer> next_list=new ArrayList<>();
List<Integer> next_cost=new ArrayList<>();
}
//昇順の優先度付きキュー
class my implements Comparator {
public int compare(Object arg0, Object arg1) {
node x = (node) arg0;
node y = (node) arg1;
if (x.cost > y.cost) {
return 1;
} else if (x.cost < y.cost) {
return -1;
} else {
return 0;
}
}
} | Main.java:4: error: class Dijkstra is public, should be declared in a file named Dijkstra.java
public class Dijkstra {
^
1 error
|
s363314375 | p03837 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)
#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v,n1,n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v,n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);
static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
{
int N, M;
cin>>N>>M;
int a[100][100]={},b[100][100]={};
REP(i, N)REP(j, N) if(i!=j)b[i][j]=1<<28;
REP(i, M)
{
int u,v,c;
std::cin>>u>>v>>c;u--,v--;
a[u][v]=a[v][u]=b[u][v]=b[v][u]=c;
}
REP(i, N)REP(j, N)REP(k, N)b[i][j]=std::min(b[i][j],b[i][k]+b[k][j]);
int c=0;
REP(i, N)REPS(j, i+1, N)if(a[i][j]>b[i][j])c++;
std::cout<<c<<endl;
}
| a.cc: In function 'int main()':
a.cc:61:4: error: expected '}' at end of input
61 | }
| ^
a.cc:40:16: note: to match this '{'
40 | int main(void) {
| ^
|
s284750434 | p03837 | C++ | #include <iostream>
#include <vector>
using namespace std;
class Node{
public:
vector<int> ecost;
bool done;
int cost;
vector<int> wayid
int from;
void init(int n){ ecost.resize(n); wayid.resize(n); }
};
void find(bool *unused, Node *node, int i, int j, int n);
int main(){
int n, m;
cin >> n >> m;
int a[m], b[m], c[m];
int i, j;
for(i=0; i<m; i++){
cin >> a[i] >> b[i] >> c[i];
}
Node node[n];
for(i=0; i<n; i++){
node[i].init(n);
}
for(i=0; i<n; i++){
node[a[i]].ecost[b[i]] = c[i];
node[b[i]].ecost[a[i]] = c[i];
node[a[i]].wayid[b[i]] = i;
node[b[i]].wayid[a[i]] = i;
}
bool unused[m];
for(i=0; i<m; i++){
unused[i]=1;
}
//i...start, j...end
int k;
for(i=0; i<n; i++){
for(j=0; j<n; j++){
if(i>=j) continue;
for(k=0; k<n; k++) { node.done=0; node.cost=-1; }
find(unused, node, i, j, n);
}
}
int a;
for(i=0; i<n; i++){
a+=unused[i];
}
cout << a << endl;
return 0;
}
void find(bool *unused, Node *node, int s, int g, int n){
int i , j, k;
node[s].done=1;
for(i=0; i<n; i++){
if(node[s].ecost[i]){
node[i].cost=node[s].ecost;
node[i].from = s;
}
}
while(1){
for(i=0; i<n; i++){
if(node[i].done) continue;
if(node[i].cost <0) continue;
k=0;
for(j=0; j<n; j++){
if(node[j].cost<0) {
node[j].cost=node[i].ecost[j];
node[j].from=i;
k=1;
continue;
}
if(node[j].cost>node[i].ecost[j]+node[i].cost){
node[j].cost=node[i].ecost[j]+node[i].cost;
node[j].from=i;
k=1;
continue;
}
}
if(k==0) node[i].done=1;
}
j=1;
for(i=0; i<n; i++){
j*=node[i].done;
}
if(j) break;
}
i=g;
while(1){
unused[node[i].wayid[node[i].from]] = 0;
i=node[i].from;
if(i==s) break;
}
} | a.cc:10:21: error: expected ';' at end of member declaration
10 | vector<int> wayid
| ^~~~~
| ;
a.cc: In function 'int main()':
a.cc:44:43: error: request for member 'done' in 'node', which is of non-class type 'Node [n]'
44 | for(k=0; k<n; k++) { node.done=0; node.cost=-1; }
| ^~~~
a.cc:44:56: error: request for member 'cost' in 'node', which is of non-class type 'Node [n]'
44 | for(k=0; k<n; k++) { node.done=0; node.cost=-1; }
| ^~~~
a.cc:48:13: error: conflicting declaration 'int a'
48 | int a;
| ^
a.cc:19:13: note: previous declaration as 'int a [m]'
19 | int a[m], b[m], c[m];
| ^
a.cc:50:18: error: incompatible types in assignment of 'bool' to 'int [m]'
50 | a+=unused[i];
| ~^~~~~~~~~~~
a.cc: In function 'void find(bool*, Node*, int, int, int)':
a.cc:63:46: error: cannot convert 'std::vector<int>' to 'int' in assignment
63 | node[i].cost=node[s].ecost;
| ~~~~~~~~^~~~~
| |
| std::vector<int>
|
s993362716 | p03837 | C++ | #include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int MAX_V = 100, INF = 999999;
static int cost[MAX_V][MAX_V];
static int edge[MAX_V][MAX_V];
static int d[MAX_V];
static int pre[MAX_V];
bool used[MAX_V];
static int V, E;
void input() {
memset(cost, INF, sizeof(cost));
cin >> E >> V;
for (int i = 0; i < V; i++) {
int a, b, w;
cin >> a >> b >> w;
cost[a - 1][b - 1] = w;
cost[b - 1][a - 1] = w;
edge[a - 1][b - 1] = 1;
edge[b - 1][a - 1] = 1;
}
}
void dijkstra(int s) {
fill(d, d + V, INF);
fill(used, used + V, false);
fill(pre, pre + V, -1);
d[s] = 0;
while (true) {
int v = -1;
for (int u = 0; u < V; u++) {
if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
}
if (v == -1) break;
used[v] = true;
for (int u = 0; u < V; u++) {
if (d[u] > d[v] + cost[v][u]) {
d[u] = d[v] + cost[v][u];
pre[u] = v;
}
}
}
}
void get_path(int t) {
for (; t != -1; t = pre[t]) {
edge[t][pre[t]]--;
edge[pre[t]][t]--;
}
}
int main()
{
input();
for (int i = 0; i < V; i++) {
dijkstra(i);
for (int j = i + 1; j < V; j++) {
get_path(j);
}
}
int ans = 0;
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
if (edge[i][j] == 1) ans++;
}
}
cout << ans/2 << endl;
return 0;
} | a.cc: In function 'void input()':
a.cc:15:9: error: 'memset' was not declared in this scope
15 | memset(cost, INF, sizeof(cost));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<queue>
+++ |+#include <cstring>
4 | #include<vector>
|
s095078622 | p03837 | C++ | #include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>
using namespace std;
#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))
double maxd(double a,double b){
if(a>=b){
return a;
}
return b;
}
double mind(double a,double b){
if(a<=b){
return a;
}
return b;
}
long long gcd(long long a, long long b){
if(a<b){
swap(a,b);
}
while(b){
long long r = a%b;
a=b;
b=r;
}
return a;
}
long long lcm(long long a, long long b){
return (a*b)/gcd(a,b);
}
int isPrim(int a){
if(a==1){
return 0;
}
for(int i=2;i<=(a+1)/2;i++){
if(a%i==0){
return 0;
}
}
return 1;
}
long long mod_pow(long long x, long long n, long long mod){
//xのn乗を計算するのにn乗を2進表記にして計算
//x^22 = x^16 + x^4 + x^2
long long ret=1;
while(n>0){
if(n%2==1){
ret=(ret*x)%mod;//答えに付加
}
x=(x*x)%mod;//2乗
n=n/2;
}
return ret;
}
struct XX{
int u;
int v;
int t;
};
class xxIntu {
public:
bool operator()(const XX& riLeft, const XX& riRight) const {
//第2条件
if((riLeft.t) == (riRight.t)){
return riLeft.u < riRight.u;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
}
//第1条件
return (riLeft.t) < (riRight.t);
}
};
/*bool operator< (const XX &riLeft, const XX &riRight){
return riLeft.d < riRight.d;
};*/
int index(string in){
if(in=="A"){
return 0;
}else if(in=="B"){
return 1;
}else if(in=="C"){
return 2;
}else if(in=="D"){
return 3;
}else if(in=="E"){
return 4;
}else if(in=="F"){
return 5;
}else if(in=="G"){
return 6;
}else if(in=="H"){
return 7;
}else if(in=="I"){
return 8;
}else if(in=="J"){
return 9;
}else if(in=="K"){
return 10;
}else if(in=="L"){
return 11;
}else if(in=="M"){
return 12;
}else if(in=="N"){
return 13;
}else if(in=="O"){
return 14;
}else if(in=="P"){
return 15;
}else if(in=="Q"){
return 16;
}else if(in=="R"){
return 17;
}else if(in=="S"){
return 18;
}else if(in=="T"){
return 19;
}else if(in=="U"){
return 20;
}else if(in=="V"){
return 21;
}else if(in=="W"){
return 22;
}else if(in=="X"){
return 23;
}else if(in=="Y"){
return 24;
}else if(in=="Z"){
return 25;
}
return -1;
}
string rindex(int in){
if(in==65){
return "A";
}else if(in==66){
return "B";
}else if(in==67){
return "C";
}else if(in==68){
return "D";
}else if(in==69){
return "E";
}else if(in==70){
return "F";
}else if(in==71){
return "G";
}else if(in==72){
return "H";
}else if(in==73){
return "I";
}else if(in==74){
return "J";
}else if(in==75){
return "K";
}else if(in==76){
return "L";
}else if(in==77){
return "M";
}else if(in==78){
return "N";
}else if(in==79){
return "O";
}else if(in==80){
return "P";
}else if(in==81){
return "Q";
}else if(in==82){
return "R";
}else if(in==83){
return "S";
}else if(in==84){
return "T";
}else if(in==85){
return "U";
}else if(in==86){
return "V";
}else if(in==87){
return "W";
}else if(in==88){
return "X";
}else if(in==89){
return "Y";
}else if(in==90){
return "Z";
}
return "";
}
int ppar[200001];
int rrank[200001];
void init(int n){
for(int i=1;i<=n;i++){
ppar[i]=i;
rrank[i]=0;
}
}
int find(int x){
if(ppar[x]==x){
return x;
}else{
return ppar[x]=find(ppar[x]);
}
}
void unite(int x,int y){
x=find(x);
y=find(y);
if(x==y){
return;
}
if(rrank[x]<rrank[y]){
ppar[x]=ppar[y];
}else{
ppar[y]=x;
if(rrank[x]==rrank[y]){
rrank[x]++;
}
}
}
bool same(int x,int y){
return find(x)==find(y);
}
//kruskal
struct edge{
int u;
int v;
int cost;
};
bool comp(edge& e1,edge& e2){
return e1.cost < e2.cost;
}
edge es[1000];
int V,E;
int ans=0;
int kruskal(){
sort(es,es+E,comp);
init(V);
int res = 0;
for(int i=0;i<E;i++){
edge e = es[i];
if(!same(e.u,e.v)){
unite(e.u,e,v);
res+=e.cost;
ans++;
}
}
return res;
}
int main(int argc, const char * argv[])
{
//std::ios::sync_with_stdio(false);
//scanf("%s",S);
//scanf("%d",&N);
//sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
//getline(cin, target);
//cin >> x >> y;
//テスト用
//ifstream ifs( "1_06.txt" );
//ifs >> a;
//ここから
int N,M;
cin >> N >> M;
for(int i=0;i<M;i++){
cin >> es[i].u >> es[i].v >> es[i].cost;
}
V=N;
E=M;
kruskal();
cout << M-ans << endl;
//ここまで
//cout << "ans" << endl;改行含む
//printf("%.0f\n",ans);//小数点以下表示なし
//printf("%.7f\n",p);
//printf("%f\n",pow(2,ans.size()));
return 0;
}
| a.cc: In function 'int kruskal()':
a.cc:270:25: error: 'v' was not declared in this scope
270 | unite(e.u,e,v);
| ^
|
s421184012 | p03837 | C++ | #include <bits/stdc++.h>
using namespace std;
int graph[101][101];
int dist[101][101];
int prev[101][101];
int V;
int cnt[101][101], mark[101][101];
void floydWarshall ()
{
int i, j, k;
for (i = 0; i < V; i++)
for (j = 0; j < V; j++) {
if(!graph[i][j]) continue;
dist[i][j] = graph[i][j];
mark[i][j] = 1;
cnt[i][j]++;
prev[i][j] = i;
}
for (k = 0; k < V; k++)
{
// Pick all vertices as source one by one
for (i = 0; i < V; i++)
{
for (j = 0; j < V; j++)
{
if(!graph[i][k] && !graph[k][j]) continue;
if (dist[i][k] + dist[k][j] < dist[i][j]) {
dist[i][j] = dist[i][k] + dist[k][j];
if(prev[i][j] != -1) {
if(cnt[prev[i][j]][j] == 1) mark[prev[i][j]][j] = 0;
cnt[prev[i][j]][j]--;
}
mark[k][j] = 1;
cnt[k][j]++;
prev[i][j] = k;
}
}
}
}
}
set<pair<int, int> > s;
// void f() {
// for(int i = 0; i < V; ++i) {
// for(int j = 0; j < V; ++j) {
// if(i == j) continue;
// int curr = pre[i][j];
// int curr2 = j;
// while(curr2 != curr) {
// if(curr > curr2) swap(curr, curr2);
// s.insert(make_pair(curr, curr2));
// curr2 = curr;
// curr = pre[i][curr2];
// }
// }
// }
// }
int main(void) {
int n, m;
cin>>n>>m;
memset(graph, 0, sizeof(graph));
memset(cnt, 0, sizeof(cnt));
memset(mark, 0, sizeof(mark));
memset(prev, -1, sizeof(prev));
for(int i = 0; i < m; ++i) {
int a, b, c;
cin>>a>>b>>c;
--a, --b;
graph[a][b] = c;
graph[b][a] = c;
}
V = n;
floydWarshall();
int cnt = 0;
for(int i = 0; i < n; ++i) {
for(int j = i+1; j < n; ++j) {
if(mark[i][j]) cnt++;
//cout<<mark[i][j];
}
//cout<<endl;
}
cout<<(m-cnt);
return 0;
}
| a.cc: In function 'void floydWarshall()':
a.cc:22:13: error: reference to 'prev' is ambiguous
22 | prev[i][j] = i;
| ^~~~
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:8:5: note: 'int prev [101][101]'
8 | int prev[101][101];
| ^~~~
a.cc:35:24: error: reference to 'prev' is ambiguous
35 | if(prev[i][j] != -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:8:5: note: 'int prev [101][101]'
8 | int prev[101][101];
| ^~~~
a.cc:36:40: error: reference to 'prev' is ambiguous
36 | if(cnt[prev[i][j]][j] == 1) mark[prev[i][j]][j] = 0;
| ^~~~
/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:8:5: note: 'int prev [101][101]'
8 | int prev[101][101];
| ^~~~
a.cc:36:70: error: reference to 'prev' is ambiguous
36 | if(cnt[prev[i][j]][j] == 1) mark[prev[i][j]][j] = 0;
| ^~~~
/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:8:5: note: 'int prev [101][101]'
8 | int prev[101][101];
| ^~~~
a.cc:37:33: error: reference to 'prev' is ambiguous
37 | cnt[prev[i][j]][j]--;
| ^~~~
/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:8:5: note: 'int prev [101][101]'
8 | int prev[101][101];
| ^~~~
a.cc:41:21: error: reference to 'prev' is ambiguous
41 | prev[i][j] = k;
| ^~~~
/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:8:5: note: 'int prev [101][101]'
8 | int prev[101][101];
| ^~~~
a.cc: In function 'int main()':
a.cc:77:16: error: reference to 'prev' is ambiguous
77 | memset(prev, -1, sizeof(prev));
| ^~~~
/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:8:5: note: 'int prev [101][101]'
8 | int prev[101][101];
| ^~~~
a.cc:77:33: error: reference to 'prev' is ambiguous
77 | memset(prev, -1, sizeof(prev));
| ^~~~
/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:8:5: note: 'int prev [101][101]'
8 | int prev[101][101];
| ^~~~
|
s658758767 | p03837 | C++ | #include <iostream> #include <algorithm> #include <vector> #include <map>
using namespace std;
void count(
map<pair<int, int>, bool>& edges,
const vector<vector<int>>& middle,
int src, int dst
) {
int m = middle[src][dst];
int min = src < dst ? src : dst;
int max = src < dst ? dst : src;
if (m < 0) {
edges[make_pair(min, max)] = true;
} else {
count(edges, middle, src, m);
count(edges, middle, m, dst);
}
}
int main()
{
int N, M;
cin >> N >> M;
if (N - M == 1) {
cout << 0 << endl;
return 0;
}
vector<vector<int>> distance(N, vector<int>(N, -1));
for (int i = 0; i < M; ++i) {
int src, dst, length;
cin >> src >> dst >> length;
--src; --dst;
distance[src][dst] = distance[dst][src] = length;
}
vector<vector<int>> middle(N, vector<int>(N, -1));
for (int k = 0; k < N; ++k) {
for (int s = 0; s < N; ++s) {
for (int t = 0; t < N; ++t) {
if (distance[s][k] < 0 or distance[k][t] < 0) continue;
int sum = distance[s][k] + distance[k][t];
if (distance[s][t] < 0 or sum < distance[s][t]) {
distance[s][t] = distance[t][s] = sum;
middle[s][t] = middle[t][s] = k;
}
}
}
}
map<pair<int, int>, bool> edges;
for (int i = 0; i < N; ++i) {
for (int j = i + 1; j < N; ++j) {
count(edges, middle, i, j);
}
}
cout << (M - edges.size()) << endl;
return 0;
} | a.cc:1:81: warning: extra tokens at end of #include directive
1 | #include <iostream> #include <algorithm> #include <vector> #include <map>
| ^
a.cc:3:6: error: variable or field 'count' declared void
3 | void count(
| ^~~~~
a.cc:4:3: error: 'map' was not declared in this scope
4 | map<pair<int, int>, bool>& edges,
| ^~~
a.cc:2:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
1 | #include <iostream> #include <algorithm> #include <vector> #include <map>
+++ |+#include <map>
2 | using namespace std;
a.cc:4:21: error: expected primary-expression before ',' token
4 | map<pair<int, int>, bool>& edges,
| ^
a.cc:4:23: error: expected primary-expression before 'bool'
4 | map<pair<int, int>, bool>& edges,
| ^~~~
a.cc:5:3: error: expected primary-expression before 'const'
5 | const vector<vector<int>>& middle,
| ^~~~~
a.cc:6:3: error: expected primary-expression before 'int'
6 | int src, int dst
| ^~~
a.cc:6:12: error: expected primary-expression before 'int'
6 | int src, int dst
| ^~~
a.cc: In function 'int main()':
a.cc:28:3: error: 'vector' was not declared in this scope
28 | vector<vector<int>> distance(N, vector<int>(N, -1));
| ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
1 | #include <iostream> #include <algorithm> #include <vector> #include <map>
+++ |+#include <vector>
2 | using namespace std;
a.cc:28:17: error: expected primary-expression before 'int'
28 | vector<vector<int>> distance(N, vector<int>(N, -1));
| ^~~
a.cc:33:13: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
33 | distance[src][dst] = distance[dst][src] = length;
| ^
a.cc:33:34: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
33 | distance[src][dst] = distance[dst][src] = length;
| ^
a.cc:36:17: error: expected primary-expression before 'int'
36 | vector<vector<int>> middle(N, vector<int>(N, -1));
| ^~~
a.cc:40:21: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
40 | if (distance[s][k] < 0 or distance[k][t] < 0) continue;
| ^
a.cc:40:43: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
40 | if (distance[s][k] < 0 or distance[k][t] < 0) continue;
| ^
a.cc:41:27: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
41 | int sum = distance[s][k] + distance[k][t];
| ^
a.cc:41:44: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
41 | int sum = distance[s][k] + distance[k][t];
| ^
a.cc:42:21: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
42 | if (distance[s][t] < 0 or sum < distance[s][t]) {
| ^
a.cc:42:49: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
42 | if (distance[s][t] < 0 or sum < distance[s][t]) {
| ^
a.cc:43:19: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
43 | distance[s][t] = distance[t][s] = sum;
| ^
a.cc:43:36: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
43 | distance[s][t] = distance[t][s] = sum;
| ^
a.cc:44:11: error: 'middle' was not declared in this scope
44 | middle[s][t] = middle[t][s] = k;
| ^~~~~~
a.cc:50:3: error: 'map' was not declared in this scope
50 | map<pair<int, int>, bool> edges;
| ^~~
a.cc:50:3: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
a.cc:50:21: error: expected primary-expression before ',' token
50 | map<pair<int, int>, bool> edges;
| ^
a.cc:50:23: error: expected primary-expression before 'bool'
50 | map<pair<int, int>, bool> edges;
| ^~~~
a.cc:53:13: error: 'edges' was not declared in this scope
53 | count(edges, middle, i, j);
| ^~~~~
a.cc:53:20: error: 'middle' was not declared in this scope
53 | count(edges, middle, i, j);
| ^~~~~~
a.cc:53:7: error: 'count' was not declared in this scope
53 | count(edges, middle, i, j);
| ^~~~~
a.cc:57:16: error: 'edges' was not declared in this scope
57 | cout << (M - edges.size()) << endl;
| ^~~~~
|
s313303646 | p03837 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//頂点fromkら頂点へのtoへのコストcostの辺
struct edge { int from, to, cost;};
const int MAX_V = 100;
const int MAX_E = 10000;
const int INF = 9999;
edge es[MAX_E];
int prev[MAX_V];
int d[MAX_V]; //最短距離
int V, E; //Vは頂点数、Eは辺の数
int used[MAX_V][MAX_V];
//s番目の頂点から各頂点への最短距離を求める
void shortest_path(int s) {
for(int i = 0; i < V; i++) d[i] = INF;
fill(prev, prev + V, -1);
d[s] = 0;
while (true) {
bool update = false;
for(int i = 0; i < E; i++) {
edge e = es[i];
if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
d[e.to] = d[e.from] + e.cost;
update = true;
prev[e.to] = prev[e.from];
}
}
if(!update) break;
}
}
vector<int> get_path(int t) {
vector<int> path;
for(; t != -1 ; t = prev[t]) path.push_back(t);
reverse(path.begin(), path.end());
return path;
}
int main() {
int ans = 0;
cin >> V >> E;
for(int i = 0; i < E; i++) {
cin >> es[i].to >> es[i].from >> es[i].cost;
}
for(int i = 0; i < V; i++) {
shortest_path(i);
for(int j = 1; j < V; j++) {
vector<int> path = get_path(j);
for(int k = 0; k < path.size()-1; k++) {
used[path[k]][path[k+1]] = 1;
}
}
}
for(int i = 0; i < E; i++) {
if(!used[es[i].to][es[i].from]) {
ans++;
}
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'void shortest_path(int)':
a.cc:24:8: error: reference to 'prev' is ambiguous
24 | fill(prev, prev + V, -1);
| ^~~~
In file included from /usr/include/c++/14/string:47,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:16:5: note: 'int prev [100]'
16 | int prev[MAX_V];
| ^~~~
a.cc:24:14: error: reference to 'prev' is ambiguous
24 | fill(prev, prev + V, -1);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:16:5: note: 'int prev [100]'
16 | int prev[MAX_V];
| ^~~~
a.cc:33:9: error: reference to 'prev' is ambiguous
33 | prev[e.to] = prev[e.from];
| ^~~~
/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:16:5: note: 'int prev [100]'
16 | int prev[MAX_V];
| ^~~~
a.cc:33:22: error: reference to 'prev' is ambiguous
33 | prev[e.to] = prev[e.from];
| ^~~~
/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:16:5: note: 'int prev [100]'
16 | int prev[MAX_V];
| ^~~~
a.cc: In function 'std::vector<int> get_path(int)':
a.cc:42:23: error: reference to 'prev' is ambiguous
42 | for(; t != -1 ; t = prev[t]) path.push_back(t);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:16:5: note: 'int prev [100]'
16 | int prev[MAX_V];
| ^~~~
|
s029430738 | p03837 | C++ | #include <iostream>
#include <vector>
#include <queue>
#include <limits>
#include <forward_list>
using namespace std;
struct edge {
int to, cost, id;
};
using graph = vector<vector<edge>>;
auto dijkstra(graph const& gr, int start) {
int const V = gr.size();
constexpr int Inf = numeric_limits<int>::max() / 2;
vector<pair<int, forward_list<int>>> result(V, {Inf, forward_list<int>()});
using P = pair<int, int>;
priority_queue<P, vector<P>, greater<P>> que;
que.emplace(0, start);
result[start].first = 0;
while (!que.empty()) {
int v, d;
tie(d, v) = que.top();
que.pop();
if (d > result[v].first) continue;
for (auto&& e : gr[v]) {
if (result[e.to].first < d + e.cost) continue;
if (result[e.to].first > d + e.cost)
result[e.to].second.clear();
result[e.to].first = d + e.cost;
result[e.to].second.push_front(e.id);
que.emplace(d + e.cost, e.to);
}
}
return result;
}
int main() {
int n, m;
cin >> n >> m;
graph gr(n);
for (int i = 0; i < m; i++) {
int a, b, cost;
cin >> a >> b >> cost;
a--; b--;
gr[a].push_back({b, cost, i});
gr[b].push_back({a, cost, i});
}
vector<bool> used(m, false);
for (int i = 0; i < n; i++) {
auto const& ds = dijkstra(gr, i);
for (auto& v : ds)
for (auto k : v.second)
used[k] = true;
}
cout << count(begin(used), end(used), false) << endl;
}
| a.cc: In function 'int main()':
a.cc:57:11: error: 'count' was not declared in this scope
57 | cout << count(begin(used), end(used), false) << endl;
| ^~~~~
|
s429844162 | p03837 | C++ | def used(dp,u,v,w):
n=len(dp)
for i in range(n):
for j in range(i+1,n):
if dp[i][j]==dp[i][u]+w+dp[v][j] or dp[i][j]==dp[i][v]+w+dp[u][j]:
return True
return False
while 1:
try:
n,m=map(int,input().split())
es=[]
for _ in range(m):
u,v,w=map(int,input().split())
es.append((u-1,v-1,w))
except: break
dp=[[float('inf')]*n for _ in range(n)]
for i in range(n):
dp[i][i]=0
for u,v,w in es:
dp[u][v]=dp[v][u]=w
for k in range(n):
for i in range(n):
for j in range(n):
dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
print(sum(int(not used(dp,u,v,w)) for u,v,w in es))
| a.cc:18:16: warning: multi-character character constant [-Wmultichar]
18 | dp=[[float('inf')]*n for _ in range(n)]
| ^~~~~
a.cc:1:1: error: 'def' does not name a type
1 | def used(dp,u,v,w):
| ^~~
|
s973997353 | p03837 | C++ | #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<tuple>
#include<set>
#include<functional>
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
int main()
{
int N, M;
std::cin >> N >> M;
std::vector<std::map<int, int>> edge(N);
std::set<std::pair<int, int>> set;
for (int i{};i < M;++i)
{
int a, b, c;
std::cin >> a >> b >> c;
edge[a - 1][b - 1] = c;
edge[b - 1][a - 1] = c;
set.emplace(std::max(a - 1, b - 1), std::min(a - 1, b - 1));
}
for (int i{};i < N;++i)
{
std::vector<int> flag(N, 0);
flag[i] = true;
p_queue<std::tuple<int, int, int>> queue;
for (auto const& p : edge[i])
{
queue.emplace(p.second, p.first);
}
while (queue.size())
{
auto top = queue.top();
queue.pop();
auto dis = std::get<0>(top);
auto now = std::get<1>(top);
auto from = std::get<2>(top);
if (flag[now])
{
continue;
}
flag[now] = true;
set.erase(std::make_pair(std::max(from, now), std::min(from, now)));
for (auto const& p : edge[now])
{
queue.emplace(dis + p.second, p.first);
}
}
}
std::cout << set.size() << std::endl;
} | In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
from /usr/include/c++/14/bits/allocator.h:46,
from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::tuple<int, int, int>; _Args = {const int&, const int&}; _Tp = std::tuple<int, int, int>]':
/usr/include/c++/14/bits/alloc_traits.h:575:17: required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::tuple<int, int, int>; _Args = {const int&, const int&}; _Tp = std::tuple<int, int, int>; allocator_type = std::allocator<std::tuple<int, int, int> >]'
575 | __a.construct(__p, std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30: required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {const int&, const int&}; _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >; reference = std::tuple<int, int, int>&]'
117 | _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118 | std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:754:18: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {const int&, const int&}; _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::greater<void>]'
754 | c.emplace_back(std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:34:17: required from here
34 | queue.emplace(p.second, p.first);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'std::tuple<int, int, int>::tuple(const int&, const int&)'
191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:1646:9: note: candidate: 'template<class _Alloc, class ... _UElements, bool _Valid, typename std::enable_if<std::tuple<int, int, int>::_TCC<_Valid>::__is_explicitly_constructible<_UElements ...>(), bool>::type <anonymous> > std::tuple< <template-parameter-1-1> >::tuple(std::allocator_arg_t, const _Alloc&, std::tuple<_Args2 ...>&&) [with _UElements = _Alloc; bool _Valid = {_UElements ...}; typename std::enable_if<_TCC<_Valid>::__is_explicitly_constructible<_UElements ...>(), bool>::type <anonymous> = _Valid; _Elements = {int, int, int}]'
1646 | tuple(allocator_arg_t __tag, const _Alloc& __a,
| ^~~~~
/usr/include/c++/14/tuple:1646:9: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/tuple:1634:9: note: candidate: 'template<class _Alloc, class ... _UElements, bool _Valid, typename std::enable_if<std::tuple<int, int, int>::_TCC<_Valid>::__is_implicitly_constructible<_UElements ...>(), bool>::type <anonymous> > std::tuple< <template-parameter-1-1> >::tuple(std::allocator_arg_t, const _Alloc&, std::tuple<_Args2 ...>&&) [with _UElements = _Alloc; bool _Valid = {_UElements ...}; typename std::enable_if<_TCC<_Valid>::__is_implicitly_constructible<_UElements ...>(), bool>::type <anonymous> = _Valid; _Elements = {int, int, int}]'
1634 | tuple(allocator_arg_t __tag, const _Alloc& __a,
| ^~~~~
/usr/include/c++/14/tuple:1634:9: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/tuple:1623:9: note: candidate: 'template<class _Alloc, class ... _UElements, bool _Valid, typename std::enable_if<std::tuple<int, int, int>::_TCC<_Valid>::__is_explicitly_constructible<const _UElements& ...>(), bool>::type <anonymous> > std::tuple< <template-parameter-1-1> >::tuple(std::allocator_arg_t, const _Alloc&, const std::tuple<_Args2 ...>&) [with _UElements = _Alloc; bool _Valid = {_UElements ...}; typename std::enable_if<_TCC<_Valid>::__is_explicitly_constructible<const _UElements& ...>(), bool>::type <anonymous> = _Valid; _Elements = {int, int, int}]'
1623 | tuple(allocator_arg_t __tag, const _Alloc& __a,
| ^~~~~
/usr/include/c++/14/tuple:1623:9: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/tuple:1611:9: note: candidate: 'template<class _Alloc, class ... _UElements, bool _Valid, typename std::enable_if<std::tuple<int, int, int>::_TCC<_Valid>::__is_implicitly_constructible<const _UElements& ...>(), bool>::type <anonymous> > std::tuple< <template-parameter-1-1> >::tuple(std::allocator_arg_t, const _Alloc&, const std::tuple<_Args2 ...>&) [with _UElements = _Alloc; bool _Valid = {_UElements ...}; typename std::enable_if<_TCC<_Valid>::__is_implicitly_constructible<const _UElements& ...>(), bool>::type <anonymous> = _Valid; _Elements = {int, int, int}]'
1611 | tuple(allocator_arg_t __tag, const _Alloc& __a,
| ^~~~~
/usr/include/c++/14/tuple:1611:9: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/tuple:1603:9: note: candidate: 'template<class _Alloc> std::tuple< <template-parameter-1-1> >::tuple(std::allocator_arg_t, const _Alloc&, std::tuple< <template-parameter-1-1> >&&) [with _Elements = {int, int, int}]'
1603 | tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
| ^~~~~
/usr/include/c++/14/tuple:1603:9: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/tuple:1598:9: note: candidate: 'template<class _Alloc> std::tuple< <template-parameter-1-1> >::tuple(std::allocator_arg_t, const _Alloc&, const std::tuple< <template-parameter-1-1> >&) [with _Elements = {int, int, int}]'
1598 | tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
| ^~~~~
/usr/include/c++/14/tuple:1598:9: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/tuple:1591:9: note: candidate: 'template<class _Alloc, class ... _UElements, bool _Valid, typename std::enable_if<std::tuple<int, int, int>::_TCC<_Valid>::__is_explicitly_constructible<_UElements ...>(), bool>::type <anonymous> > std::tuple< <template-parameter-1-1> >::tuple(std::allocator_arg_t, const _Alloc&, _UElements&& ...) [with _UElements = _Alloc; bool _Valid = {_UElements ...}; typename std::enable_if<_TCC<_Valid>::__is_explicitly_constructible<_UElements ...>(), bool>::type <anonymous> = _Valid; _Elements = {int, int, int}]'
1591 | tuple(allocator_arg_t __tag, const _Alloc& __a,
| ^~~~~
/usr/include/c++/14/tuple:1591:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:1587:59: error: no matching function for call to 'std::tuple<int, int, int>::__valid_args<>()'
1587 | bool _Valid = __valid_args<_UElements...>(),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/c++/14/tuple:1390:31: note: candidate: 'template<class _Up> static constexpr bool std::tuple< <template-parameter-1-1> >::__valid_args() [with _Elements = {int, int, int}]'
1390 | static constexpr bool __valid_args()
| ^~~~~~~~~~~~
/usr/include/c++/14/tuple:1390:31: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:1587:59: note: couldn't deduce template parameter '_Up'
1587 | bool _Valid = __valid_args<_UElements...>(),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/c++/14/tuple:1398:31: note: candidate: 'template<class, class, class ... _Tail> static constexpr bool std::tuple< <template-parameter-1-1> >::__valid_args() [with _Tail = <template-parameter-1-1>; _Elements = {int, int, int}]'
1398 | static constexpr bool __valid_args()
| ^~~~~~~~~~~~
/usr/include/c++/14/tuple:1398:31: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:1587:59: note: couldn't deduce template parameter '<template-parameter-1-1>'
1587 | bool _Valid = __valid_args<_UElements...>(),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/c++/14/tuple:1581:9: note: candidate: 'template<class _Alloc, class ... _UElements, bool _Valid, typename std::enable_if<std::tuple<int, int, int>::_TCC<_Valid>::__is_implicitly_constructible<_UElements ...>(), bool>::type <anonymous> > std::tuple< <template-parameter-1-1> >::tuple(std::allocator_arg_t, const _Alloc&, _UElements&& ...) [with _UElements = _Alloc; bool _Valid = {_UElements ...}; typename std::enable_if<_TCC<_Valid>::__is_implicitly_constructible<_UElements ...>(), bool>::type <anonymous> = _Valid; _Elements = {int, int, int}]'
1581 | tuple(allocator_arg_t __tag, const _Alloc& __a,
| ^~~~~
/usr/include/c++/14/tuple:1581:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:1578:57: error: no matching function for call to 'std::tuple<int, int, int>::__valid_args<>()'
1578 | bool _Valid = __valid_args<_UElements...>(),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/c++/14/tuple:1390:31: note: candidate: 'template<class _Up> static constexpr bool std::tuple< <template-parameter-1-1> >::__valid_args() [with _Elements = {int, int, int}]'
1390 | |
s932210964 | p03837 | C++ | #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;
int n, m;
int a[1010], b[1010], c[1010];
int d[110][110];
int prev[110][110];
const int INF = 1e7;
void init(int n){
rep(i, 0, n){
rep(j, 0, n){
d[i][j] = INF;
prev[i][j] = i;
if(i == j) d[i][j] = 0;
}
}
}
void warshall_floyd(){
rep(k, 0, n){
rep(i, 0, n){
rep(j, 0, n){
if(d[i][k] + d[k][j] < d[i][j]){
d[i][j] = d[i][k] + d[k][j];
prev[i][j] = prev[k][j];
}
}
}
}
}
int f[110][110];
void path(int s, int g){
vector<int> pt;
for(int i = g; i != s; i = prev[s][i]){
// st.insert(i);
pt. push_back(i);
}
reverse(all(pt));
int now = s;
rep(i, 0, pt.size()){
f[now][pt[i]] = true;
now = pt[i];
}
}
signed main(){
cin >> n >> m;
init(n);
rep(i, 0, m){
cin >> a[i] >> b[i] >> c[i];
a[i]--;
b[i]--;
d[a[i]][b[i]] = c[i];
d[b[i]][a[i]] = c[i];
}
warshall_floyd();
rep(i, 0, n) rep(j, 0, n) f[i][j] = false;
rep(i, 0, n){
rep(j, i + 1, n){
path(i, j);
}
}
int ans = 0;
rep(i, 0, m){
if(f[a[i]][b[i]] == false && f[b[i]][a[i]] == false) ans++;
}
o(ans);
} | a.cc: In function 'void init(long long int)':
a.cc:21:13: error: reference to 'prev' is ambiguous
21 | prev[i][j] = i;
| ^~~~
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:13:5: note: 'long long int prev [110][110]'
13 | int prev[110][110];
| ^~~~
a.cc: In function 'void warshall_floyd()':
a.cc:33:21: error: reference to 'prev' is ambiguous
33 | prev[i][j] = prev[k][j];
| ^~~~
/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:13:5: note: 'long long int prev [110][110]'
13 | int prev[110][110];
| ^~~~
a.cc:33:34: error: reference to 'prev' is ambiguous
33 | prev[i][j] = prev[k][j];
| ^~~~
/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:13:5: note: 'long long int prev [110][110]'
13 | int prev[110][110];
| ^~~~
a.cc: In function 'void path(long long int, long long int)':
a.cc:44:32: error: reference to 'prev' is ambiguous
44 | for(int i = g; i != s; i = prev[s][i]){
| ^~~~
/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:13:5: note: 'long long int prev [110][110]'
13 | int prev[110][110];
| ^~~~
|
s756761302 | p03837 | C++ | #include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
set<pair<int,int>> used_edge;
template <typename T>
class Dijkstra {
struct edge { int to; T cost; };
typedef pair<T, int> P; // <譛遏ュ霍晞屬, 鬆らせ逡ェ蜿キ>
public:
T INF;
Dijkstra(int V)
: INF(std::numeric_limits<T>::max())
, m_V(V)
{
m_G.resize(m_V);
}
// a -> b縺ォ迚・婿蜷代・繧ィ繝・ず繧貞シオ繧・ void add_dir_edge(int a, int b, T cost) {
m_G[a].push_back( edge{ b, cost } );
}
// a <-> b縺ォ荳。譁ケ蜷代・繧ィ繝・ず繧貞シオ繧・ void add_undir_edge(int a, int b, T cost) {
add_dir_edge(a, b, cost);
add_dir_edge(b, a, cost);
}
// 鬆らせs縺九i蜷・らせ縺セ縺ァ縺ョ霍晞屬繧定ィ育ョ励@縺ヲ霑斐☆
vector<T> shortest_path(int s) {
vector<T> d(m_V, INF);
vector<pair<int,int>> last_edge(m_V);
priority_queue<P, vector<P>, greater<P> > que;
d[s] = 0;
que.push(P(0, s));
while(!que.empty()) {
P p = que.top();
que.pop();
auto dist = p.first;
auto v = p.second;
if (d[v] < dist) continue;
REP(i, m_G[v].size()) {
edge e = m_G[v][i];
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(P(d[e.to], e.to));
last_edge[e.to] = mp(v, e.to);
}
}
}
for (auto edge : last_edge) {
int v1 = edge.first;
int v2 = edge.second;
if (v1 != v2) {
used_edge.insert(mp(v1,v2));
used_edge.insert(mp(v2,v1));
}
}
return d;
}
private:
int m_V;
vector<vector<edge> > m_G;
};
int main(void)
{
cin.sync_with_stdio(false);
int N, M;
cin >> N >> M;
Dijkstra<int> dij(N);
REP(m,M) {
int a, b, c;
cin >> a >> b >> c;
--a; --b;
dij.add_undir_edge(a, b, c);
}
REP(n,N) {
auto res = dij.shortest_path(n);
}
cout << (M - (SIZE(used_edge) / 2)) << endl;
return 0;
}
| a.cc:50:9: error: 'm_G' does not name a type
50 | m_G[a].push_back( edge{ b, cost } );
| ^~~
a.cc:50:43: error: expected unqualified-id before ')' token
50 | m_G[a].push_back( edge{ b, cost } );
| ^
a.cc: In constructor 'Dijkstra<T>::Dijkstra(int)':
a.cc:44:11: error: class 'Dijkstra<T>' does not have any field named 'm_V'
44 | , m_V(V)
| ^~~
a.cc:46:9: error: 'm_G' was not declared in this scope
46 | m_G.resize(m_V);
| ^~~
a.cc:46:20: error: 'm_V' was not declared in this scope
46 | m_G.resize(m_V);
| ^~~
a.cc: At global scope:
a.cc:51:6: error: expected ';' before 'add_dir_edge'
51 | }
| ^
| ;
......
54 | add_dir_edge(a, b, cost);
| ~~~~~~~~~~~~
a.cc:55:21: error: expected constructor, destructor, or type conversion before '(' token
55 | add_dir_edge(b, a, cost);
| ^
a.cc:56:5: error: expected declaration before '}' token
56 | }
| ^
a.cc:59:12: error: 'T' was not declared in this scope
59 | vector<T> shortest_path(int s) {
| ^
a.cc:59:13: error: template argument 1 is invalid
59 | vector<T> shortest_path(int s) {
| ^
a.cc:59:13: error: template argument 2 is invalid
a.cc: In function 'int shortest_path(int)':
a.cc:60:16: error: 'T' was not declared in this scope
60 | vector<T> d(m_V, INF);
| ^
a.cc:60:17: error: template argument 1 is invalid
60 | vector<T> d(m_V, INF);
| ^
a.cc:60:17: error: template argument 2 is invalid
a.cc:60:21: error: 'm_V' was not declared in this scope
60 | vector<T> d(m_V, INF);
| ^~~
a.cc:60:26: error: 'INF' was not declared in this scope
60 | vector<T> d(m_V, INF);
| ^~~
a.cc:60:29: error: expression list treated as compound expression in initializer [-fpermissive]
60 | vector<T> d(m_V, INF);
| ^
a.cc:63:24: error: 'P' was not declared in this scope
63 | priority_queue<P, vector<P>, greater<P> > que;
| ^
a.cc:63:35: error: template argument 2 is invalid
63 | priority_queue<P, vector<P>, greater<P> > que;
| ^
a.cc:63:49: error: template argument 1 is invalid
63 | priority_queue<P, vector<P>, greater<P> > que;
| ^
a.cc:63:49: error: template argument 2 is invalid
a.cc:63:49: error: template argument 3 is invalid
a.cc:64:10: error: invalid types 'int[int]' for array subscript
64 | d[s] = 0;
| ^
a.cc:65:13: error: request for member 'push' in 'que', which is of non-class type 'int'
65 | que.push(P(0, s));
| ^~~~
a.cc:67:20: error: request for member 'empty' in 'que', which is of non-class type 'int'
67 | while(!que.empty()) {
| ^~~~~
a.cc:68:14: error: expected ';' before 'p'
68 | P p = que.top();
| ^~
| ;
a.cc:69:17: error: request for member 'pop' in 'que', which is of non-class type 'int'
69 | que.pop();
| ^~~
a.cc:71:25: error: 'p' was not declared in this scope
71 | auto dist = p.first;
| ^
a.cc:74:20: error: 'm_G' was not declared in this scope
74 | REP(i, m_G[v].size()) {
| ^~~
a.cc:23:43: note: in definition of macro 'REP'
23 | #define REP(i,n) for(int i = 0; i < (int)(n); ++i)
| ^
a.cc:75:17: error: 'edge' was not declared in this scope
75 | edge e = m_G[v][i];
| ^~~~
a.cc:76:23: error: 'e' was not declared in this scope
76 | if (d[e.to] > d[v] + e.cost) {
| ^
a.cc:78:25: error: request for member 'push' in 'que', which is of non-class type 'int'
78 | que.push(P(d[e.to], e.to));
| ^~~~
a.cc: At global scope:
a.cc:96:1: error: expected unqualified-id before 'private'
96 | private:
| ^~~~~~~
a.cc:98:19: error: 'edge' was not declared in this scope
98 | vector<vector<edge> > m_G;
| ^~~~
a.cc:98:23: error: template argument 1 is invalid
98 | vector<vector<edge> > m_G;
| ^
a.cc:98:23: error: template argument 2 is invalid
a.cc:98:25: error: template argument 1 is invalid
98 | vector<vector<edge> > m_G;
| ^
a.cc:98:25: error: template argument 2 is invalid
a.cc:99:1: error: expected declaration before '}' token
99 | };
| ^
a.cc: In function 'int main()':
a.cc:112:13: error: 'class Dijkstra<int>' has no member named 'add_undir_edge'
112 | dij.add_undir_edge(a, b, c);
| ^~~~~~~~~~~~~~
a.cc:115:24: error: 'class Dijkstra<int>' has no member named 'shortest_path'
115 | auto res = dij.shortest_path(n);
| ^~~~~~~~~~~~~
|
s514918053 | p03837 | C++ | #include "bits/stdc++.h"
using namespace std;
//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
using Weight = int;
class Edge {
public:
int s; //source
int d; //destination
Weight w; //weight
Edge(int s = 0, int d = 0, Weight w = INF) : s(s), d(d), w(w) {};
bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;
//辺の挿入
//G[s].emplace_back(s, d, w);
//G[d].emplace_back(d, s, w); 無向木は更に
enum { WHITE, GRAY, BLACK };
//未探索, 探索中, 探索済
//単一始点最短路(負閉路なし) Single Source Shortest Path
//Dijkstra O((E+V)logV)
//dist: 始点から各頂点までの最短距離 distance
//戻り値: 最短路木の親頂点(根は-1)
vector<int> dijkstra(const Graph &g, int s, vector<Weight> &dist) {
using State = tuple<Weight, int, int>; //始点からの最小コスト 子 親
priority_queue<State, vector<State>, greater<State>> PQ;
int n = g.size();
vector<int> color(n, WHITE);
vector<int> prev(n, -1);
dist.assign(n, INF);
dist[s] = 0; PQ.emplace(0, s, -1); color[s] = GRAY; //始点
while (PQ.size()) {
Weight d; int v, u;
tie(d, v, u) = PQ.top(); PQ.pop(); //distが最小となるStateを取り出し
if (dist[v] < d)continue; //すでに最短でなければ無視
color[v] = BLACK;
prev[v] = u;
for (auto &e : g[v]) { //隣接する頂点が存在する限り
if (color[e.d] == BLACK)continue; //探索済は無視
if (dist[e.d] > dist[v] + e.w) {
dist[e.d] = dist[v] + e.w;
PQ.emplace(dist[e.d], e.d, v);
color[e.d] = GRAY;
}
}
}
return prev;
}
//単一始点最短路(負閉路あり) Single Source Shortest Path
//Bellman Ford O(VE)
//dist: 始点から各頂点までの最短距離
//戻り値: 最短路木の親頂点, 負閉路なし:true あり:false
pair<vector<Weight>, bool> bellman_ford(const Graph &g, int s, vector<Weight> &dist) {
int n = g.size();
vector<int> prev(n, -1);
Edges es; for (int i = 0; i < n; i++) for (auto &e : g[i]) es.emplace_back(e);
dist.assign(n, INF); dist[s] = 0;
bool negative_cycle = false;
for (int i = 0;; i++) {
bool update = false;
for (auto &e : es) {
if (dist[e.s] != INF && dist[e.d] > dist[e.s] + e.w) {
dist[e.d] = dist[e.s] + e.w;
prev[e.d] = e.s;
update = true;
}
}
if (!update) break;
if (i > n) { negative_cycle = true; break; }
}
return make_pair(prev, !negative_cycle);
}
//始点から終点までの経路を取得
//終点から親を再帰的に辿り始点に着くまでの経路を反転している
//存在しない場合の戻り値: vector<int>()
vector<int> get_path(int s, int d, vector<int> prev) {
vector<int> path;
path.emplace_back(d);
for (int i = d; i != s; ) {
if (i == -1)return vector<int>();
path.emplace_back(i = prev[i]);
}
reverse(path.begin(), path.end());
return path;
}
vector<vector<vector<int>>> warshall_floyd(const Graph &g, Matrix &dist) {
int n = g.size();
dist.assign(n, Array(n, INF));
vector<vector<vector<int>>> prev(n, vector<vector<int>>(n, vector<int>()));
for (int i = 0; i < n; i++) dist[i][i] = 0;
for (int i = 0; i < n; i++)
for (auto e : g[i]) {
if (chmin(dist[e.s][e.d], e.w)) {
prev[e.s][e.d] = vector<int>{ e.d };
}
}
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
for (int k = 0; k < n; k++)
if (dist[j][i] != INF&&dist[i][k] != INF) {
if (chmin(dist[j][k], dist[j][i] + dist[i][k])) {
prev[j][k] = prev[j][i];
prev[j][k].insert(prev[j][k].begin(), all(prev[i][k]));
}
}
return prev;
}
//トポロジカルソート O(E+V)
//入次数が0の点と辺を取り除きながらretに突っ込む
vector<int> topological_sort(const Graph &g) {
int n = g.size(), k = 0;
vector<int> ord(n), indeg(n); //入次数
for (auto &es : g) for (auto &e : es) indeg[e.d]++;
queue<int> Q;
for (int i = 0; i < n; i++) if (indeg[i] == 0) Q.push(i);
while (!Q.empty()) {
int v = Q.front(); Q.pop(); ord[k++] = v;
for (auto &e : g[v]) if (--indeg[e.d] == 0) Q.push(e.d);
}
return *max_element(indeg.begin(), indeg.end()) == 0 ? ord : vector<int>();
}
//木の直径
Edge diameter(const Graph &g, int s = 0) {
vector<Weight> dist;
dijkstra(g, s, dist);
int n = g.size(), u = -1, v = -1;
for (int i = 0; i < n; i++) if (dist[i] != INF && (u == -1 || dist[i] > dist[u])) u = i;
dijkstra(g, u, dist);
for (int i = 0; i < n; i++) if (dist[i] != INF && (v == -1 || dist[i] > dist[v])) v = i;
Weight d = dist[v];
if (u > v) swap(u, v);
return Edge(u, v, d);
}
//#include "UnionFind.cpp"
////最小全域木
////Kruskal O(|E|log|E|)
//pair<Weight, Edges> kruskal(const Graph &g) {
// UnionFind UF(g.size());
// Edges es;
// for (int i = 0; i < g.size(); i++) for (auto &e : g[i]) es.emplace_back(e);
// sort(es.begin(), es.end());
// Weight total = 0;
// Edges T;
// for (auto &e : es) if (!UF.same(e.s, e.d)) {
// T.push_back(e); total += e.w; UF.unite(e.s, e.d);
// }
// return make_pair(total, T);
//}
//
////最小全域木
////Prim O(ElogV)
////rから到達可能な頂点が対象
////Edgeを bool operator<(const Edge &e)const { return w > e.w; } にする必要がある
//pair<Weight, Edges> prim(const Graph &g, int r = 0) {
// Edges T; Weight total = 0; vector<int> v(g.size());
// priority_queue <Edge> q;
// q.emplace(-1, r, 0);
// while (q.size()) {
// Edge e = q.top(); q.pop();
// if (v[e.d]) continue;
// v[e.d] = true;
// total += e.w; if (e.s != -1) T.emplace_back(e);
// for (auto &f : g[e.d]) if (!v[f.d]) q.emplace(f);
// }
// return make_pair(total, T);
//}
signed main() {
int N, M; cin >> N >> M;
Graph G(N);
rep(i, 0, M) {
int a, b, c; cin >> a >> b >> c; a--, b--;
G[a].emplace_back(a, b, c);
G[b].emplace_back(b, a, c);
}
Matrix dist;
auto prev = warshall_floyd(G, dist);
unordered_set<pair<int, int>> st;
rep(i, 0, N)rep(j, i + 1, N) {
prev[i][j].emplace_back(i);
rep(k, 1, prev[i][j].size()) {
int s = prev[i][j][k - 1], d = prev[i][j][k];
if (s > d)swap(s, d);
st.insert(make_pair(s, d));
}
}
cout << M - st.size() << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:201:39: error: use of deleted function 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
201 | unordered_set<pair<int, int>> st;
| ^~
In file included from /usr/include/c++/14/unordered_set:41,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:189,
from a.cc:1:
/usr/include/c++/14/bits/unordered_set.h:142:7: note: 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' is implicitly deleted because the default definition would be ill-formed:
142 | unordered_set() = default;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_set.h: At global scope:
/usr/include/c++/14/bits/unordered_set.h:142:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]'
In file included from /usr/include/c++/14/bits/unordered_map.h:33,
from /usr/include/c++/14/unordered_map:41,
from /usr/include/c++/14/functional:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' is implicitly deleted because the default definition would be ill-formed:
539 | _Hashtable() = default;
| ^~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]'
In file included from /usr/include/c++/14/bits/hashtable.h:35:
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' is implicitly deleted because the default definition would be ill-formed:
1731 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]'
/usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]':
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here
1328 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()'
1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
| ^~~~~
In file included from /usr/include/c++/14/string_view:50,
from /usr/include/c++/14/bits/basic_string.h:47,
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:
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()'
/usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]'
83 | __hash_enum(__hash_enum&&);
| ^~~~~~~~~~~
/usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
84 | ~__hash_enum();
| ^
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates
1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
| ^~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed:
1328 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed:
1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()'
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context
/usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
84 | ~__hash_enum();
| ^
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates
1731 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
/usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed:
1306 | struct _Hash_code_base
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates
539 | _Hashtable() = default;
| ^~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::equal_to<std::pair<int, int> >, |
s139632670 | p03838 | C++ | #include "atcoder/all"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>
const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;
using namespace std;
using namespace atcoder;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
if (a.first == b.first)
return a.second < b.second;
return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec) \
std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec) \
std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d) \
vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d) \
vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec) \
do { \
sort(ALL((vec))); \
(vec).erase(std::unique(ALL((vec))), (vec).end()); \
} while (0)
ll POW(ll n, ll m) {
if (m == 0) {
return 1;
} else if (m % 2 == 0) {
ll tmp = POW(n, m / 2);
return (tmp * tmp);
} else {
return (n * POW(n, m - 1));
}
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll X, Y;
cin >> X >> Y;
if (Y >= X)
cout << min(Y - X, abs(X + Y) + 1) << endl;
else
cout << min(X - Y + 2, abs(X + Y) + 1) << endl;
return 0;
}
| a.cc:1:10: fatal error: atcoder/all: No such file or directory
1 | #include "atcoder/all"
| ^~~~~~~~~~~~~
compilation terminated.
|
s647677434 | p03838 | C++ | include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using namespace std;
int main(){
ll x, y;
cin >> x >> y;
ll ans;
if (x <= y) ans = y - x;
else {
if (x*y != 0 && x/abs(x)*y/abs(y) > 0) ans = x - y + 2;
else ans = abs(-x-y) + 1;
}
cout << ans << endl;
return 0;
}
| a.cc:1:1: error: 'include' does not name a type
1 | include <bits/stdc++.h>
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:9: error: 'll' was not declared in this scope
7 | ll x, y;
| ^~
a.cc:8:9: error: 'cin' was not declared in this scope
8 | cin >> x >> y;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | include <bits/stdc++.h>
a.cc:8:16: error: 'x' was not declared in this scope
8 | cin >> x >> y;
| ^
a.cc:8:21: error: 'y' was not declared in this scope
8 | cin >> x >> y;
| ^
a.cc:9:11: error: expected ';' before 'ans'
9 | ll ans;
| ^~~~
| ;
a.cc:10:21: error: 'ans' was not declared in this scope
10 | if (x <= y) ans = y - x;
| ^~~
a.cc:12:35: error: 'abs' was not declared in this scope
12 | if (x*y != 0 && x/abs(x)*y/abs(y) > 0) ans = x - y + 2;
| ^~~
a.cc:12:56: error: 'ans' was not declared in this scope
12 | if (x*y != 0 && x/abs(x)*y/abs(y) > 0) ans = x - y + 2;
| ^~~
a.cc:13:22: error: 'ans' was not declared in this scope
13 | else ans = abs(-x-y) + 1;
| ^~~
a.cc:15:9: error: 'cout' was not declared in this scope
15 | cout << ans << endl;
| ^~~~
a.cc:15:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:17: error: 'ans' was not declared in this scope
15 | cout << ans << endl;
| ^~~
a.cc:15:24: error: 'endl' was not declared in this scope
15 | 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 | include <bits/stdc++.h>
|
s597238867 | p03838 | C | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int ghad(int a){
if(a < 0)
return a * -1;
return a;
}
int main() {
int a, b, f = 0;
cin >> a >> b;
while(a != b){
if(ghad(a) < ghad(b)){
a = ghad(a);
a++;
f++;
}
else if(ghad(a) > ghad(b)){
b = ghad(b);
b++;
f++;
}
else{
f++;
a *= -1;
}
}
cout << f;
}
| main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
1 | #include <bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s067025506 | p03838 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long y = sc.nextLong();
long count = 0;
if(x==0){
if(y>=0){
System.out.println(y);
return;
}else{
System.out.println(y+1);
return;
}
}
if(y==0){
if(x<=0){
System.out.println(Math.abs(x));
return;
}else{
System.out.println(Math.abs(x)+1)
return;
}
}
if(x*y>0){
if(y-x>0){
System.out.println(y-x);
}else{
System.out.println(x-y+2);
}
}else{
if(x<0){//x ga hu
if(Math.abs(x)<=Math.abs(y)){
System.out.println(Math.abs(y)-Math.abs(x)+1);
}else{
System.out.println(Math.abs(x)-Math.abs(y)+1);
}
}else{//y ga hu
if (Math.abs(x)>=Math.abs(y)) {
System.out.println(Math.abs(x)-Math.abs(y)+1);
}else{
System.out.println(Math.abs(y)-Math.abs(x)+1);
}
}
}
}
}
| Main.java:22: error: ';' expected
System.out.println(Math.abs(x)+1)
^
1 error
|
s571849538 | p03838 | C++ | #pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const ll INF=1e9+7;
int main(){
ll x,y;
cin >> x >> y;
if(x<=y){
if(x<0 && y>0 && abs(y)>=abs(x)){
cout << 1+y+x << endl;
}
else{
cout << y-x << endl;
}
else{
if(x>0 && y>=0){
cout << 1+x+y << endl;
}
else if(x>0 && y<0 && abs(x)>=abs(y)){
cout << 1+x+y << endl;
}
else if(x>0 && y<0 && abs(x)<abs(y)){
cout << 1-x-y << endl;
}
else if(x==0){
cout << 1-y << endl;
}
else{
cout << 2+x-y << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:35:5: error: expected '}' before 'else'
35 | else{
| ^~~~
a.cc:28:13: note: to match this '{'
28 | if(x<=y){
| ^
|
s836234854 | p03838 | C++ | #include <iostream>
using namespace std;
int main(){
int x, y;
cin >> x >> y;
if(x<y){
if(x<0 && 0<y){
if(-x<y){
cout << x+y+1 << endl;
}else if(-x>y){
cout << y-x << endl;
}else{
cout << 1 << endl;
}
}else{
cout << y-x << endl;
}
}else{
if(y<0 && 0<x){
if(-y<x){
cout << x+y+1 << endl;
}else if(-y>x){
cout << -y-x+1 << endl;
}else{
cout << 1 << endl;
}
}else{
if(x<0 && y<0){
cout << (-y)-(-x)+2 << endl;
}else{
cout << x+y+1 << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:35:4: error: expected '}' at end of input
35 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s606921974 | p03838 | C++ | //ABC_128_B// pair型の中にpair型
/*int main() {
int n;
cin >> n;
vector<pair<pair<string,int>,int>> a(n);
for(int i=0;i<n;i++){
string s;
cin >> s;
int num;
cin >> num;
num = num * -1;
a.at(i).first.first = s;
a.at(i).first.second = num;
a.at(i).second = i;
}
sort(a.begin(), a.end());
for(int i=0;i<n;i++){
cout << a.at(i).second +1 << endl;
}
}
*/
//ABC_058_Cのように
// s.at(j) == a のとき
//cout << s.at(j)-'0' - 49 << endl;
//とすると、「0」を出力してくれる。 →もっといいほかの方法はないの?
//全bit探索を入れよう!!
/*ABC_167_C skill up などを参考に…
//https://qiita.com/hareku/items/3d08511eab56a481c7db
int main() {
int n = 3;
// {0, 1, ..., n-1} の部分集合の全探索
for (int bit = 0; bit < (1<<n); ++bit) {
vector<int> S;
for (int i = 0; i < n; ++i) {
if (bit & (1<<i)) { // 列挙に i が含まれるか
S.push_back(i);
}
}
cout << bit << ": {";
for (int i = 0; i < (int)S.size(); ++i) {
cout << S[i] << " ";
}
cout << "}" << endl;
}
}
*/
//next_permutation(順列列挙)
/*https://note.com/memenekokaburi/n/nf0201d6002cd
ABC_150_Cなど。
int main() {
int n;
cin >> n ;
vector<int>array = {};
for(int i=0;i<n;i++){
array.push_back(i);
}
do{
for(int i=0; i<n; i++){
cout << array.at(i);
if(i!=n-1)cout<<" ";
}
cout<<endl;
}while(next_permutation(array.begin(),array.end()));
return 0;
}
*/
//ABC126_Cのように関数でdouble型で返ってきてほしい場合はdouble kan_halfのようにかく
/*
//ABC_041_C// pair型
int main() {
int n;
cin >> n;
vector<pair<int,int>>a(n);
for(int i=0;i<n;i++){
int num;
cin >> num;
a.at(i).first = num;
a.at(i).second = i;
}
sort(a.begin(), a.end());
reverse(a.begin(),a.end());
for(int i=0;i<n;i++){
cout << a.at(i).second + 1<< endl;
}
}
*/
/*ABC_068_C //boolの配列を使って
bool s[200050] = {};
bool t[200050] = {};
int main() {
ll n, m; cin >> n >> m;
for (int i = 0; i < m; i++){
ll a, b; cin >> a >> b;
if (a == 1) {
t[b] = true;
}
if (b == n) {
s[a] = true;
}
}
for (int i = 0; i < 200050; i++){
if (s[i] && t[i]) {
cout << "POSSIBLE" << endl;
return 0;
}
}
cout << "IMPOSSIBLE" << endl;
return 0;
}
*/
//int32 4 signed, signed int, int -2,147,483,648 ~ 2,147,483,647 = 2*10^9
//再帰関数 ABC_029_C
/*
void f(int rest , string s){
if(rest == 0){
cout << s << endl;
}
else{
for(char moji = 'a' ;moji <='c' ; moji++){
f(rest-1,s+moji);
}
}
}
int main() {
int n;
cin >> n;
f(n, "");
}
*/
//連想配列 ARC_081_Cの解答 //ABC073でも復習できます。
/*
int main() {
ll n;
cin >> n;
vector<ll>a(n);
rep(i,n) cin>>a.at(i);
map<ll,ll>mp;
rep(i,n){
mp[a.at(i)]++;
}
ll one = 0;
ll two = 0;
for(auto p:mp){
// cout << p.first << " " << p.second << endl;
if(p.second >= 2){
if(one <= p.first){
two = one;
one = p.first;
}
}
if(p.second >= 4){
if(one <= p.first){
two = p.first;
one = p.first;
}
}
}
// cout << one << endl;
// cout << two << endl;
// cout << endl;
cout << one * two << endl;
}
*/
//#define pi 3.14159265359
//桁数を指定して出力する方法
//#include <iomanip>//これをincludeしておかないといけない
//cout << fixed << setprecision(20)<< ans << endl;
// s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
// s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//getline(cin, s); //空白文字を含むものをまとめて入力できる。
//s配列に格納した単語を、辞書順にソートする
// sort(s.begin(), s.end());
// string t = "keyence";//で文字列を格納できる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
string s; cin >> s;
int n; cin >> n;
vector<int>a(n); vector<int>b(n);
rep(i,n) cin>>a.at(i)>>b.at(i);
rep(i,n)a.at(i)--; rep(i,n)b.at(i)--;
string t;
rep(i,n){
t = s;
for(int k=0;k<=b.at(i)-a.at(i);k++){
t.at(a.at(i)+k) = s.at(b.at(i)-k);
}
s = t;
}
cout << s << endl;
}
*///ABC018-B
// cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
// cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
/*01 02 03 12 13 23 と6回見ていくパターン
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
}
}
*/
//vector<vector<int>> a(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//10のi乗pow(10, i);//ただしdouble型のため注意
/*string s; stringでの文字列を数字型に変える方法
cin >> s;
rep(i,s.size()-2) {
int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
*/
#include <bits/stdc++.h>
#include <iomanip>//これをincludeしておかないといけない
using namespace std;
typedef long long ll;
typedef long double lld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265359
ll gcd(ll a, ll b){
if (a%b == 0){
return(b);
}
else{
return(gcd(b, a%b));
}
}
ll lcm(ll a, ll b){
// return a * b / gcd(a, b);
return a / gcd(a, b)* b;
}
int kan_hyaku(int n){
int kurai = 0;
for(int i=0;i<3;i++){
kurai = n%10;
n /=10;
}
return kurai;
}
int kan_ju(int n){
int kurai = 0;
for(int i=0;i<2;i++){
kurai = n%10;
n /=10;
}
return kurai;
}
int kan_ichi(int n){
int kurai = 0;
for(int i=0;i<1;i++){
kurai = n%10;
n /=10;
}
return kurai;
}
int keta(int n){
int wa = 1;
while(n>0){
wa *=10;
n--;
}
return wa;
}
double kan_half(int n){
double wa = 1;
while(n>0){
// cout << "TEST"<<endl;
wa *= 0.5;
// cout << wa << endl;
n--;
}
return wa;
}
ll facctorialMethod(ll k){
ll sum = 1;
for (ll i = 1; i <= k; ++i)
{
sum = sum%1000000007 * i%1000000007;
}
return sum;
}
int zorocheck(string s){
int count = 0;
rep(i,s.size()){
if(s.at(i) == s.at(0)) count++;
}
if(count ==s.size()){
return 1;
}
else{
return 0;
}
}
int sannobekijou(int n){
int wa = 1;
while(n>0){
n--;
wa *=3;
}
return wa;
}
/*
int n;
cin >> n;
vector<int>a(n);
rep(i,n) cin >> a.at(i);
*/
//cout << fixed << setprecision(10)<< ans << endl;
//数字から文字列に変換 a.at(0) = std::to_string(111);
bool red[100010] = {};
int main() {
ll x,y;
cin >> x >> y;
if(x == y){
cout << 0 << endl;
}
else if(x>=0 && y>=0){
if(x < y){
cout << y - x << endl;
}
else {
cout << x - y + 2 << endl;
}
}
else if(x >= 0 && y <= 0){
if(x == abs(y)){
cout << 1 << endl;
}
else if(x > abs(y)){
cout << x - abs(y) + 1 << endl;
}
else{
cout << abs(y) - x + 1 << endl;
}
}
else if(x =< 0 && y >= 0){
if( abs(x) == y){
cout << 1 << endl;
}
else if( abs(x) > y){
cout << abs(x) - y + 1 << endl;
}
else{
cout << y - abs(x) + 1 << endl;
}
}
else{
if(x < y){
cout << y - x << endl;
}
else{
cout << x - y + 2 << endl;
}
}
}
| a.cc: In function 'int main()':
a.cc:351:14: error: expected primary-expression before '<' token
351 | else if(x =< 0 && y >= 0){
| ^
|
s390891284 | p03838 | C++ | //ABC_128_B// pair型の中にpair型
/*int main() {
int n;
cin >> n;
vector<pair<pair<string,int>,int>> a(n);
for(int i=0;i<n;i++){
string s;
cin >> s;
int num;
cin >> num;
num = num * -1;
a.at(i).first.first = s;
a.at(i).first.second = num;
a.at(i).second = i;
}
sort(a.begin(), a.end());
for(int i=0;i<n;i++){
cout << a.at(i).second +1 << endl;
}
}
*/
//ABC_058_Cのように
// s.at(j) == a のとき
//cout << s.at(j)-'0' - 49 << endl;
//とすると、「0」を出力してくれる。 →もっといいほかの方法はないの?
//全bit探索を入れよう!!
/*ABC_167_C skill up などを参考に…
//https://qiita.com/hareku/items/3d08511eab56a481c7db
int main() {
int n = 3;
// {0, 1, ..., n-1} の部分集合の全探索
for (int bit = 0; bit < (1<<n); ++bit) {
vector<int> S;
for (int i = 0; i < n; ++i) {
if (bit & (1<<i)) { // 列挙に i が含まれるか
S.push_back(i);
}
}
cout << bit << ": {";
for (int i = 0; i < (int)S.size(); ++i) {
cout << S[i] << " ";
}
cout << "}" << endl;
}
}
*/
//next_permutation(順列列挙)
/*https://note.com/memenekokaburi/n/nf0201d6002cd
ABC_150_Cなど。
int main() {
int n;
cin >> n ;
vector<int>array = {};
for(int i=0;i<n;i++){
array.push_back(i);
}
do{
for(int i=0; i<n; i++){
cout << array.at(i);
if(i!=n-1)cout<<" ";
}
cout<<endl;
}while(next_permutation(array.begin(),array.end()));
return 0;
}
*/
//ABC126_Cのように関数でdouble型で返ってきてほしい場合はdouble kan_halfのようにかく
/*
//ABC_041_C// pair型
int main() {
int n;
cin >> n;
vector<pair<int,int>>a(n);
for(int i=0;i<n;i++){
int num;
cin >> num;
a.at(i).first = num;
a.at(i).second = i;
}
sort(a.begin(), a.end());
reverse(a.begin(),a.end());
for(int i=0;i<n;i++){
cout << a.at(i).second + 1<< endl;
}
}
*/
/*ABC_068_C //boolの配列を使って
bool s[200050] = {};
bool t[200050] = {};
int main() {
ll n, m; cin >> n >> m;
for (int i = 0; i < m; i++){
ll a, b; cin >> a >> b;
if (a == 1) {
t[b] = true;
}
if (b == n) {
s[a] = true;
}
}
for (int i = 0; i < 200050; i++){
if (s[i] && t[i]) {
cout << "POSSIBLE" << endl;
return 0;
}
}
cout << "IMPOSSIBLE" << endl;
return 0;
}
*/
//int32 4 signed, signed int, int -2,147,483,648 ~ 2,147,483,647 = 2*10^9
//再帰関数 ABC_029_C
/*
void f(int rest , string s){
if(rest == 0){
cout << s << endl;
}
else{
for(char moji = 'a' ;moji <='c' ; moji++){
f(rest-1,s+moji);
}
}
}
int main() {
int n;
cin >> n;
f(n, "");
}
*/
//連想配列 ARC_081_Cの解答 //ABC073でも復習できます。
/*
int main() {
ll n;
cin >> n;
vector<ll>a(n);
rep(i,n) cin>>a.at(i);
map<ll,ll>mp;
rep(i,n){
mp[a.at(i)]++;
}
ll one = 0;
ll two = 0;
for(auto p:mp){
// cout << p.first << " " << p.second << endl;
if(p.second >= 2){
if(one <= p.first){
two = one;
one = p.first;
}
}
if(p.second >= 4){
if(one <= p.first){
two = p.first;
one = p.first;
}
}
}
// cout << one << endl;
// cout << two << endl;
// cout << endl;
cout << one * two << endl;
}
*/
//#define pi 3.14159265359
//桁数を指定して出力する方法
//#include <iomanip>//これをincludeしておかないといけない
//cout << fixed << setprecision(20)<< ans << endl;
// s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
// s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//getline(cin, s); //空白文字を含むものをまとめて入力できる。
//s配列に格納した単語を、辞書順にソートする
// sort(s.begin(), s.end());
// string t = "keyence";//で文字列を格納できる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
string s; cin >> s;
int n; cin >> n;
vector<int>a(n); vector<int>b(n);
rep(i,n) cin>>a.at(i)>>b.at(i);
rep(i,n)a.at(i)--; rep(i,n)b.at(i)--;
string t;
rep(i,n){
t = s;
for(int k=0;k<=b.at(i)-a.at(i);k++){
t.at(a.at(i)+k) = s.at(b.at(i)-k);
}
s = t;
}
cout << s << endl;
}
*///ABC018-B
// cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
// cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
/*01 02 03 12 13 23 と6回見ていくパターン
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
}
}
*/
//vector<vector<int>> a(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//10のi乗pow(10, i);//ただしdouble型のため注意
/*string s; stringでの文字列を数字型に変える方法
cin >> s;
rep(i,s.size()-2) {
int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
*/
#include <bits/stdc++.h>
#include <iomanip>//これをincludeしておかないといけない
using namespace std;
typedef long long ll;
typedef long double lld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265359
ll gcd(ll a, ll b){
if (a%b == 0){
return(b);
}
else{
return(gcd(b, a%b));
}
}
ll lcm(ll a, ll b){
// return a * b / gcd(a, b);
return a / gcd(a, b)* b;
}
int kan_hyaku(int n){
int kurai = 0;
for(int i=0;i<3;i++){
kurai = n%10;
n /=10;
}
return kurai;
}
int kan_ju(int n){
int kurai = 0;
for(int i=0;i<2;i++){
kurai = n%10;
n /=10;
}
return kurai;
}
int kan_ichi(int n){
int kurai = 0;
for(int i=0;i<1;i++){
kurai = n%10;
n /=10;
}
return kurai;
}
int keta(int n){
int wa = 1;
while(n>0){
wa *=10;
n--;
}
return wa;
}
double kan_half(int n){
double wa = 1;
while(n>0){
// cout << "TEST"<<endl;
wa *= 0.5;
// cout << wa << endl;
n--;
}
return wa;
}
ll facctorialMethod(ll k){
ll sum = 1;
for (ll i = 1; i <= k; ++i)
{
sum = sum%1000000007 * i%1000000007;
}
return sum;
}
int zorocheck(string s){
int count = 0;
rep(i,s.size()){
if(s.at(i) == s.at(0)) count++;
}
if(count ==s.size()){
return 1;
}
else{
return 0;
}
}
int sannobekijou(int n){
int wa = 1;
while(n>0){
n--;
wa *=3;
}
return wa;
}
/*
int n;
cin >> n;
vector<int>a(n);
rep(i,n) cin >> a.at(i);
*/
//cout << fixed << setprecision(10)<< ans << endl;
//数字から文字列に変換 a.at(0) = std::to_string(111);
bool red[100010] = {};
int main() {
ll x,y;
cin >> x >> y;
if(x == y){
cout << 0 << endl;
}
else if(x>=0 && y>=0){
if(x < y){
cout << y - x << endl;
}
else {
cout << x - y + 2 << endl;
}
}
else if(x >= 0 && y =< 0){
if(x == abs(y)){
cout << 1 << endl;
}
else if(x > abs(y)){
cout << x - abs(y) + 1 << endl;
}
else{
cout << abs(y) - x + 1 << endl;
}
}
else if(x =< 0 && y >= 0){
if( abs(x) == y){
cout << 1 << endl;
}
else if( abs(x) > y){
cout << abs(x) - y + 1 << endl;
}
else{
cout << y - abs(x) + 1 << endl;
}
}
else{
if(x < y){
cout << y - x << endl;
}
else{
cout << x - y + 2 << endl;
}
}
}
| a.cc: In function 'int main()':
a.cc:340:24: error: expected primary-expression before '<' token
340 | else if(x >= 0 && y =< 0){
| ^
a.cc:351:14: error: expected primary-expression before '<' token
351 | else if(x =< 0 && y >= 0){
| ^
|
s266274996 | p03838 | C++ | #include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
int main(){
ll x,y;
in(x,y);
ll ans=0;
if(y==0){
if(x>0){
ans=x+1;
}else{
ans=-x;
}
}else if(abs(y)>=abs(x)){
if(x>=0&&y>=0){
ans=y-x;
}
if(x<0&&y>=0){
ans=y+x+1;
}
if(x>=0&&y<0){
ans=-y-x+1;
}
if(x<0&&y<0){
ans=-y+x+2;
}
if(x==0&&y>0)ans=y;
if(x==0&&y<0)ans=-y+1;
}else{
if(x>=0&&y>=0){
ans=x+y+1;
}
if(x<0&&y>=0){
ans=y-x;
}
if(x>=0&&y<0){
ans=x+y+1;
}
if(x<0&&y<0){
ans=y-x;
}
if(x==0&&y>0)ans=y;
if(x==0&&y<0)ans=-y+1;
}
out(ans);
} | a.cc:47:11: error: redefinition of 'const int MOD'
47 | const int MOD=1000000007;
| ^~~
a.cc:12:11: note: 'const int MOD' previously defined here
12 | const int MOD=1000000007;
| ^~~
a.cc:49:6: error: redefinition of 'void scan(int&)'
49 | void scan(int& a){scanf("%d",&a);}
| ^~~~
a.cc:14:6: note: 'void scan(int&)' previously defined here
14 | void scan(int& a){scanf("%d",&a);}
| ^~~~
a.cc:50:6: error: redefinition of 'void scan(long long int&)'
50 | void scan(long long& a){scanf("%lld",&a);}
| ^~~~
a.cc:15:6: note: 'void scan(long long int&)' previously defined here
15 | void scan(long long& a){scanf("%lld",&a);}
| ^~~~
a.cc:51:24: error: redefinition of 'template<class T> void scan(T&)'
51 | template<class T> void scan(T& a){cin>>a;}
| ^~~~
a.cc:16:24: note: 'template<class T> void scan(T&)' previously declared here
16 | template<class T> void scan(T& a){cin>>a;}
| ^~~~
a.cc:52:24: error: redefinition of 'template<class T> void scan(std::vector<_Tp>&)'
52 | template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
| ^~~~
a.cc:17:24: note: 'template<class T> void scan(std::vector<_Tp>&)' previously declared here
17 | template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
| ^~~~
a.cc:53:6: error: redefinition of 'void in()'
53 | void in(){}
| ^~
a.cc:18:6: note: 'void in()' previously defined here
18 | void in(){}
| ^~
a.cc:54:43: error: redefinition of 'template<class Head, class ... Tail> void in(Head&, Tail& ...)'
54 | template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
| ^~
a.cc:19:43: note: 'template<class Head, class ... Tail> void in(Head&, Tail& ...)' previously declared here
19 | template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
| ^~
a.cc:56:6: error: redefinition of 'void print(const int&)'
56 | void print(const int& a){printf("%d",a);}
| ^~~~~
a.cc:21:6: note: 'void print(const int&)' previously defined here
21 | void print(const int& a){printf("%d",a);}
| ^~~~~
a.cc:57:6: error: redefinition of 'void print(const long long int&)'
57 | void print(const long long& a){printf("%lld",a);}
| ^~~~~
a.cc:22:6: note: 'void print(const long long int&)' previously defined here
22 | void print(const long long& a){printf("%lld",a);}
| ^~~~~
a.cc:58:6: error: redefinition of 'void print(const double&)'
58 | void print(const double& a){printf("%.15lf",a);}
| ^~~~~
a.cc:23:6: note: 'void print(const double&)' previously defined here
23 | void print(const double& a){printf("%.15lf",a);}
| ^~~~~
a.cc:59:24: error: redefinition of 'template<class T> void print(const T&)'
59 | template<class T> void print(const T& a){cout<<a;}
| ^~~~~
a.cc:24:24: note: 'template<class T> void print(const T&)' previously declared here
24 | template<class T> void print(const T& a){cout<<a;}
| ^~~~~
a.cc:60:24: error: redefinition of 'template<class T> void print(const std::vector<_Tp>&)'
60 | template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
| ^~~~~
a.cc:25:24: note: 'template<class T> void print(const std::vector<_Tp>&)' previously declared here
25 | template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
| ^~~~~
a.cc:61:6: error: redefinition of 'void out()'
61 | void out(){putchar('\n');}
| ^~~
a.cc:26:6: note: 'void out()' previously defined here
26 | void out(){putchar('\n');}
| ^~~
a.cc:62:24: error: redefinition of 'template<class T> void out(const T&)'
62 | template<class T> void out(const T& t){print(t);putchar('\n');}
| ^~~
a.cc:27:24: note: 'template<class T> void out(const T&)' previously declared here
27 | template<class T> void out(const T& t){print(t);putchar('\n');}
| ^~~
a.cc:63:43: error: redefinition of 'template<class Head, class ... Tail> void out(const Head&, const Tail& ...)'
63 | template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
| ^~~
a.cc:28:43: note: 'template<class Head, class ... Tail> void out(const Head&, const Tail& ...)' previously declared here
28 | template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
| ^~~
a.cc:65:24: error: redefinition of 'template<class T> void dprint(const T&)'
65 | template<class T> void dprint(const T& a){cerr<<a;}
| ^~~~~~
a.cc:30:24: note: 'template<class T> void dprint(const T&)' previously declared here
30 | template<class T> void dprint(const T& a){cerr<<a;}
| ^~~~~~
a.cc:66:24: error: redefinition of 'template<class T> void dprint(const std::vector<_Tp>&)'
66 | template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
| ^~~~~~
a.cc:31:24: note: 'template<class T> void dprint(const std::vector<_Tp>&)' previously declared here
31 | template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
| ^~~~~~
a.cc:67:6: error: redefinition of 'void debug()'
67 | void debug(){cerr<<endl;}
| ^~~~~
a.cc:32:6: note: 'void debug()' previously defined here
32 | void debug(){cerr<<endl;}
| ^~~~~
a.cc:68:24: error: redefinition of 'template<class T> void debug(const T&)'
68 | template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
| ^~~~~
a.cc:33:24: note: 'template<class T> void debug(const T&)' previously declared here
33 | template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
| ^~~~~
a.cc:69:43: error: redefinition of 'template<class Head, class ... Tail> void debug(const Head&, const Tail& ...)'
69 | template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
| ^~~~~
a.cc:34:43: note: 'template<class Head, class ... Tail> void debug(const Head&, const Tail& ...)' previously declared here
34 | template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
| ^~~~~
|
s286782381 | p03838 | C++ | #include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<utility>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>
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; }
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
ll gcd(int a, int b){return b ? gcd(b, a%b) : a;}
ll lcm(int a, int b){return a*b / gcd(a, b);}
const ll MAX = 1e9+7;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main(){
ll x, y;
cin >> x >> y;
if(x <= y){
cout << y-x << endl;
}
else if(y == -x){
cout << 1 << endl;
}
else{
if(y >= 0 || x <= 0){
cout << abs(y-x) + 2 << endl;
}
else{
cout << -y-x + 1 << endl;
}
}
return 0;
}
}
| a.cc:48:1: error: expected declaration before '}' token
48 | }
| ^
|
s500124002 | p03838 | C++ | #pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll a,b;
cin >> a >> b;
ll ans = 0;
if(a == 0){
if(b > 0)
ans += b;
if(b < 0) {
ans++;
ans += b;
}
else{
ans += (1 + a);
}
}
else if(a > 0){
if(b == 0){
ans += b + 1;
}
else if(a > b && b > 0){
ans += 2 + (a - b);
}
else if(abs(a) >= abs(b) && b < 0){
ans++;
ans += (a - abs(b));
}
else if(a < b && b > 0){
ans += (b - a);
}
else if(abs(a) =< abs(b) && b < 0){
ans += (abs(b) - a);
ans++;
}
}
else{
if(abs(a) =< b){
ans++;
ans +=(b - a);
}
if(abs(a) >= b && b > 0){
ans +=(b - abs(a));
ans += 1;
}
if(a < b && b < 0){
ans +=(abs(a) - abs(b));
}
if(a > b && b < 0){
ans += 2;
ans += (abs(b) - abs(a));
}
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:42:21: error: expected primary-expression before '<' token
42 | else if(abs(a) =< abs(b) && b < 0){
| ^
a.cc:48:16: error: expected primary-expression before '<' token
48 | if(abs(a) =< b){
| ^
|
s121948539 | p03838 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl
const int INF = 1e9+7;
const ll INFL = 9*1e18;
// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };
const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}
// TODO: write
int main() {
int x,y;cin>>x>>y;
if(x >= 0 && y >= 0){
if(x < y)print(y-x);
else print(x-y+2);
}else if(x > 0){
if(x < abs(y))print(abs(y)-x+1);
else print(abs(y)-x+1);
}else if(y > 0){
if(abs(x) < y)print(y-abs(x)+1);
else
}else if(x < 0 && y < 0){
if(abs(x) < abs(y))print(abs(y-x)+2);
else print(abs(y-x));
}
return 0;
} | a.cc: In function 'int main()':
a.cc:64:3: error: expected primary-expression before '}' token
64 | }else if(x < 0 && y < 0){
| ^
|
s107803914 | p03838 | C++ | int main()
{
long int x,y,z,a;
cin>>x>>y;
if(x>=0&&y>=0)
{
if(x>y)
{
z=x-y+2;
if(y==0){cout<<x-y+1;}else{cout<<z;}
}
else{
z=y-x;
cout<<z;
}
}
else if (x>=0&&y<=0){
z=-x-y+1;
a=x+y+1;
if(x>=-y){cout<<a;}
else{cout<<z;}
}
else if(x<=0&&y>=0){if (y>=-x){cout<<x+y+1;}else{cout<<y-x;}}
else if(x<=0&&y<=0){if(x>y)
{
z=x-y+2;
cout<<z;
}
else{
z=y-x;
cout<<z;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
4 | cin>>x>>y;
| ^~~
a.cc:12:19: error: 'cout' was not declared in this scope
12 | if(y==0){cout<<x-y+1;}else{cout<<z;}
| ^~~~
a.cc:12:37: error: 'cout' was not declared in this scope
12 | if(y==0){cout<<x-y+1;}else{cout<<z;}
| ^~~~
a.cc:16:9: error: 'cout' was not declared in this scope
16 | cout<<z;
| ^~~~
a.cc:25:19: error: 'cout' was not declared in this scope
25 | if(x>=-y){cout<<a;}
| ^~~~
a.cc:26:14: error: 'cout' was not declared in this scope
26 | else{cout<<z;}
| ^~~~
a.cc:29:34: error: 'cout' was not declared in this scope
29 | else if(x<=0&&y>=0){if (y>=-x){cout<<x+y+1;}else{cout<<y-x;}}
| ^~~~
a.cc:29:52: error: 'cout' was not declared in this scope
29 | else if(x<=0&&y>=0){if (y>=-x){cout<<x+y+1;}else{cout<<y-x;}}
| ^~~~
a.cc:33:10: error: 'cout' was not declared in this scope
33 | cout<<z;
| ^~~~
a.cc:37:9: error: 'cout' was not declared in this scope
37 | cout<<z;
| ^~~~
|
s115252950 | p03838 | C++ | include <iostream>
using namespace std;
int main()
{
double x,y,z,a;
cin>>x>>y;
if(x>0&&y>0)
{ if(x>y)
{
z=x+y+1;
cout<<z;
}
else{
z=y-x;
cout<<z;
}
}
else if (x>0&&y<0){
z=-x-y+1;
a=x+y+1;
if(x>-y){cout<<a;}
else{cout<<z;}
}
else if(x<0&&y>0){if (y>-x){cout<<x+y+1;}else{cout<<y-x;}}
else if(x<0&&y<0){if(x>y)
{
z=x-y+2;
cout<<z;
}
else{
z=y-x;
cout<<z;
}
}
return 0;
}
| a.cc:1:1: error: 'include' does not name a type
1 | include <iostream>
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope
8 | cin>>x>>y;
| ^~~
a.cc:13:10: error: 'cout' was not declared in this scope
13 | cout<<z;
| ^~~~
a.cc:17:9: error: 'cout' was not declared in this scope
17 | cout<<z;
| ^~~~
a.cc:26:18: error: 'cout' was not declared in this scope
26 | if(x>-y){cout<<a;}
| ^~~~
a.cc:27:14: error: 'cout' was not declared in this scope
27 | else{cout<<z;}
| ^~~~
a.cc:30:31: error: 'cout' was not declared in this scope
30 | else if(x<0&&y>0){if (y>-x){cout<<x+y+1;}else{cout<<y-x;}}
| ^~~~
a.cc:30:49: error: 'cout' was not declared in this scope
30 | else if(x<0&&y>0){if (y>-x){cout<<x+y+1;}else{cout<<y-x;}}
| ^~~~
a.cc:34:10: error: 'cout' was not declared in this scope
34 | cout<<z;
| ^~~~
a.cc:38:9: error: 'cout' was not declared in this scope
38 | cout<<z;
| ^~~~
|
s509547417 | p03838 | C++ | #include <iostream>
using namespace std;
int main()
{
double x,y,z,a,b,c;
cin>>x>>y;
if(x>0&&y>0)
{ if(x>y)
{
z=x+y+1;
cout<<z;
}
else{
z=y-x;
cout<<z;
}
}
else if (x>0&&y<0){
z=-x-y+1;
a=x+y+1;
if(x>-y){cout<<a;}
else{cout<<z;}
}
else if(x<0&&y>0){if (y>-x){cout<<x+y+1;}else{cout<<y-x;}}
else if(x<0&&y<0){if(x>y)
{
z=x-y+2;
cout<<z;
}
else{
z=y-x;
cout<<z;
}
}
return 0; | a.cc: In function 'int main()':
a.cc:42:14: error: expected '}' at end of input
42 | return 0;
| ^
a.cc:6:1: note: to match this '{'
6 | {
| ^
|
s608604380 | p03838 | C++ | using System;
namespace kekW
{
internal static class Program
{
private static void Main()
{
var nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var x = nbrs[0];
var y = nbrs[1];
int res = 0;
if(x < y)
{
if(x < 0 && y < 0 || x > 0 && y > 0)
{
res = y - x;
}
else if(x < 0 && y > 0)
{
res = 1 + y - Math.Abs(x);
}
}
else
{
if(x > 0 && y < 0)
{
res = Math.Abs(x + y) + 1;
}
else if(x > 0 && y > 0)
{
res = 2 + x - y;
}
else if(x < 0 && y < 0)
{
res = y - x;
}
}
Console.WriteLine(res);
}
}
}
| a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:5:5: error: 'internal' does not name a type
5 | internal static class Program
| ^~~~~~~~
|
s477434119 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG
signed main() {
int x, y; cin >> x >> y;
if(x < y) {
if(x < 0 && y > 0) cout << min(y-x, y+x+1) << endl;
else cout << y-x << endl;
else {
if(x < 0) cout << x-y+2 << endl;
else if(x == 0) cout << -y+1 << endl;
else if(y >= 0) cout << x+y+1 << endl;
else cout << abs(x+y)+1 << endl;
}
} | a.cc: In function 'int main()':
a.cc:16:3: error: expected '}' before 'else'
16 | else {
| ^~~~
a.cc:13:13: note: to match this '{'
13 | if(x < y) {
| ^
|
s220325512 | p03838 | Java |
import java.util.*;
import java.io.*;
public class {
public static void main(String[] args) {
FastScanner fs = new FastScanner();
int x = fs.nextInt();
int y = fs.nextInt();
int absx = Math.abs(x);
int absy = Math.abs(y);
if(absx > absy){
if(x > 0 && y>0){
System.out.println(absx-absy+2);
}else if (x > 0 && y <= 0){
System.out.println(absx-absy+1);
}else if(x < 0 && y>0){
System.out.println(absx-absy+1);
}else{
System.out.println(absx-absy);
}
}else if(absx < absy){
if(x >= 0 && y>0){
System.out.println(absy-absx);
}else if (x < 0 && y > 0){
System.out.println(absy-absx+1);
}else if(x > 0 && y < 0){
System.out.println(absy-absx+1);
}else{
System.out.println(absy-absx+2);
}
}else {
if(x!=y){
System.out.println(1);
}else{
System.out.println(0);
}
}
}
static class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
}else{
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while(isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while(true){
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
}else if(b == -1 || !isPrintableChar(b)){
return minus ? -n : n;
}else{
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() {
long nl = nextLong();
if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
return (int) nl;
}
public double nextDouble() { return Double.parseDouble(next());}
}
}
| Main.java:5: error: <identifier> expected
public class {
^
1 error
|
s071167148 | p03838 | Java | な | Main.java:1: error: reached end of file while parsing
?
^
1 error
|
s931945351 | p03838 | C++ | #include <iostream>
int iabs(int a)
{
if (a >= 0) return a;
else return -a;
}
int diffabs(a, b)
{
if (a >= b) return a - b;
else b - a;
}
int main()
{
int x, y;
cin >> x >> y;
int ans = diffabs(iabs(a), iabs(b));
if (((x >= 0 && y >= 0) || (x < 0 && y < 0)) && x > y)
ans += 2;
else if (x < 0 && y >= 0)
ans += 1;
else if (x >= 0 && x < 0)
ans += 1;
} | a.cc:9:13: error: 'a' was not declared in this scope
9 | int diffabs(a, b)
| ^
a.cc:9:16: error: 'b' was not declared in this scope
9 | int diffabs(a, b)
| ^
a.cc:9:17: error: expression list treated as compound expression in initializer [-fpermissive]
9 | int diffabs(a, b)
| ^
a.cc: In function 'int main()':
a.cc:18:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
18 | cin >> x >> y;
| ^~~
| 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:20:26: error: 'a' was not declared in this scope
20 | int ans = diffabs(iabs(a), iabs(b));
| ^
a.cc:20:35: error: 'b' was not declared in this scope
20 | int ans = diffabs(iabs(a), iabs(b));
| ^
a.cc:20:37: error: 'diffabs' cannot be used as a function
20 | int ans = diffabs(iabs(a), iabs(b));
| ^
|
s211186875 | p03838 | C++ | #include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463
using namespace std;
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}
//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}
ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }
ll x,y;
ll cal(int b1, int b2)
{
ll xx = (b1 ? -x : x);
ll yy = (b2 ? -y : y);
if(xx<=yy) return yy-xx+b1+b2;
else return INF;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> x >> y;
ll ans = cal(0,0);
ans = min(ans, cal(0,1));
ans = min(ans, cal(1,0));
ans = min(ans, cal(1,1));
cout << ans << endl;
return 0;
} | a.cc: In function 'long long int cal(int, int)':
a.cc:48:15: error: 'INF' was not declared in this scope
48 | else return INF;
| ^~~
|
s975092881 | p03838 | C++ | #include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2100000000
#define mod 1000000007
#define INF2 1000000000000000000
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
int x, y;
cin >> x >> y;
int ans = INF;
int d = abs(abs(x) - abs(y));
if(x + d == y) {
ans = min(ans, d);
}
if(-x + d == y) {
ans = min(ans, d + 1);
}
if(abs(-x + d) == y) {
ans = min(ans, d + 2);
}
if(x - d == y) {
ans = min(ans, d + 2)
};
if(-(x + d) == y) {
ans = min(ans, d + 1);
}
assert(ans < INF);
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:46:30: error: expected ';' before '}' token
46 | ans = min(ans, d + 2)
| ^
| ;
47 | };
| ~
|
s775076581 | p03838 | C++ | #include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <assert>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2100000000
#define mod 1000000007
#define INF2 1000000000000000000
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
int x, y;
cin >> x >> y;
int ans = INF;
int d = abs(abs(x) - abs(y));
if(x + d == y) {
ans = min(ans, d);
} else if(-x + d == y) {
ans = min(ans, d + 1);
} else if(abs(-x + d) == y) {
ans = min(ans, d + 2);
} else if(x - d == y) {
ans = min(ans, d + 2);
}
assert(ans < INF);
cout << ans << endl;
return 0;
}
| a.cc:15:10: fatal error: assert: No such file or directory
15 | #include <assert>
| ^~~~~~~~
compilation terminated.
|
s746874626 | p03838 | C++ | #include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long
int gcd(int a,int b){
return b ? gcd(b, a % b) : a;
}
int lcm(int a,int b){
return b / gcd(a,b) * a;
}
signed main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int x,y; cin >> x >> y;
if(y >= x && y >0 && x < 0 && abs(y)> abs(x)) cout << 1 + y + x << endl;
else if()
else if(y >= x) cout << y - x << endl;
else if(y >= 0) cout << 1 + y + x << endl;
else if(x >= 0 && abs(x) >= abs(y)) cout << 1 + abs(x) - abs(y) << endl;
else if(x >= 0) cout << abs(y) - abs(x) + 1 << endl;
else cout << 1 + abs(y) - abs(x) + 1 << endl;
} | a.cc: In function 'int main()':
a.cc:38:13: error: expected primary-expression before ')' token
38 | else if()
| ^
a.cc:39:5: error: expected primary-expression before 'else'
39 | else if(y >= x) cout << y - x << endl;
| ^~~~
|
s926382141 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a , b;
int main(){
migmig
ll ans = 1e18;
cin >> a >> b;
if(a <= b)ans = min(ans , b-a);
if(-a <= b)ans = min(ans ,b+a+1);
if(-a <= -b)ans = min(ans ,a-b+2);
if(a <= -b)ans = min(ans , -b-a+1);
cout << ans;
return(0);
} | a.cc: In function 'int main()':
a.cc:10:5: error: 'migmig' was not declared in this scope
10 | migmig
| ^~~~~~
a.cc:13:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
13 | if(a <= b)ans = min(ans , b-a);
| ^~~
| abs
a.cc:14:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
14 | if(-a <= b)ans = min(ans ,b+a+1);
| ^~~
| abs
a.cc:15:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
15 | if(-a <= -b)ans = min(ans ,a-b+2);
| ^~~
| abs
a.cc:16:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
16 | if(a <= -b)ans = min(ans , -b-a+1);
| ^~~
| abs
a.cc:17:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
17 | cout << ans;
| ^~~
| abs
|
s265492883 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int ,int > pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll maxn = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);
#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}
ll a , b;
ll s1(){
if(a<=b)
return(b - a);
return(1e18);
}
ll s2(){
ll boz = -a;
if(a <= b)
return(b - a + 1);
return(1e18);
}
ll s3(){
ll boz = -b;
if(-a <= boz)
return(boz +a a + 2);
return(1e18);
}
int main(){
migmig
cin >> a >> b;
ll ans = 1e18;
ans = min(ans , s1());
ans = min(ans , s2());
ans = min(ans , s3());
cout << ans;
return(0);
} | a.cc: In function 'll s3()':
a.cc:41:30: error: expected ')' before 'a'
41 | return(boz +a a + 2);
| ~ ^~
| )
|
s213801910 | p03838 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;
int main(){
ll x,y;
ci>>x>>y;
ll d=abs(y)-abs(x);
ll ans=0;
if(d>=0){
ans+=abs(d);
if(x<0)ans++;
if(y<0)ans++;
}
else {
ans+=abs(d);
if(x>0)ans++;
if(y>0)ans++;
}
cout <<ans <<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:51:5: error: 'ci' was not declared in this scope; did you mean 'co'?
51 | ci>>x>>y;
| ^~
| co
|
s486984299 | p03838 | C++ | #include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
int N;
vi bit;
Binary_indexed_tree(int n):N(n){
bit.resize(N+1,0);
}
void add(int x,int a){
for(x;x<=N;x+=(x&-x)) bit[x]+=a;
}
ll sum(int x){
ll ret=0;
for(x;x>0;x-=(x&-x)) ret+=bit[x];
return ret;
}
};
struct Union_Find{
ll N;
vi par;
vi siz;
Union_Find(int n):N(n){
par.resize(N);
siz.resize(N,1);
rep(i,0,N) par[i]=i;
}
ll root(ll X){
if(par[X]==X) return X;
return par[X]=root(par[X]);
}
bool same(ll X,ll Y){
return root(X)==root(Y);
}
void unite(ll X,ll Y){
X=root(X);
Y=root(Y);
if(X==Y) return;
par[X]=Y;
siz[Y]+=siz[X];
siz[X]=0;
}
ll size(ll X){
return siz[root(X)];
}
};
ll modpow(ll X,ll Y){
ll sum=X,cnt=1;
vi A;
while(cnt<=Y){
A.pb(sum);
sum*=sum;
sum%=MOD;
cnt*=2;
}
int M=A.size();
ll ret=1;
REP(i,1,M){
if(Y>=(1ll<<M-i)){
Y-=(1ll<<M-i);
ret*=A[M-i];
ret%=MOD;
}
}
return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n,ll r){
if(n<r||n<0||r<0) return 0;
return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
ll X,Y; cin>>X>>Y;
ll ans;
if(X<=Y) ans=Y-X;
else{
if(Y>=0){
X=-X;
ans=Y-X+1;
X=-X;
ans=std::min(ans,abs(X-Y)+2);
}
else{
if(X<0){
ans=-Y-X+1;
X=-X;
ans=std::min(ans,-Y-X+2);
}
else{
ans=abs(-Y-X)+1;
}
}
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:116:25: error: no matching function for call to 'min(long long int&, int)'
116 | ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
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:116:25: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
116 | ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
/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:116:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
116 | ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
|
s009398220 | p03838 | C++ | #include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
int N;
vi bit;
Binary_indexed_tree(int n):N(n){
bit.resize(N+1,0);
}
void add(int x,int a){
for(x;x<=N;x+=(x&-x)) bit[x]+=a;
}
ll sum(int x){
ll ret=0;
for(x;x>0;x-=(x&-x)) ret+=bit[x];
return ret;
}
};
struct Union_Find{
ll N;
vi par;
vi siz;
Union_Find(int n):N(n){
par.resize(N);
siz.resize(N,1);
rep(i,0,N) par[i]=i;
}
ll root(ll X){
if(par[X]==X) return X;
return par[X]=root(par[X]);
}
bool same(ll X,ll Y){
return root(X)==root(Y);
}
void unite(ll X,ll Y){
X=root(X);
Y=root(Y);
if(X==Y) return;
par[X]=Y;
siz[Y]+=siz[X];
siz[X]=0;
}
ll size(ll X){
return siz[root(X)];
}
};
ll modpow(ll X,ll Y){
ll sum=X,cnt=1;
vi A;
while(cnt<=Y){
A.pb(sum);
sum*=sum;
sum%=MOD;
cnt*=2;
}
int M=A.size();
ll ret=1;
REP(i,1,M){
if(Y>=(1ll<<M-i)){
Y-=(1ll<<M-i);
ret*=A[M-i];
ret%=MOD;
}
}
return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n,ll r){
if(n<r||n<0||r<0) return 0;
return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
ll X,Y; cin>>X>>Y;
ll ans;
if(X<=Y) ans=Y-X;
else{
if(Y>=0){
X=-X;
ans=Y-X+1;
X=-X;
ans=std::min(ans,abs(X-Y)+2);
}
else{
if(X<0){
ans=-Y-X+1;
X=-X;
ans=std::min(ans,-Y-X+2);
}
else{
ans=abs(-Y-X)+1;
}
}
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:116:25: error: no matching function for call to 'min(long long int&, int)'
116 | ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
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:116:25: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
116 | ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
/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:116:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
116 | ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
|
s568666287 | p03838 | C++ | #include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
int N;
vi bit;
Binary_indexed_tree(int n):N(n){
bit.resize(N+1,0);
}
void add(int x,int a){
for(x;x<=N;x+=(x&-x)) bit[x]+=a;
}
ll sum(int x){
ll ret=0;
for(x;x>0;x-=(x&-x)) ret+=bit[x];
return ret;
}
};
struct Union_Find{
ll N;
vi par;
vi siz;
Union_Find(int n):N(n){
par.resize(N);
siz.resize(N,1);
rep(i,0,N) par[i]=i;
}
ll root(ll X){
if(par[X]==X) return X;
return par[X]=root(par[X]);
}
bool same(ll X,ll Y){
return root(X)==root(Y);
}
void unite(ll X,ll Y){
X=root(X);
Y=root(Y);
if(X==Y) return;
par[X]=Y;
siz[Y]+=siz[X];
siz[X]=0;
}
ll size(ll X){
return siz[root(X)];
}
};
ll modpow(ll X,ll Y){
ll sum=X,cnt=1;
vi A;
while(cnt<=Y){
A.pb(sum);
sum*=sum;
sum%=MOD;
cnt*=2;
}
int M=A.size();
ll ret=1;
REP(i,1,M){
if(Y>=(1ll<<M-i)){
Y-=(1ll<<M-i);
ret*=A[M-i];
ret%=MOD;
}
}
return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n,ll r){
if(n<r||n<0||r<0) return 0;
return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
ll X,Y; cin>>X>>Y;
ll ans;
if(X<=Y) ans=Y-X;
else{
if(Y>=0){
X=-X;
ans=Y-X+1;
X=-X;
ans=std::min(ans,abs(X-Y)+2);
}
else{
if(X<0){
ans=-Y-X+1;
X=-X;
ans=std::min(ans,-Y-X+2);
}
else{
ans=abs(abs(-Y-X)+1);
}
}
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:116:25: error: no matching function for call to 'min(long long int&, int)'
116 | ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
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:116:25: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
116 | ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
/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:116:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
116 | ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
|
s329772338 | p03838 | C++ | #include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
int N;
vi bit;
Binary_indexed_tree(int n):N(n){
bit.resize(N+1,0);
}
void add(int x,int a){
for(x;x<=N;x+=(x&-x)) bit[x]+=a;
}
ll sum(int x){
ll ret=0;
for(x;x>0;x-=(x&-x)) ret+=bit[x];
return ret;
}
};
struct Union_Find{
ll N;
vi par;
vi siz;
Union_Find(int n):N(n){
par.resize(N);
siz.resize(N,1);
rep(i,0,N) par[i]=i;
}
ll root(ll X){
if(par[X]==X) return X;
return par[X]=root(par[X]);
}
bool same(ll X,ll Y){
return root(X)==root(Y);
}
void unite(ll X,ll Y){
X=root(X);
Y=root(Y);
if(X==Y) return;
par[X]=Y;
siz[Y]+=siz[X];
siz[X]=0;
}
ll size(ll X){
return siz[root(X)];
}
};
ll modpow(ll X,ll Y){
ll sum=X,cnt=1;
vi A;
while(cnt<=Y){
A.pb(sum);
sum*=sum;
sum%=MOD;
cnt*=2;
}
int M=A.size();
ll ret=1;
REP(i,1,M){
if(Y>=(1ll<<M-i)){
Y-=(1ll<<M-i);
ret*=A[M-i];
ret%=MOD;
}
}
return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n,ll r){
if(n<r||n<0||r<0) return 0;
return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
ll X,Y; cin>>X>>Y;
ll ans;
if(X<=Y) ans=Y-X;
else{
if(Y>=0){
X=-X;
ans=Y-X+1;
X=-X;
if(ans=std::min(ans,abs(X-Y)+2);
}
else{
if(X<0){
ans=-Y-X+1;
X=-X;
ans=std::min(ans,-Y-X+2);
}
else{
ans=abs(-Y-X+1);
}
}
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:116:28: error: no matching function for call to 'min(long long int&, int)'
116 | if(ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
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:116:28: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
116 | if(ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
/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:116:28: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
116 | if(ans=std::min(ans,abs(X-Y)+2);
| ~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:117:9: error: expected primary-expression before '}' token
117 | }
| ^
a.cc:116:45: error: expected ')' before '}' token
116 | if(ans=std::min(ans,abs(X-Y)+2);
| ~ ^
| )
117 | }
| ~
a.cc:117:9: error: expected primary-expression before '}' token
117 | }
| ^
|
s595948751 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
long long H,W; cin>>H>>W;
if(H==W){
cout<<0<<endl;}
else if(W==0){
if(H>0){
cout<<1+H;}
else
cout<<abs(H);
else if(H<W){
if(0<=H){
cout<<W-H<<endl;}
else if(W<0)
cout<<abs(abs(W)-abs(H));
else
cout<<1+abs(abs(H)-W);}
else{
if(W>=0){
cout<<2+H-W<<endl;}
else if(H<0){
cout<<2+abs(abs(W)-abs(H));}
else
cout<<1+abs(abs(W)-H);}}
| a.cc: In function 'int main()':
a.cc:12:1: error: expected '}' before 'else'
12 | else if(H<W){
| ^~~~
a.cc:7:14: note: to match this '{'
7 | else if(W==0){
| ^
|
s371725572 | p03838 | C++ |
#include <bits/stdc++.h>
using namespace std;
int _x;
int _y;
int _ans;
void CParseIn () {
cin >> _x >> _y;
}
void Core () {
if (_x / _y >= 0) {
_ans = abs(_x - _y);
return;
}
if (_x < 0 && _y > _abs(_x)) {
_ans = 1 + _y - _x;
return;
}
if (_x < 0 && _y <= _abs(_x)) {
_ans = _y - _x;
return;
}
if (_x > 0 && _y < -_x) {
_ans = 1 - _y - _x;
return;
}
_ans = 1 + _y + _x;
}
void CWriteOut () {
printf("%d\n", _ans);
}
int main () {
CParseIn();
Core();
CWriteOut();
return 0;
} | a.cc: In function 'void Core()':
a.cc:21:24: error: '_abs' was not declared in this scope; did you mean 'labs'?
21 | if (_x < 0 && _y > _abs(_x)) {
| ^~~~
| labs
a.cc:26:25: error: '_abs' was not declared in this scope; did you mean 'labs'?
26 | if (_x < 0 && _y <= _abs(_x)) {
| ^~~~
| labs
|
s735928891 | p03838 | C++ | #include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
distance(v.begin(), upper_bound(v.begin(), v.end(), x))
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;
ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
/* Macros reg. ends here */
const ll INF = 1LL << 50;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(15);
ll x, y;
cin >> x >> y;
ll cnt = 0;
if(y == 0){
if (x <= 0) cnt = y - x;
else {
cnt++;
x *= -1;
cnt += y - x;
}
} else if (y > 0) {
if (x <= -y) {
cnt += -y - x;
cnt++;
} else if (x < 0) {
cnt++;
x *= -1;
cnt += y - x;
} else if (x <= y) {
cnt += y - x;
} else {
cnt++;
x *= -1;
cnt += -y - x;
cnt++;
}
} else {
if (x <= y) {
cnt += y - x;
} else if (x < 0) {
x *= -1;
cnt++;
cnt += -y - x;
cnt++;
} else if (x <= -y) {
cnt += -y - x;
cnt++;
} else { // -y < x
cnt++;
x *= -1;
cnt += y - x;
}
}
cout << cnt << endl;
return 0;
}
g | a.cc:109:1: error: 'g' does not name a type
109 | g
| ^
|
s133881319 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
ll A, B;
cin >> A >> B;
ll ans;
if (A*B < 0) ans = abs(A+B)+1;
else {
if (A < B) ans = B-A;
else {
ans = A-B+2;
if (A*B == 0) ans -= 1;
}
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:5:3: error: 'll' was not declared in this scope
5 | ll A, B;
| ^~
a.cc:6:10: error: 'A' was not declared in this scope
6 | cin >> A >> B;
| ^
a.cc:6:15: error: 'B' was not declared in this scope
6 | cin >> A >> B;
| ^
a.cc:7:5: error: expected ';' before 'ans'
7 | ll ans;
| ^~~~
| ;
a.cc:8:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
8 | if (A*B < 0) ans = abs(A+B)+1;
| ^~~
| abs
a.cc:10:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
10 | if (A < B) ans = B-A;
| ^~~
| abs
a.cc:12:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
12 | ans = A-B+2;
| ^~~
| abs
a.cc:17:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
17 | cout << ans << endl;
| ^~~
| abs
|
s028026405 | p03838 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int ans=abs(abs(a)-abs(b));
if(a*b>){
if(a>b)ans+=2;
}
else ans++;
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:7:10: error: expected primary-expression before ')' token
7 | if(a*b>){
| ^
|
s742005959 | p03838 | C++ | int x, y;
cin >> x >> y;
int ans = abs(abs(x) - abs(y));
if (x < 0 && y < 0)
ans += 2;
if ((x < 0 && y>0) || (x > 0 && y < 0))
ans++;
if (x > 0 && y>0 && x>y)
ans += 2;
if (x == 0 && y < 0)
ans++;
cout << ans; | a.cc:2:9: error: 'cin' does not name a type
2 | cin >> x >> y;
| ^~~
a.cc:3:23: error: 'abs' was not declared in this scope; did you mean 'ans'?
3 | int ans = abs(abs(x) - abs(y));
| ^~~
| ans
a.cc:3:32: error: 'abs' was not declared in this scope; did you mean 'ans'?
3 | int ans = abs(abs(x) - abs(y));
| ^~~
| ans
a.cc:3:19: error: 'abs' was not declared in this scope; did you mean 'ans'?
3 | int ans = abs(abs(x) - abs(y));
| ^~~
| ans
a.cc:4:9: error: expected unqualified-id before 'if'
4 | if (x < 0 && y < 0)
| ^~
a.cc:6:9: error: expected unqualified-id before 'if'
6 | if ((x < 0 && y>0) || (x > 0 && y < 0))
| ^~
a.cc:8:9: error: expected unqualified-id before 'if'
8 | if (x > 0 && y>0 && x>y)
| ^~
a.cc:10:9: error: expected unqualified-id before 'if'
10 | if (x == 0 && y < 0)
| ^~
a.cc:12:9: error: 'cout' does not name a type
12 | cout << ans;
| ^~~~
|
s758881020 | p03838 | C++ | object DS_Grid1: TDataSource
DataSet = A_
Left = 338
Top = 172
end
| a.cc:1:1: error: 'object' does not name a type
1 | object DS_Grid1: TDataSource
| ^~~~~~
|
s898599799 | p03838 | C++ | using namespace std;
int main() {
int x,y;
cin >> x >> y;
if( ( 0<=x && x<y )||( x<y && y<=0 ))
cout << y-x << endl;
else if(x*y>0)
cout << x-y+2 << endl;
else
{if(x+y>0)
cout << x+y+1 << endl;
else
cout << 1-x-y << endl;
}
} | a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
5 | cin >> x >> y;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | using namespace std;
a.cc:7:5: error: 'cout' was not declared in this scope
7 | cout << y-x << endl;
| ^~~~
a.cc:7:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:7:20: error: 'endl' was not declared in this scope
7 | cout << y-x << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | using namespace std;
a.cc:9:5: error: 'cout' was not declared in this scope
9 | cout << x-y+2 << endl;
| ^~~~
a.cc:9:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:9:22: error: 'endl' was not declared in this scope
9 | cout << x-y+2 << endl;
| ^~~~
a.cc:9:22: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:12:5: error: 'cout' was not declared in this scope
12 | cout << x+y+1 << endl;
| ^~~~
a.cc:12:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:12:22: error: 'endl' was not declared in this scope
12 | cout << x+y+1 << endl;
| ^~~~
a.cc:12:22: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:14:5: error: 'cout' was not declared in this scope
14 | cout << 1-x-y << endl;
| ^~~~
a.cc:14:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:14:22: error: 'endl' was not declared in this scope
14 | cout << 1-x-y << endl;
| ^~~~
a.cc:14:22: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
|
s101794485 | p03838 | C++ | int main() {
int x,y;
cin >> x >> y;
cout << 1-x-y << endl;
} | a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
3 | cin >> x >> y;
| ^~~
a.cc:4:5: error: 'cout' was not declared in this scope
4 | cout << 1-x-y << endl;
| ^~~~
a.cc:4:22: error: 'endl' was not declared in this scope
4 | cout << 1-x-y << endl;
| ^~~~
|
s914279649 | p03838 | C++ | int main() {
int x,y;
cin >> x >> y;
cout << 1-x-y << endl;
} | a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
3 | cin >> x >> y;
| ^~~
a.cc:4:5: error: 'cout' was not declared in this scope
4 | cout << 1-x-y << endl;
| ^~~~
a.cc:4:22: error: 'endl' was not declared in this scope
4 | cout << 1-x-y << endl;
| ^~~~
|
s147402779 | p03838 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
struct Union{
vector<int> par;
Union(int a){
par=vector<int>(a,-1);
}
int find(int a){
if(par[a]<0){
return a;
}
else{
return par[a]=find(par[a]);
}
}
bool same(int a,int b){
return (find(a)==find(b));
}
int size(int a){
return -par[find(a)];
}
void unite(int a,int b){
int c=find(a),d=find(b);
if(c==d)
return;
if(size(c)<size(d)){
swap(c,d);
}
par[c]+=par[d];
par[d]=c;
}
};
int main(){
int x,y;
cin >> x >> y;
if(x>y&&y>0)cout << x-y+2;
else if(x>y&&y=0)cout << x+1;
else if(x<y&&x>0)cout << y-x;
else if(x<y&&x=0)cout << y;
else if(x>y&&x<0)cout << x-y+2;
else if(x<y&&y<0)cout << y-x;
else if(x<y)cout << abs(y)-abs(x)+1;
else cout << abs(x)-abs(y)+1;
}
| a.cc: In function 'int main()':
a.cc:43:14: error: lvalue required as left operand of assignment
43 | else if(x>y&&y=0)cout << x+1;
| ~~~^~~
a.cc:45:14: error: lvalue required as left operand of assignment
45 | else if(x<y&&x=0)cout << y;
| ~~~^~~
|
s042666500 | p03838 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
struct Union{
vector<int> par;
Union(int a){
par=vector<int>(a,-1);
}
int find(int a){
if(par[a]<0){
return a;
}
else{
return par[a]=find(par[a]);
}
}
bool same(int a,int b){
return (find(a)==find(b));
}
int size(int a){
return -par[find(a)];
}
void unite(int a,int b){
int c=find(a),d=find(b);
if(c==d)
return;
if(size(c)<size(d)){
swap(c,d);
}
par[c]+=par[d];
par[d]=c;
}
};
int main(){
int x,y;
cin >> x >> y;
else if(x>y&&y>0)cout << x-y+2;
else if(x<y&&x>0)cout << y-x;
else if(x>y&&x<0)cout << x-y+2;
else if(x<y&&y>0)cout << y-x;
else if(x<y)cout << y-x+1;
else cout << x-y+1;
} | a.cc: In function 'int main()':
a.cc:42:3: error: 'else' without a previous 'if'
42 | else if(x>y&&y>0)cout << x-y+2;
| ^~~~
|
s603531179 | p03838 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
long x,y;
cin >> x >> y;
if(y >= x) cout << y-x << endl;
else if(abs(y) <= abs(x)) cout << x+y+1 << endl;;
else if(abs(y) > abs(x) && x >= 0) cout << -x-y+1 << endl;
else cout << x-y+2 << endl;
}
| a.cc: In function 'int main()':
a.cc:9:3: error: 'else' without a previous 'if'
9 | else if(abs(y) > abs(x) && x >= 0) cout << -x-y+1 << endl;
| ^~~~
|
s188512873 | p03838 | C++ | #include<stdio.h>
#include<algorithm>
using namespace std;
int s(int x,int y){
if(x<=y) return y-x;
else return x-y+2;
}
int main(){
int x,y;
scanf("%d%d",&x,&y);
printf("%d\n",min(s(x,y),min(s(-x,y)+1,min(s(x,-y)+1,s(-x,-y)+2))));
return 0;
| a.cc: In function 'int main()':
a.cc:12:14: error: expected '}' at end of input
12 | return 0;
| ^
a.cc:8:11: note: to match this '{'
8 | int main(){
| ^
|
s489329279 | p03838 | C++ | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int x, y;
cin >> x >> y;
int ans;
if (x > 0) {
if (y <= -x) ans = -y - x + 1;
if (-x <= y && y <= 0) ans = x + y + 1;
if (0 < y && y < x) ans = x - y + 2;
if (x <= y) ans = y - x;
}
else if (x < 0) {
if (y < x) ans = x - y + 2;
if (x <= y && y <= 0) ans = y - x;
if (0 < y && y <= -x) ans = -x - y + 1;
if (-x < y) ans = x + y + 1;
}
else {
if (y >= 0) ans = y;
else ans = -y + 1
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:25:26: error: expected ';' before '}' token
25 | else ans = -y + 1
| ^
| ;
26 | }
| ~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.