Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <vector>
- using namespace std;
- int n,m,p,lin=1,col=1;
- vector<pair<int,int>> v;
- int check(int &x,int &y)
- {
- if(x<=v[y].first)
- return v[y].second;
- return 0;
- }
- void get_next(int &dx,int &dy)
- {
- v[col]={lin+dx-1,dy};
- while (true)
- {
- int aux=check(lin,col);
- if(!aux)
- return;
- col+=aux;
- if(col==m+1)
- col=1,++lin;
- }
- }
- int main()
- {
- ifstream f("covoare1.in");
- f>>n>>m>>p;
- v.resize(m+1);
- ofstream g("covoare1.out");
- for(int i=1,x,y;i<=p;++i)
- g<<lin<<' '<<col<< '\n',f>>x>>y,get_next(x, y);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement