Submission #717698

#TimeUsernameProblemLanguageResultExecution timeMemory
717698EntityPlanttPoi (IOI09_poi)C++14
100 / 100
327 ms9968 KiB
#include <cstdio> #include <cstring> #include <algorithm> #include <vector> int main() { int n, t, p, i, j, x; scanf("%d%d%d", &n, &t, &p); std::vector <int> solved[n], score(t, n), final(n, 0); int ppl[n]; for (i = 0; i < n; i++) { ppl[i] = i; for (j = 0; j < t; j++) { scanf("%d", &x); if (x) { solved[i].push_back(j); score[j]--; } } } for (i = 0; i < n; i++) { for (j = 0; j < solved[i].size(); j++) { final[i] += score[solved[i][j]]; } } std::sort(ppl, ppl + n, [&](int a, int b) { if (final[a] != final[b]) return final[a] > final[b]; if (solved[a].size() != solved[b].size()) return solved[a].size() > solved[b].size(); return a < b; }); p--; /* for (i = 0; i < n; i++) { if (ppl[i] == p) { printf(">%3d", i + 1); } else { printf("%4d", i + 1); } printf(" | Contestant #%d, Total: %d, Solved tasks: %d\n", ppl[i] + 1, final[ppl[i]], solved[ppl[i]].size()); } */ printf("%d %d", final[p], std::distance(ppl - 1, std::find(ppl, ppl + n, p))); return 0; }

Compilation message (stderr)

poi.cpp: In function 'int main()':
poi.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (j = 0; j < solved[i].size(); j++) {
      |                     ~~^~~~~~~~~~~~~~~~~~
poi.cpp:40:17: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::iterator_traits<int*>::difference_type' {aka 'long int'} [-Wformat=]
   40 |     printf("%d %d", final[p], std::distance(ppl - 1, std::find(ppl, ppl + n, p)));
      |                ~^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                 |                          |
      |                 int                        std::iterator_traits<int*>::difference_type {aka long int}
      |                %ld
poi.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d%d%d", &n, &t, &p);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
poi.cpp:13:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |             scanf("%d", &x);
      |             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...