QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#377347#7995. 图DvaWA 1ms5648kbC++142.2kb2024-04-05 12:43:132024-04-05 12:43:13

Judging History

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

  • [2024-04-05 12:43:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5648kb
  • [2024-04-05 12:43:13]
  • 提交

answer

#pragma GCC optimize(3)
#include <bits/stdc++.h>

#define f(i, n, m) for (long long i = n; i <= m; ++i)
#define unf(i, n, m) for (long long i = n; i >= m; --i)
#define kong NULL
#define debug cout << "sss" << endl;

using ll = long long;
using ull = unsigned long long;
using point_t = double; // 计算几何的默认类型

const double e = exp(1.0);
const double pi = acos(-1.0);
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
constexpr ll maxx = 0x3f3f3f3f3f3f3f3f;
constexpr ll minn = 0xc0c0c0c0c0c0c0c0;

#define endl '\n'
constexpr char blank = ' ';
constexpr ll mod = (ll)998244353;
constexpr size_t N = (size_t)1e6 + 6;

#ifdef _DEBUG
#define Crash(...) (__debugbreak(), 0)
#define Debug(...) (__debugbreak(), 0)
#else
#define Crash(...) (exit(-1), 0)
#define Debug(...) ((void)0)
#endif // _DEBUG

#define ensure(expression) (void)(!!(expression) || Crash())

inline void setaccuracy(const std::streamsize &accuracy) {
	std::cout << std::fixed << std::setprecision(accuracy);
}

#define int long long
using namespace std;

int n;
int mp[510][510];
int dp[510][510];
void bfs(int x,int fa,int wo){
  vector<int>check(510,0);
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>que;
  que.push({0,x});
  
  while(!que.empty()){
    auto it=que.top();
    que.pop();
    if(check[it.second])continue;
    check[it.second]=1;
    f(i,1,n){
      if(i==it.second)continue;
      if(it.first+mp[it.second][i]<dp[wo][i]){
        dp[wo][i]=it.first+mp[it.second][i];
        que.push({dp[wo][i],i});
      }
    }
  }
}
void solve() {
  cin>>n;
  f(i,1,n){
    f(j,1,n){
      cin>>mp[i][j];
      dp[i][j]=maxx;
    }
  }
  f(i,1,n)bfs(i,0,i);
  int cnt=0;
  f(i,1,n){
    f(j,1,n){

      if(i==j)dp[i][j]=0;
      else if(dp[i][j]==mp[i][j]){
        dp[i][j]=1;
      }
      else dp[i][j]=0;
    }
    cout<<endl;
  }
  f(i,1,n){
    f(j,1,n)cout<<dp[i][j];
    if(i!=n)cout<<endl;
  }
  

	// std::cout<< minn<<endl;
}

signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	int T = 1;
	// cin >> T;
	// scanf(" %d", &T);
	// std::cin >> T;
	// for (int q = 1; q <= T; q++) {
	// while (T--) {
		solve();
	// }

	return 0;
}

详细

Test #1:

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

input:

4
0 3 2 100
3 0 8 100
2 8 0 10
100 100 10 0

output:





0110
1000
1001
0010

result:

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