QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#411411#6765. Don't Really Like How The Story EndsxiaoleWA 247ms8396kbC++231016b2024-05-15 13:03:312024-05-15 13:03:31

Judging History

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

  • [2024-05-15 13:03:31]
  • 评测
  • 测评结果:WA
  • 用时:247ms
  • 内存:8396kb
  • [2024-05-15 13:03:31]
  • 提交

answer

#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;using ll = long long;using PLL = pair<ll,ll>;
const ll MAX = 1e18;const ll MIN = -1e18;const ll INF=0x3f3f3f3f;
const ll Q = 1e5+9;const ll MOD = 1e9 + 7;
set<ll> d[Q];ll ans;
bool vis[Q];ll n,m;
ll now=2;
void dfs(ll x){
    for(auto i:d[x]){
        if(i<now) continue;
        while(i>=now)
        {
            if(i==now){
                now++;
                dfs(now-1);
            }else{
                ans++;
                now++;
                dfs(now-1);
            }
        }
    }
}
void solve(){
   cin>>n>>m;
   memset(vis,0,sizeof vis);
   ans=0;now=2;
   for (ll i = 0; i <= n; i++) d[i].clear();
   for (ll i = 0; i < m; i++)
   {
    ll o,p;cin>>o>>p;
    if(p>o) d[o].insert(p);
    else d[p].insert(o);
   }
   d[1].insert(n+1);
   dfs(1);
   
   cout<<ans<<"\n";
}
int main(){
    ios;ll _=1;cin>>_;
    while (_--)solve();
    return 0;
}

详细

Test #1:

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

input:

3
2 3
1 1
1 2
2 1
4 1
1 4
4 2
1 2
3 4

output:

0
2
1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 247ms
memory: 8352kb

input:

117747
3 7
2 1
3 3
1 3
1 1
3 2
1 1
3 1
4 8
2 3
4 3
3 2
4 2
1 3
2 1
4 3
2 4
3 4
2 3
2 2
3 3
1 1
2 5
1 1
2 2
2 2
1 2
2 2
3 7
2 1
1 2
3 3
3 2
1 2
3 3
3 2
4 5
1 2
3 3
4 4
1 4
2 1
3 1
3 2
1 3
1 1
1 1
1 1
1 6
1 1
1 1
1 1
1 1
1 1
1 1
5 4
2 1
2 5
1 3
3 2
4 7
1 1
2 4
3 2
1 1
1 1
4 2
2 3
5 8
3 3
2 2
4 2
1 4
1...

output:

0
0
1
0
0
1
1
0
0
1
1
1
0
0
2
0
2
0
1
0
0
3
0
0
0
2
1
1
1
0
0
0
2
0
2
1
3
0
2
0
3
1
2
1
0
0
1
2
0
2
2
1
2
2
1
2
0
0
0
1
0
3
2
1
0
0
1
0
0
3
2
0
0
0
1
0
2
3
0
1
1
1
1
0
0
2
2
3
0
1
2
1
0
0
3
2
1
3
1
0
2
0
0
0
1
0
0
0
0
0
0
4
0
0
0
0
0
0
2
0
1
0
0
1
1
1
1
2
0
1
0
0
0
2
0
1
2
1
1
0
0
1
0
0
1
1
1
0
0
0
...

result:

wrong answer 51st lines differ - expected: '0', found: '2'