QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#59693#2832. Graph TheoryXrkArul#WA 58ms3560kbC++172.0kb2022-10-31 19:58:042022-10-31 19:58:07

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-31 19:58:07]
  • 评测
  • 测评结果:WA
  • 用时:58ms
  • 内存:3560kb
  • [2022-10-31 19:58:04]
  • 提交

answer

// Duet of Dusk Embers--XrkArul
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ULL __int128_t
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define endl '\n'
#define ednl '\n'
#define pb push_back
#define fi first
#define se second
#define ls (p<<1)
#define rs (p<<1|1)
#define fix setprecision
#define all(v) v.begin(),v.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define debug(x) cerr<<#x<<':'<<' '<<x<<'\n'
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define pq priority_queue<int, vector<int>>
#define PQ priority_queue<int, vector<int>, greater<int>>
const ll inf = 1e18;
const ll mod=1e9+7;
const ull hashbase = 5767169;
ll powmod(ll a,ll b){ll s=1;a%=mod;while(b){if(b&1)s=s*a%mod;b>>=1;a=a*a%mod;}return s%mod;}

#define int long long
void solve(){
    
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    //cin>>T;
    int n,m;
    while(cin>>n>>m){
        multiset<int> s;
        vector<vector<pii>> qwq(n+10);
        int f=0;
        rep(i,1,m){
            int a,b;cin>>a>>b;
            if(a==b){
                continue;
            }
            if(a>b)swap(a,b);
            f=1;
            int len=b-a;
            qwq[a].pb({n-len,1});
            qwq[b].pb({n-len,-1});
            qwq[1].pb({len,1});
            qwq[a].pb({len,-1});
            qwq[b].pb({len,1});
            // qwq[n+1]
        }
        int ans=inf;
        if(!f){
            cout<<0<<endl;continue;
        }
        rep(i,1,n){
            sort(all(qwq[i]),[&](pii a,pii b){
                return a.se<b.se;
            });
            for(auto x:qwq[i]){
                if(x.se==-1){
                    if(!s.size())continue;
                    s.erase(s.find(x.fi));
                }else{
                    s.insert(x.fi);
                }
            }
            if(s.size())
            ans=min(ans,*(s.rbegin()));
        }
        cout<<ans<<endl;
    }
    return 0;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3504kb

input:

3 2
1 2
2 3
3 2
1 1
2 2
3 3
1 2
2 3
3 1

output:

1
0
2

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 2ms
memory: 3548kb

input:

2 1
1 2

output:

1

result:

ok single line: '1'

Test #3:

score: -100
Wrong Answer
time: 58ms
memory: 3560kb

input:

17 17
6 10
1 9
14 6
12 13
5 4
15 17
14 15
6 5
10 6
10 11
2 9
9 6
17 15
9 15
4 8
1 4
13 15
13 19
11 10
12 10
10 5
2 8
12 11
8 3
1 7
10 9
8 5
1 5
9 4
8 7
12 10
6 8
13 1
5 8
11 5
10 8
7 7
16 14
9 5
8 1
4 16
10 8
16 15
15 1
13 5
9 3
4 4
9 7
7 2
5 4
5 11
9 14
5 13
1 5
4 5
4 1
4 4
1 1
5 3
3 5
4 1
3 2
5 1
...

output:

8
12
14
4
1
3
7
6
2
9
3
10
10
12
14
10
5
10
12
7
10
10
6
8
10
13
2
2
2
11
6
9
13
4
3
17
4
1
15
9
9
2
6
4
1
4
2
3
6
13
13
7
4
11
10
11
5
8
1
6
5
3
1
8
8
6
7
8
6
7
12
11
3
3
9
7
8
5
10
11
8
1
4
4
8
1
18
7
5
9
4
6
7
5
7
11
1
9
8
11
6
5
9
3
8
7
7
6
9
2
14
5
6
7
10
7
1
4
2
6
12
7
9
7
3
5
1
5
7
3
2
17
9
8...

result:

wrong answer 2nd lines differ - expected: '6', found: '12'