Submission #67330646


Source Code Expand

#include <bits/stdc++.h>
 
using namespace std;

const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int h,w,k;
	cin>>h>>w>>k;
	
	vector<vector<int>> vv(h+1);
	
	for(int i=0; i<k; i++){
		int r,c;
		cin>>r>>c;
		vv[r].push_back(c);
		
	}
	
	for(int i=1; i<=h; i++) sort(vv[i].begin(),vv[i].end());
	
	
	int ct=0;
	
	vector<vector<vector<int>>>  pts(h+1);
	
	for(int i=1; i<=h; i++){
		if(!vv[i].size()){
			pts[i].push_back({1,w,ct++});
			
			
		}
		else if(vv[i].size()==w){
			cout<<"No";
			return 0;		
			
			
		}
		else{
			for(int l=1,r=1,j=0;l<=w;l=r){
				while(j<vv[i].size() && vv[i][j]==l){
					j++;
					l++;
					
				}
				r=(j==vv[i].size())?w+1:vv[i][j];
				pts[i].push_back({l,r-1,ct++});
				
				
			}
			
			
		}
		
		
	}

	vector<vector<int>> gr(ct);
	
	for(int i=1; i<h; i++){
		for(int j=0,k=0; j<pts[i].size(); j++){
			while(k<pts[i+1].size() && pts[i+1][k][1]<pts[i][j][0]) k++;
			while(k<pts[i+1].size() && pts[i+1][k][1]<=pts[i][j][1]){
				gr[pts[i][j][2]].push_back(pts[i+1][k][2]);
				gr[pts[i+1][k][2]].push_back(pts[i][j][2]);
				k++;
			}
			if(k<pts[i+1].size() && pts[i+1][k][0]<=pts[i][j][1]){
				gr[pts[i][j][2]].push_back(pts[i+1][k][2]);
				gr[pts[i+1][k][2]].push_back(pts[i][j][2]);
			}
			
			
			
			
			
		}
		
		
	}
	
	vector<int> vis(ct);
	
	vis[0]=1;
	queue<int> q;
	q.push(0);
	
	while(q.size()){
		int cur=q.front();
		q.pop();
		for(int x:gr[cur]){
			if(!vis[x]){
				vis[x]=1;
				q.push(x);
			}
		}
		
	}
	cout<<(vis[ct-1]?"Yes":"No");
	
	
	
	
	
	
    return 0;
}

Submission Info

Submission Time
Task G - Big Banned Grid
User usernameson
Language C++ 23 (gcc 12.2)
Score 575
Code Size 1674 Byte
Status AC
Exec Time 115 ms
Memory 66228 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:36:37: warning: comparison of integer expressions of different signedness: ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
   36 |                 else if(vv[i].size()==w){
      |                         ~~~~~~~~~~~~^~~
Main.cpp:44:40: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   44 |                                 while(j<vv[i].size() && vv[i][j]==l){
      |                                       ~^~~~~~~~~~~~~
Main.cpp:49:37: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   49 |                                 r=(j==vv[i].size())?w+1:vv[i][j];
      |                                    ~^~~~~~~~~~~~~~
Main.cpp:64:35: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   64 |                 for(int j=0,k=0; j<pts[i].size(); j++){
      |                                  ~^~~~~~~~~~~~~~
Main.cpp:65:32: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   65 |                         while(k<pts[i+1].size() && pts[i+1][k][1]<pts[i][j][0]) k++;
      |                               ~^~~~~~~~~~~~~~~~
Main.cpp:66:32: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   66 |                         while(k<pts[i+1].size() && pts[i+1][k][1]<=pts[i][j][1]){
      |                               ~^~~~~~~~~~~~~~~~
Main.cpp:71:29: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   71 |                         if(k<pts[i+1].size() && pts[i+1][k][0]<=pts[i][j][1]){
      |                            ~^~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 575 / 575
Status
AC × 4
AC × 45
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3548 KiB
00_sample_01.txt AC 1 ms 3460 KiB
00_sample_02.txt AC 1 ms 3468 KiB
00_sample_03.txt AC 1 ms 3552 KiB
01_random_04.txt AC 115 ms 66116 KiB
01_random_05.txt AC 112 ms 66228 KiB
01_random_06.txt AC 114 ms 66116 KiB
01_random_07.txt AC 113 ms 66200 KiB
01_random_08.txt AC 113 ms 66128 KiB
01_random_09.txt AC 112 ms 66112 KiB
01_random_10.txt AC 49 ms 33892 KiB
01_random_11.txt AC 15 ms 11068 KiB
01_random_12.txt AC 78 ms 38420 KiB
01_random_13.txt AC 50 ms 33712 KiB
01_random_14.txt AC 67 ms 37684 KiB
01_random_15.txt AC 73 ms 40820 KiB
01_random_16.txt AC 10 ms 6796 KiB
01_random_17.txt AC 10 ms 10360 KiB
01_random_18.txt AC 20 ms 9356 KiB
01_random_19.txt AC 16 ms 7392 KiB
01_random_20.txt AC 4 ms 4828 KiB
01_random_21.txt AC 7 ms 5980 KiB
01_random_22.txt AC 103 ms 60628 KiB
01_random_23.txt AC 103 ms 59288 KiB
01_random_24.txt AC 102 ms 60844 KiB
01_random_25.txt AC 100 ms 59860 KiB
01_random_26.txt AC 99 ms 59372 KiB
01_random_27.txt AC 101 ms 59832 KiB
01_random_28.txt AC 33 ms 18832 KiB
01_random_29.txt AC 56 ms 37208 KiB
01_random_30.txt AC 44 ms 28680 KiB
01_random_31.txt AC 47 ms 22676 KiB
01_random_32.txt AC 35 ms 36864 KiB
01_random_33.txt AC 64 ms 37684 KiB
01_random_34.txt AC 9 ms 7512 KiB
01_random_35.txt AC 10 ms 4888 KiB
01_random_36.txt AC 9 ms 5748 KiB
01_random_37.txt AC 15 ms 5476 KiB
01_random_38.txt AC 15 ms 9588 KiB
01_random_39.txt AC 1 ms 3712 KiB
01_random_40.txt AC 1 ms 3536 KiB
01_random_41.txt AC 1 ms 3464 KiB
01_random_42.txt AC 6 ms 9396 KiB
01_random_43.txt AC 25 ms 28948 KiB
01_random_44.txt AC 25 ms 29768 KiB