Language: C++

#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};
 
struct UnionFind {
	vector<int> par;
 
	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }
 
	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}
 
	bool same(int x, int y) {
		return root(x) == root(y);
	}
 
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}
 
	int size(int x) {
		return -par[root(x)];
	}
};
 
int main(){
    ll n,m;
	cin>>n>>m;
	UnionFind tree(n);
	int x[M],y[M];
	//切るのは嫌なのでくっつけていく
	rep(i,0,m)cin>>x[i]>>y[i],x[i]--,y[i]--;
	ll cnt=n*(n-1)/2;
	vl ans;
	rep(i,0,m){
		ans.push_back(cnt);
		int a=x[m-1-i],b=y[m-1-i];
		if(tree.same(a,b))continue;
		ll sa=tree.size(a),sb=tree.size(b);
		cnt-=sa*sb;
		tree.merge(a,b);
	}
	reverse(ALL(ans));
	for(auto v:ans)print(v);
}
 
提出情報
提出日時	2019-08-04 12:07:19
問題	D - Decayed Bridges
ユーザ	Engelcat 
言語	C++14 (GCC 5.4.1)
得点	0
コード長	1492 Byte
結果	
実行時間	208 ms
メモリ	3444 KB
テストケース
セット名	得点 / 配点	テストケース
All
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};
 
struct UnionFind {
	vector<int> par;
 
	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }
 
	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}
 
	bool same(int x, int y) {
		return root(x) == root(y);
	}
 
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}
 
	int size(int x) {
		return -par[root(x)];
	}
};
 
int main(){
	int n,m;
	cin>>n>>m;
	UnionFind tree(n);
	int x[M],y[M];
	//切るのは嫌なのでくっつけていく
	rep(i,0,m)cin>>x[i]>>y[i],x[i]--,y[i]--;
	ll cnt=n*(n-1)/2;
	vl ans;
	rep(i,0,m){
		ans.push_back(cnt);
		int a=x[m-1-i],b=y[m-1-i];
		if(tree.same(a,b))continue;
		ll sa=tree.size(a),sb=tree.size(b);
		cnt-=sa*sb;
		tree.merge(a,b);
	}
	reverse(ALL(ans));
	for(auto v:ans)print(v);
}
 
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main(){
	 n,m;
	cin>>n>>m;
	UnionFind tree(n);
	int x[M],y[M];
	//切るのは嫌なのでくっつけていく
	rep(i,0,m)cin>>x[i]>>y[i],x[i]--,y[i]--;
	ll cnt=n*(n-1)/2;
	vl ans;
	rep(i,0,m){
		ans.push_back(cnt);
		int a=x[m-1-i],b=y[m-1-i];
		if(tree.same(a,b))continue;
		ll sa=tree.size(a),sb=tree.size(b);
		cnt-=sa*sb;
		tree.merge(a,b);
	}
	reverse(ALL(ans));
	for(auto v:ans)print(v);
}

提出情報
提出日時	2019-08-04 12:07:19
問題	D - Decayed Bridges
ユーザ	Engelcat 
言語	C++14 (GCC 5.4.1)
得点	0
コード長	1492 Byte
結果	
実行時間	208 ms
メモリ	3444 KB
テストケース
セット名	得点 / 配点	テストケース
All
提出情報
提出日時	2019-08-04 14:30:39
問題	D - Decayed Bridges
ユーザ	Engelcat 
言語	C++14 (GCC 5.4.1)
得点	0
コード長	3267 Byte
結果	
コンパイルエラー
./Main.cpp:137:1: error: stray ‘\346’ in program
 提出情報
 ^
./Main.cpp:137:1: error: stray ‘\217’ in program
./Main.cpp:137:1: error: stray ‘\220’ in program
./Main.cpp:137:1: error: stray ‘\345’ in program
./Main.cpp:137:1: error: stray ‘\207’ in program
./Main.cpp:137:1: error: stray ‘\272’ in program
./Main.cpp:137:1: error: stray ‘\346’ in program
./Main.cpp:137:1: error: stray ‘\203’ in program
./Main.cpp:137:1: error: stray ‘\205’ in program
./Main.cpp:137:1: error: stray ‘\345’ in program
./Main.cpp:137:1: error: stray ‘\240’ in program
./Main.cpp:137:1: error: stray ‘\261’ in program
./Main.cpp:138:1: error: stray ‘\346’ in program
 提出日時 2019-08-04 12:07:19
 ^
./Main.cpp:138:1: error: stray ‘\217’ in program
./Main.cpp:138:1: error: stray ‘\220’ in program
./Main.cpp:138:1: error: stray ‘\345’ in program
./Main.cpp:138:1: error: stray ‘\207’ in program
./Main.cpp:138:1: error: stray ‘\272’ in program
./Main.cpp:138:1: error: stray ‘\346’ in program
./Main.cpp:138:1: error: stray ‘\227’ in program
./Ma...
FacebookTwitterHatena共有
ルール 用語集
利用規約 プライバシーポリシー 個人情報保護方針 企業情報 よくある質問 お問い合わせ 資料請求
Copyright Since 2012 ©AtCoder Inc. All rights 

