Submission #1078512

#TimeUsernameProblemLanguageResultExecution timeMemory
1078512mindiyakPainting Squares (IOI20_squares)C++14
45 / 100
67 ms776 KiB
#include "squares.h" #include <vector> #include <iostream> using namespace std; vector<int> paint(int n) { vector<int> labels; int cnt = 1; // for(int i=0;i<1000;i++){ // for(int j = 0;j<(32-cnt);j++)cerr << 0; // for(int j = 0;j<cnt;j++)cerr << 1; // cerr << endl; // cnt ++; // i += 31; // } cnt = 1; for(int i=0;i<n;i++){ for(int j = 0;j<(32-cnt);j++)labels.push_back(0); for(int j = 0;j<cnt;j++)labels.push_back(1); cnt ++; i += 31; } labels.resize(n); labels.push_back(50); return labels; } int find_location(int n, vector<int> c) { for (int i = 0; i < c.size(); i++) if (c[i] == -1) return n-i; int cnt = 0,pos = 0; for (int i = 1; i < c.size(); i++){ if(c[i] != c[0])cnt ++; else{ if(cnt != 0){ pos = i; break; } } } if(c[0] == 0){ int line = cnt * 32; // cerr << c[0] << " " << line << " " << cnt << " " << pos << " " << (line - pos) << endl; return line - pos; } int line = 32 * (32-cnt-1); // cerr << c[0] << " " << line << " " << cnt << " " << pos << " " << (line-pos)<< endl; return line - pos + cnt; }

Compilation message (stderr)

squares.cpp: In function 'int find_location(int, std::vector<int>)':
squares.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i = 0; i < c.size(); i++) if (c[i] == -1) return n-i;
      |                  ~~^~~~~~~~~~
squares.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i = 1; i < c.size(); i++){
      |                  ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...