제출 #627506

#제출 시각아이디문제언어결과실행 시간메모리
627506inwbear드문 곤충 (IOI22_insects)C++17
42.91 / 100
245 ms464 KiB
#include "insects.h" #include<bits/stdc++.h> #define pb push_back #define F first #define S second using namespace std; int cc[2005],re,sq,rr; pair<int,int>pos[2005]; bool ins[2005]; int min_cardinality(int N) { re=N; vector<int>v; vector<pair<int,int> >fr; for(int i=0;i<N;i++){ move_inside(i); if(press_button()>1){ move_outside(i); fr.pb({i,false}); } else v.pb(i),ins[i]=true; } if(v.size()!=(int)sqrt(v.size())*(int)sqrt(v.size()))sq=(int)sqrt(v.size())+1; else sq=(int)sqrt(v.size()); for(int i=0;i<v.size();i++)move_outside(v[i]); for(int i=sq;i<v.size();i+=sq){ rr=0; for(int j=i;j<v.size()&&j<i+sq;j++){ rr++; move_inside(v[j]); } for(int j=0;j<fr.size();j++){ if(fr[j].S)continue; move_inside(fr[j].F); if(press_button()>1){ fr[j].S=true; rr--; pos[fr[j].F].F=i/sq; } move_outside(fr[j].F); } for(int j=i;j<v.size()&&j<i+sq;j++){ move_outside(v[j]); } if(rr>0)return 1; } for(int j=0;j<fr.size();j++)fr[j].S=true; for(int i=1;i<sq;i++){ rr=0; for(int j=i;j<v.size();j+=sq){ move_inside(v[j]); rr++; } for(int j=0;j<fr.size();j++){ if(!fr[j].S)continue; move_inside(fr[j].F); if(press_button()>1){ fr[j].S=false; pos[fr[j].F].S=i; rr--; } move_outside(fr[j].F); } for(int j=i;j<v.size();j+=sq){ move_inside(v[j]); } if(rr>0)return 1; } //for(int i=0;i<v.size();i++)printf("{%d}",v[i]); //for(int i=0;i<fr.size();i++)printf("[%d %d]",pos[fr[i].F].F,pos[fr[i].F].S); for(int i=0;i<fr.size();i++){ cc[v[(pos[fr[i].F].F*sq)+pos[fr[i].F].S]]++; } for(int i=0;i<v.size();i++)re=min(re,cc[v[i]]+1); return re; }

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:24:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   if(v.size()!=(int)sqrt(v.size())*(int)sqrt(v.size()))sq=(int)sqrt(v.size())+1;
      |      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
insects.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int i=0;i<v.size();i++)move_outside(v[i]);
      |               ~^~~~~~~~~
insects.cpp:27:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for(int i=sq;i<v.size();i+=sq){
      |                ~^~~~~~~~~
insects.cpp:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int j=i;j<v.size()&&j<i+sq;j++){
      |                 ~^~~~~~~~~
insects.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int j=0;j<fr.size();j++){
      |                 ~^~~~~~~~~~
insects.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int j=i;j<v.size()&&j<i+sq;j++){
      |                 ~^~~~~~~~~
insects.cpp:48:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for(int j=0;j<fr.size();j++)fr[j].S=true;
      |               ~^~~~~~~~~~
insects.cpp:51:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int j=i;j<v.size();j+=sq){
      |                 ~^~~~~~~~~
insects.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int j=0;j<fr.size();j++){
      |                 ~^~~~~~~~~~
insects.cpp:65:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for(int j=i;j<v.size();j+=sq){
      |                 ~^~~~~~~~~
insects.cpp:72:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |   for(int i=0;i<fr.size();i++){
      |               ~^~~~~~~~~~
insects.cpp:75:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |   for(int i=0;i<v.size();i++)re=min(re,cc[v[i]]+1);
      |               ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...