Compiler output:
a.cc:70:22: error: invalid digit "8" in octal constant
   70 | 提出日時        2019-08-04 12:07:19
      |                      ^~
a.cc:73:20: error: too many decimal points in number
   73 | 言語    C++14 (GCC 5.4.1)
      |                    ^~~~~
a.cc:219:22: error: invalid digit "8" in octal constant
  219 | 提出日時        2019-08-04 12:07:19
      |                      ^~
a.cc:222:20: error: too many decimal points in number
  222 | 言語    C++14 (GCC 5.4.1)
      |                    ^~~~~
a.cc:232:22: error: invalid digit "8" in octal constant
  232 | 提出日時        2019-08-04 14:30:39
      |                      ^~
a.cc:235:20: error: too many decimal points in number
  235 | 言語    C++14 (GCC 5.4.1)
      |                    ^~~~~
a.cc:240:32: error: extended character ‘ is not valid in an identifier
  240 | ./Main.cpp:137:1: error: stray ‘\346’ in program
      |                                ^
a.cc:240:33: error: stray '\' in program
  240 | ./Main.cpp:137:1: error: stray ‘\346’ in program
      |                                 ^
a.cc:240:34: error: extended character ’ is not valid in an identifier
  240 | ./Main.cpp:137:1: error: stray ‘\346’ in program
      |                                  ^
a.cc:243:32: error: extended character ‘ is not valid in an identifier
  243 | ./Main.cpp:137:1: error: stray ‘\217’ in program
      |                                ^
a.cc:243:33: error: stray '\' in program
  243 | ./Main.cpp:137:1: error: stray ‘\217’ in program
      |                                 ^
a.cc:243:34: error: extended character ’ is not valid in an identifier
  243 | ./Main.cpp:137:1: error: stray ‘\217’ in program
      |                                  ^
a.cc:244:32: error: extended character ‘ is not valid in an identifier
  244 | ./Main.cpp:137:1: error: stray ‘\220’ in program
      |                                ^
a.cc:244:33: error: stray '\' in program
  244 | ./Main.cpp:137:1: error: stray ‘\220’ in program
      |                                 ^
a.cc:244:34: error: extended character ’ is not valid in an identifier
  244 | ./Main.cpp:137:1: error: stray ‘\220’ in program
      |                                  ^
a.cc:245:32: error: extended character ‘ is not valid in an identifier
  245 | ./Main.cpp:137:1: error: stray ‘\345’ in program
      |                                ^
a.cc:245:33: error: stray '\' in program
  245 | ./Main.cpp:137:1: error: stray ‘\345’ in program
      |                                 ^
a.cc:245:34: error: extended character ’ is not valid in an identifier
  245 | ./Main.cpp:137:1: error: stray ‘\345’ in program
      |                                  ^
a.cc:246:32: error: extended character ‘ is not valid in an identifier
  246 | ./Main.cpp:137:1: error: stray ‘\207’ in program
      |                                ^
a.cc:246:33: error: stray '\' in program
  246 | ./Main.cpp:137:1: error: stray ‘\207’ in program
      |                                 ^
a.cc:246:34: error: extended character ’ is not valid in an identifier
  246 | ./Main.cpp:137:1: error: stray ‘\207’ in program
      |                                  ^
a.cc:247:32: error: extended character ‘ is not valid in an identifier
  247 | ./Main.cpp:137:1: error: stray ‘\272’ in program
      |                                ^
a.cc:247:33: error: stray '\' in program
  247 | ./Main.cpp:137:1: error: stray ‘\272’ in program
      |                                 ^
a.cc:247:34: error: extended character ’ is not valid in an identifier
  247 | ./Main.cpp:137:1: error: stray ‘\272’ in program
      |                                  ^
a.cc:248:32: error: extended character ‘ is not valid in an identifier
  248 | ./Main.cpp:137:1: error: stray ‘\346’ in program
      |                                ^
a.cc:248:33: error: stray '\' in program
  248 | ./Main.cpp:137:1: error: stray ‘\346’ in program
      |                                 ^
a.cc:248:34: error: extended character ’ is not valid in an identifier
  248 | ./Main.cpp:137:1: error: stray ‘\346’ in program
      |                                  ^
a.cc:249:32: error: extended character ‘ is not valid in an identifier
  249 | ./Main.cpp:137:1: error: stray ‘\203’ in program
      |                                ^
a.cc:249:33: error: stray '\' in program
  249 | ./Main.cpp:137:1: error: stray ‘\203’ in program
      |                                 ^
a.cc:249:34: error: extended character ’ is not valid in an identifier
  249 | ./Main.cpp:137:1: error: stray ‘\203’ in program
      |                                  ^
a.cc:250:32: error: extended character ‘ is not valid in an identifier
  250 | ./Main.cpp:137:1: error: stray ‘\205’ in program
      |                                ^
a.cc:250:33: error: stray '\' in program
  250 | ./Main.cpp:137:1: error: stray ‘\205’ in program
      |                                 ^
