제출 #1176796

#제출 시각아이디문제언어결과실행 시간메모리
1176796sleepntsheep푸드 코트 (JOI21_foodcourt)C++20
7 / 100
51 ms7748 KiB
#include <vector>
#include <deque>
#include <utility>
#include <stdio.h>

using namespace std;
template<typename T>
using ve=std::vector<T>;
using pii=std::pair<int,int>;

int n, m, q;
struct Q{
    int t,a,b,c,d;
    long long k;
}qq[250000];

int main() {
    scanf("%d%d%d", &n, &m, &q);
    for (int i = 0; i < q; ++i) {
	scanf("%d", &qq[i].t);
	if (qq[i].t == 1)
	    scanf("%d%d%d%d", &qq[i].a, &qq[i].b, &qq[i].c, &qq[i].d);
	else if (qq[i].t == 2)
	    scanf("%d%d%d", &qq[i].a, &qq[i].b, &qq[i].c);
	else
	    scanf("%d%lld", &qq[i].a, &qq[i].k);
    }

    if(n<=2000&&q<=2000){
	ve<deque<pii>>x(2001);
	for(int i=0;i<q;++i){
	    auto[t,a,b,c,d,k]=qq[i];
	    if(t==1){
		for(int j=a;j<=b;++j)x[j].emplace_back(d,c);
	    }else if(t==2){
		for(int j=a;j<=b;++j){
		    int k2=c;
		    while(x[j].size()&&k2){
			if(x[j][0].first<=k2){
			    k2-=x[j][0].first;
			    x[j].pop_front();
			}else{
			    x[j][0].first-=k2;
			    k2=0;
			}
		    }
		}
	    }else{
		long long j=0,k2=k;
		for(;j<=x[a].size()&&k2;++j){
		    if(j==x[a].size()){
			puts("0");
			break;
		    } else if(k2<=x[a][j].first){
			printf("%d\n",x[a][j].second);
			k2=0;
			break;
		    }else{
			k2-=x[a][j].first;
		    }
		}
	    }
	}
    }



    return 0;
}

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

foodcourt.cpp: In function 'int main()':
foodcourt.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d%d%d", &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%d", &qq[i].t);
      |         ~~~~~^~~~~~~~~~~~~~~~
foodcourt.cpp:22:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |             scanf("%d%d%d%d", &qq[i].a, &qq[i].b, &qq[i].c, &qq[i].d);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:24:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |             scanf("%d%d%d", &qq[i].a, &qq[i].b, &qq[i].c);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |             scanf("%d%lld", &qq[i].a, &qq[i].k);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...