QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#636645#3563. Treatment ProjectDimash0 1ms5812kbC++231.7kb2024-10-13 01:27:212024-10-13 01:27:22

Judging History

This is the latest submission verdict.

  • [2024-10-13 01:27:22]
  • Judged
  • Verdict: 0
  • Time: 1ms
  • Memory: 5812kb
  • [2024-10-13 01:27:21]
  • Submitted

answer

#include <bits/stdc++.h>
    
using namespace std;
    
typedef long long ll;
    
const int  N = 2e5 + 12, MOD = (int)1e9 + 7;
    
const ll inf = 1e18;
ll res = inf, d[N];
int n, m;
vector<array<int, 4>> a;
    
bool cmp(array<int, 4> x, array<int, 4> y) {
    return make_pair(x[1], x[2]) < make_pair(y[1], y[2]);
}
vector<int> g[N];
void test() {
    cin >> n >> m;
    a.resize(m);
    for(int i = 0; i < m; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3], d[i] = inf;
    }
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            if (a[i][0] <= a[j][0]) {
				if (a[j][1] <= a[i][2] - (a[j][0] - a[i][0])) {
					g[i].push_back(j);
				}
 			}
			if (a[i][0] >= a[j][0]) {
				if (a[i][2] >= a[j][1] + (a[i][0] - a[j][0])) {
					g[i].push_back(j);
				}
			}
        }
    }
    set<pair<ll, int>> st;
    for(int i = 0; i < m; i++) {    
        if(a[i][1] == 1) {
            st.insert({d[i], i});
            d[i] = a[i][3];
        }
    }
    while(!st.empty()) {
        auto [w, v] = (*st.begin());
        st.erase(st.begin());
        for(int to:g[v]) {
            if(d[to] > d[v] + a[to][3]) {
                st.erase({d[to], to});
                d[to] = d[v] + a[to][3];
                st.insert({d[to], to});
            }
        }
    }
    for(int i = 0; i < m; i++) if(a[i][2] == n){
        res = min(res, d[i]);
    }
    if(res == inf) {
        res = -1;
    }
    cout << res << '\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); 
    
    int t = 1; 
    // cin >> t;
    
    while(t--) 
        test();
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

1000000000 100000
1 811370001 811380000 1000000000
1 413190001 413200000 1000000000
1 462480001 462490000 1000000000
1 384860001 384870000 1000000000
1 543220001 543230000 1000000000
1 766300001 766310000 1000000000
1 348890001 348900000 1000000000
1 996350001 996360000 1000000000
1 302700001 302710...

output:


result:


Subtask #2:

score: 0
Wrong Answer

Test #19:

score: 5
Accepted
time: 1ms
memory: 5624kb

input:

1 1
1000000000 1 1 1000000000

output:

1000000000

result:

ok single line: '1000000000'

Test #20:

score: 0
Wrong Answer
time: 1ms
memory: 5812kb

input:

1000000000 16
6 2 2 1
4 999999997 999999999 4
2 999999997 1000000000 2
3 1 4 3
3 999999997 1000000000 3
5 999999998 999999999 3
6 999999999 999999999 1
2 1 4 2
6 3 999999998 1
999999987 1 1000000000 10
999999986 1 1000000000 10
999999985 1 1000000000 10
4 2 4 4
5 2 3 3
1 999999997 1000000000 1
1 1 4 1

output:

10

result:

wrong answer 1st lines differ - expected: '9', found: '10'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%