結果
| 問題 |
No.2403 "Eight" Bridges of Königsberg
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-04 21:37:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,015 bytes |
| コンパイル時間 | 911 ms |
| コンパイル使用メモリ | 78,344 KB |
| 最終ジャッジ日時 | 2025-02-15 22:30:36 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 WA * 10 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin>>N>>M;
vector<int>C(N);
for(int i=0;i<M;i++){
int u,v;
cin>>u>>v;
u--;
v--;
C[u]++;
C[v]--;
}
sort(all(C));
int a=0,b=0;
for(int i=0;i<N;i++){
if(i==0){
a+=max(0,-1-C[i]);
b+=max(0,-C[i]);
}else if(i==N-1){
a+=max(0,1-C[i]);
b+=max(0,-C[i]);
}else{
a+=max(0,-C[i]);
b+=max(0,-C[i]);
}
}
cout<<min(a,b)<<"\n";
}