Submission #46316592


Source Code Expand

#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int, int> P;

bool comp(P first, P second){
  if (first.second == second.second){
    return first.first < second.first;
  }
  return first.second > second.second;
}

int main(){
  int n;
  cin >> n;
  vector<P> ps;
  int i_ = 1;
  while(i_ <= n){
    string s;
    cin >> s;
    int score = 0;
    for (int i = 0; i < s.size(); i++){
      if (s.compare(i, 1, "o") == 0){
        score++;
      }
    }
    P p (i_, score);
    ps.push_back(p);
    i_++;
  }
  sort(ps.begin(), ps.end(), comp);
  for (int i = 0; i < ps.size(); i++){
    cout << ps[i].first << " ";
  }
  cout << endl;
  return 0;
}

Submission Info

Submission Time
Task B - Round-Robin Tournament
User ThousandthStar
Language C++ 17 (gcc 12.2)
Score 200
Code Size 777 Byte
Status AC
Exec Time 1 ms
Memory 3564 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:28:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   28 |     for (int i = 0; i < s.size(); i++){
      |                     ~~^~~~~~~~~~
Main.cpp:38:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::pair<int, int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   38 |   for (int i = 0; i < ps.size(); i++){
      |                   ~~^~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 12
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3472 KiB
00_sample_02.txt AC 1 ms 3476 KiB
01_test_01.txt AC 1 ms 3396 KiB
01_test_02.txt AC 1 ms 3468 KiB
01_test_03.txt AC 1 ms 3520 KiB
01_test_04.txt AC 1 ms 3468 KiB
01_test_05.txt AC 1 ms 3508 KiB
01_test_06.txt AC 1 ms 3452 KiB
01_test_07.txt AC 1 ms 3448 KiB
01_test_08.txt AC 1 ms 3488 KiB
01_test_09.txt AC 1 ms 3564 KiB
01_test_10.txt AC 1 ms 3492 KiB