제출 #1078482

#제출 시각아이디문제언어결과실행 시간메모리
1078482mindiyakHandcrafted Gift (IOI20_gift)C++14
25 / 100
158 ms29172 KiB
#include "gift.h" #include <vector> #include <algorithm> #include <iostream> using namespace std; int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) { vector<int> arr(n,0),presum(n+1,0); vector<pair<int,int>> p,q,t; for(int i=0;i<r;i++){ if(x[i] == 1)p.push_back({a[i],b[i]}); if(x[i] == 2)q.push_back({a[i],b[i]}); } sort(p.begin(),p.end()); if(p.size()>0){ int start = p[0].first,end = p[0].second; for(int i = 1;i<p.size();i++){ if(p[i].first <= end){ end = max(end,p[i].second); }else{ t.push_back({start,end}); start = p[i].first; end = p[i].second; } } t.push_back({start,end}); for(int i=0;i<t.size();i++){ cerr << (i%2)+1 << " " << t[i].first << " " << t[i].second << endl; for(int j=t[i].first;j<=t[i].second;j++){ // arr[j] = (i%2)+1; arr[j] = 2; } } } int val = 1; for(int i=0;i<n;i++){ if(arr[i] == 0)arr[i] = (val%2) + 1; val ++; } for(int i=1;i<=n;i++){ presum[i] = presum[i-1] + arr[i-1]; } for(int i=0;i<q.size();i++){ int len = q[i].second - q[i].first + 1; int val = presum[q[i].second+1] - presum[q[i].first]; if(len == val) return 0; if(len*2 == val) return 0; } string s = ""; for(int i=0;i<n;i++)s += (arr[i] == 1) ? "R" : "B"; 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:24: 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 = 1;i<p.size();i++){
      |                       ~^~~~~~~~~
gift.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i=0;i<t.size();i++){
      |                     ~^~~~~~~~~
gift.cpp:50: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]
   50 |     for(int i=0;i<q.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...
#Verdict Execution timeMemoryGrader output
Fetching results...