답안 #1077730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077730 2024-08-27T08:45:34 Z vjudge1 Reconstruction Project (JOI22_reconstruction) C++17
7 / 100
1599 ms 49680 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=505,M=1e5+5,Q=1e6+5;
int n,m,j[N],q,ans[Q];
vector<int> adj[N];
pair<int,int> w[Q];
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>m;
	for (int i=1;i<=m;i++){
		int x,y,w;
		cin>>x>>y>>w;
		adj[x].pb(w);
	}
	for (int i=1;i<n;i++) sort(adj[i].begin(),adj[i].end()),j[i]=0;
	cin>>q;
	for (int i=1;i<=q;i++) cin>>w[i].F,w[i].S=i;
	sort(w+1,w+1+q);
	for (int i=1;i<=q;i++){
		for (int k=1;k<n;k++){
			while (j[k]+1<adj[k].size()){
				if (abs(w[i].F-adj[k][j[k]+1])<abs(w[i].F-adj[k][j[k]])) j[k]++;
				else break;
			}
			ans[w[i].S]+=abs(w[i].F-adj[k][j[k]]);
		}
	}
	for (int i=1;i<=q;i++) cout<<ans[i]<<endl;
	return 0;
}

Compilation message

reconstruction.cpp: In function 'int32_t main()':
reconstruction.cpp:33:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    while (j[k]+1<adj[k].size()){
      |           ~~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1599 ms 47500 KB Output is correct
5 Correct 1581 ms 47420 KB Output is correct
6 Correct 1555 ms 47312 KB Output is correct
7 Correct 1037 ms 49348 KB Output is correct
8 Correct 944 ms 49652 KB Output is correct
9 Correct 921 ms 49204 KB Output is correct
10 Correct 1575 ms 47432 KB Output is correct
11 Correct 1030 ms 49680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -