제출 #258078

#제출 시각아이디문제언어결과실행 시간메모리
258078tqbfjotldRestore Array (RMI19_restore)C++14
0 / 100
16 ms1148 KiB
/* value = 0 --> sum of range(l,r)<=r-l+1-k value = 1 --> sum of range(l,r)>=r-l+1-k+1 */ #include <bits/stdc++.h> using namespace std; typedef pair<pair<int,int>,pair<int,int> > query; bool cmp(query a, query b){ if (a.second.first==1 && a.second.second==1) return true; if (b.second.first==1 && b.second.second==1) return false; if (a.second.first==a.first.second-a.first.first+1 && a.second.second==0) return true; if (b.second.first==b.first.second-b.first.first+1 && b.second.second==0) return false; return a<b; } int arr[5005]; vector<query> queries; int main(){ int n,m; scanf("%d%d",&n,&m); for (int x = 0; x<m; x++){ int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d); queries.push_back({{a,b},{c,d}}); } sort(queries.begin(),queries.end(),cmp); for (auto x : queries){ int l = x.first.first; int r = x.first.second; int k = x.second.first; int val = x.second.second; if (k==1&&val==1){ for (int x = l; x<=r; x++){ arr[x] = 1; } continue; } if (k==r-l+1 && val==0){ for (int x = l; x<=r; x++){ if (arr[x]==1){ printf("-1"); return 0; } } continue; } //if (val==0){ bool found = false; for (int x = l; x<=r; x++){ if (val==arr[x]) found = true; } if (!found){ printf("-1"); return 0; } //} } for (int x = 0; x<n; x++){ printf("%d ",arr[x]); } }

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

restore.cpp: In function 'int main()':
restore.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
restore.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d%d",&a,&b,&c,&d);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...