Submission #370380

#TimeUsernameProblemLanguageResultExecution timeMemory
370380nicolaalexandraRed-blue table (IZhO19_stones)C++14
100 / 100
881 ms9404 KiB
#include <bits/stdc++.h> #define DIM 1010 using namespace std; int t,n,m,i,j; int a[DIM][DIM],aux[DIM][DIM],lin[DIM],col[DIM]; vector <pair<int,int> > v; int main (){ //ifstream cin ("date.in"); //ofstream cout ("date.out"); cin>>t; for (;t--;){ memset (a,0,sizeof a); memset (aux,0,sizeof aux); memset (lin,0,sizeof lin); memset (col,0,sizeof col); cin>>n>>m; int swapped = 0; if (n > m){ swap (n,m); swapped = 1; } int sol = m; for (i=1;i<=n;i++){ /// verific daca am suficiente coloane libere ca sa formez o linie buna /// nu vreau sa stric coloanele care sunt deja toate ok v.clear(); for (j=1;j<=m;j++){ if (col[j] + 1 <= (n-1)/2) v.push_back(make_pair(col[j],j)); } if (v.size() <= m/2) /// nu mai am cum sa formez nicio linie break; sol++; /// o sa pun unuri pe coloanele unde am cei mai putini sort (v.begin(),v.end()); for (j=0;j<=m/2;j++){ int poz = v[j].second; col[poz]++; lin[i]++; a[i][poz] = 1; } } if (swapped){ for (i=1;i<=n;i++) for (j=1;j<=m;j++) aux[m-j+1][i] = a[i][j]; swap (n,m); for (i=1;i<=n;i++) for (j=1;j<=m;j++) a[i][j] = 1 - aux[i][j]; } cout<<sol<<"\n"; for (i=1;i<=n;i++,cout<<"\n") for (j=1;j<=m;j++){ if (a[i][j]) cout<<"+"; else cout<<"-"; } } return 0; }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:39:26: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |             if (v.size() <= m/2) /// nu mai am cum sa formez nicio linie
      |                 ~~~~~~~~~^~~~~~
#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...