QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#401474#140. Palembang Bridges socpite0 0ms3516kbC++231.2kb2024-04-28 19:29:042024-04-28 19:29:04

Judging History

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

  • [2024-04-28 19:29:04]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3516kb
  • [2024-04-28 19:29:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
 
long long INF = 1e18;
 
vector<int> cp;
 
vector<pair<int, int>> vec;
 
int k, n;
 
int main(){
    cin >> k >> n;
	assert(k == 2);
    long long ans = INF;
    long long base = 0;
    for(int i = 0; i < n; i++){
        char t1, t2;
        pair<int, int> p;
        cin >> t1 >> p.first >> t2 >> p.second;
        if(p.first > p.second)swap(p.first, p.second);
        base += p.second - p.first;
        if(t1 != t2) {
            base++;
            vec.push_back(p);
        	cp.push_back(p.first);
        	cp.push_back(p.second);
        }
    }
    sort(cp.begin(), cp.end());
    // cp.erase(unique(cp.begin(), cp.end()), cp.end());
    for(auto x: cp){
        for(auto y: cp){
            long long sum = 0;
            for(auto p: vec){
                if(p.first <= x && x <= p.second)continue;
                if(p.first <= y && y <= p.second)continue;
                sum += min(min(abs(x - p.first), abs(x - p.second)), min(abs(y - p.first), abs(y - p.second)));
            }
            ans = min(ans, sum);
            // cout << x << " " << y << " " << sum << endl;
        }
    }
    cout << base + ans*2;
}

詳細信息

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

1 1
B 426311872 B 741424667

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 0ms
memory: 3516kb

input:

2 1
B 822190955 B 309099167

output:

2000000000513091788

result:

wrong answer 1st lines differ - expected: '513091788', found: '2000000000513091788'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%