a.cc:250:34: error: extended character ’ is not valid in an identifier
  250 | ./Main.cpp:137:1: error: stray ‘\205’ in program
      |                                  ^
a.cc:251:32: error: extended character ‘ is not valid in an identifier
  251 | ./Main.cpp:137:1: error: stray ‘\345’ in program
      |                                ^
a.cc:251:33: error: stray '\' in program
  251 | ./Main.cpp:137:1: error: stray ‘\345’ in program
      |                                 ^
a.cc:251:34: error: extended character ’ is not valid in an identifier
  251 | ./Main.cpp:137:1: error: stray ‘\345’ in program
      |                                  ^
a.cc:252:32: error: extended character ‘ is not valid in an identifier
  252 | ./Main.cpp:137:1: error: stray ‘\240’ in program
      |                                ^
a.cc:252:33: error: stray '\' in program
  252 | ./Main.cpp:137:1: error: stray ‘\240’ in program
      |                                 ^
a.cc:252:34: error: extended character ’ is not valid in an identifier
  252 | ./Main.cpp:137:1: error: stray ‘\240’ in program
      |                                  ^
a.cc:253:32: error: extended character ‘ is not valid in an identifier
  253 | ./Main.cpp:137:1: error: stray ‘\261’ in program
      |                                ^
a.cc:253:33: error: stray '\' in program
  253 | ./Main.cpp:137:1: error: stray ‘\261’ in program
      |                                 ^
a.cc:253:34: error: extended character ’ is not valid in an identifier
  253 | ./Main.cpp:137:1: error: stray ‘\261’ in program
      |                                  ^
a.cc:254:32: error: extended character ‘ is not valid in an identifier
  254 | ./Main.cpp:138:1: error: stray ‘\346’ in program
      |                                ^
a.cc:254:33: error: stray '\' in program
  254 | ./Main.cpp:138:1: error: stray ‘\346’ in program
      |                                 ^
a.cc:254:34: error: extended character ’ is not valid in an identifier
  254 | ./Main.cpp:138:1: error: stray ‘\346’ in program
      |                                  ^
a.cc:255:16: error: invalid digit "8" in octal constant
  255 |  提出日時 2019-08-04 12:07:19
      |                ^~
a.cc:257:32: error: extended character ‘ is not valid in an identifier
  257 | ./Main.cpp:138:1: error: stray ‘\217’ in program
      |                                ^
a.cc:257:33: error: stray '\' in program
  257 | ./Main.cpp:138:1: error: stray ‘\217’ in program
      |                                 ^
a.cc:257:34: error: extended character ’ is not valid in an identifier
  257 | ./Main.cpp:138:1: error: stray ‘\217’ in program
      |                                  ^
a.cc:258:32: error: extended character ‘ is not valid in an identifier
  258 | ./Main.cpp:138:1: error: stray ‘\220’ in program
      |                                ^
a.cc:258:33: error: stray '\' in program
  258 | ./Main.cpp:138:1: error: stray ‘\220’ in program
      |                                 ^
a.cc:258:34: error: extended character ’ is not valid in an identifier
  258 | ./Main.cpp:138:1: error: stray ‘\220’ in program
      |                                  ^
a.cc:259:32: error: extended character ‘ is not valid in an identifier
  259 | ./Main.cpp:138:1: error: stray ‘\345’ in program
      |                                ^
a.cc:259:33: error: stray '\' in program
  259 | ./Main.cpp:138:1: error: stray ‘\345’ in program
      |                                 ^
a.cc:259:34: error: extended character ’ is not valid in an identifier
  259 | ./Main.cpp:138:1: error: stray ‘\345’ in program
      |                                  ^
a.cc:260:32: error: extended character ‘ is not valid in an identifier
  260 | ./Main.cpp:138:1: error: stray ‘\207’ in program
      |                                ^
a.cc:260:33: error: stray '\' in program
  260 | ./Main.cpp:138:1: error: stray ‘\207’ in program
      |                                 ^
a.cc:260:34: error: extended character ’ is not valid in an identifier
  260 | ./Main.cpp:138:1: error: stray ‘\207’ in program
      |                                  ^
a.cc:261:32: error: extended character ‘ is not valid in an identifier
  261 | ./Main.cpp:138:1: error: stray ‘\272’ in program
      |                                ^
a.cc:261:33: error: stray '\' in program
  261 | ./Main.cpp:138:1: error: stray ‘\272’ in program
      |                                 ^
a.cc:261:34: error: extended character ’ is not valid in an identifier
  261 | ./Main.cpp:138:1: error: stray ‘\272’ in program
      |                                  ^
a.cc:262:32: error: extended character ‘ is not valid in an identifier
  262 | ./Main.cpp:138:1: error: stray ‘\346’ in program
      |                                ^
a.cc:262:33: error: stray '\' in program
  262 | ./Main.cpp:138:1: error: stray ‘\346’ in program
      |                                 ^
a.cc:262:34: error: extended character ’ is not valid in an identifier
  262 | ./Main.cpp:138