Submission #864297

#TimeUsernameProblemLanguageResultExecution timeMemory
864297vjudge1Monster Game (JOI21_monster)C++17
0 / 100
91 ms1616 KiB
#include <bits/stdc++.h> #include "monster.h" using namespace std; vector<int> Solve(int n) { int wins[n]={0}; bool outcome[n][n]; vector<int> strength(n); for (int i=0; i<n; i++) for (int j=i+1; j<n; j++) { outcome[i][j]=Query(i, j); if (outcome[i][j]==true) wins[i]=wins[i]+1; else wins[j]=wins[j]+1; } for (int i=0; i<n; i++) strength[i]=wins[i]; for (int i=0; i<n; i++) for (int j=j+1; j<n; j++) { if (wins[i]==n-2 && wins[j]==n-2) { strength[i]=n-1; strength[j]=n-2; if (outcome[i][j]==true) swap(strength[i], strength[j]); } if (wins[i]==1 && wins[1]==1) { strength[i]=2; strength[j]=1; if (outcome[i][j]==true) swap(strength[i], strength[j]); } } return strength; }

Compilation message (stderr)

monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:22:18: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |         for (int j=j+1; j<n; j++)
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...