제출 #747747

#제출 시각아이디문제언어결과실행 시간메모리
747747LIFHandcrafted Gift (IOI20_gift)C++14
10 / 100
232 ms19184 KiB
#include "gift.h" #include<bits/stdc++.h> #include<string> #include<vector> using namespace std; int ass[500005]; vector<pair<int,int> > one; //first step : assort it , such that 1111 , 2222; int construct(int n, int r, vector<int> a, vector<int> b, std::vector<int> x) { int pos = 1; for(int i=0;i<r;i++) { if(x[i] == 1)one.push_back(make_pair(a[i],b[i])); if(x[i] == 2 && b[i] == a[i])return 0; } sort(one.begin(),one.end()); int poss = 1; int last = 0; for(int i=0;i<one.size();i++) { int mxr = one[i].second; while(one[i].first <= mxr && i<= one.size()-1) { mxr = max(mxr,one[i].second); i++; } i--; for(int j=last;j<=mxr;j++)ass[j] = poss; last = mxr + 1; poss++; } for(int i=0;i<r;i++) { if(x[i] == 1)continue; if(ass[b[i]] == ass[a[i]])return 0; } string s; s += "R"; int lastmax = -1; if(ass[0] == 1) lastmax = 1; for(int i=1;i<n;i++) { if(ass[i] == 0) { if(s[i-1] == 'R')s += "B"; else s += "R"; continue; } if(ass[i] == lastmax) { s += s[i-1]; continue; } if(ass[i] > lastmax) { lastmax = ass[i]; if(s[i-1] == 'R')s += "B"; else s += "R"; continue; } } craft(s); return 1; }

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

gift.cpp: In function 'int construct(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
gift.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=0;i<one.size();i++)
      |              ~^~~~~~~~~~~
gift.cpp:23:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   while(one[i].first <= mxr && i<= one.size()-1)
      |                                ~^~~~~~~~~~~~~~~
gift.cpp:11:6: warning: unused variable 'pos' [-Wunused-variable]
   11 |  int pos = 1;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...